Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 80545 invoked from network); 25 Jul 2007 10:01:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Jul 2007 10:01:32 -0000 Received: (qmail 9161 invoked by uid 500); 25 Jul 2007 10:01:27 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 9084 invoked by uid 500); 25 Jul 2007 10:01:27 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org List-Id: Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 9073 invoked by uid 99); 25 Jul 2007 10:01:27 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jul 2007 03:01:27 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [194.45.156.2] (HELO agp.nl) (194.45.156.2) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jul 2007 03:01:25 -0700 Content-class: urn:content-classes:message Subject: RE: Radiobuttons in CForm Repeater Date: Wed, 25 Jul 2007 11:59:32 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C7CEA2.83867780" Message-ID: <50EF6CAD028DF844B9F60BCB3F79AD2F1E232E@agp-dc1.AGP.local> In-Reply-To: X-MimeOLE: Produced By Microsoft Exchange V6.5 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Radiobuttons in CForm Repeater Thread-Index: AcfOnl8OsxtLBs0VQQCX/EDq263GoQAAHfQg References: From: "Robby Pelssers" To: X-Virus-Checked: Checked by ClamAV on apache.org ------_=_NextPart_001_01C7CEA2.83867780 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Markus, =20 I don't think it is possible to accomplish this. You could define a Boolean-field as child of the repeater, but this means that only within one repeaterrow, you will have a radiobutton. =20 I think you could accomplish the behaviour you want by doing something like this: =20 =20 event.source.form.getAttribute("controller").handleIsSelectedValueChange d(event, viewData); =20 =20 =20 =20 // OTHER WIDGETS =20 =20 =20 Your javascript controller would look similar to: ************************************************************************ ** Function ShoppingCart() { this.form =3D new Form("context://??/??/shoppingcart.fd"); this.form.setAttribute("controller", this); } =20 ShoppingCart.prototype.handleIsSelectedValueChanged =3D function(event, viewData) { Var productsRepeater =3D this.form.form.lookupWidget("products"); Var isSelected =3D event.source.getValue().booleanValue(); //only in case isSelected =3D=3D true we need to deselect any other selected product if (isSelected) { var rowIndex =3D productsRepeater.indexOf(event.source.parent); for (var i =3D 0; i < productsRepeater.getSize(); i++) { var row =3D productsRepeater.getRow(i); //we only need to set the values of the other rows to false if (i !=3D rowIndex) { row.lookupWidget("isSelected").setValue(false); } } } } ************************************************************************ ** =20 Hope this helps, =20 Cheers, Robby Pelssers =20 =20 =20 =20 ________________________________ Van: Markus Kratz [mailto:markuskratz@googlemail.com]=20 Verzonden: woensdag, juli 2007 11:31 Aan: users@cocoon.apache.org Onderwerp: Radiobuttons in CForm Repeater =20 Hi, I need a radio button for each item in a CForms repeater, so that the user of this form can select only one item as default. The repeater is used, because there are also other needed widgets in the rows. When I use a boolean-field with the styling "radio" inside the repeater, it is transformed to checkboxes with different names. So even if it would be transformed to radiobuttons, it wouldn't work like I suspected. When I use a selection-list inside the repeater, there is a selection-list for each row in the repeater. Also not what I expect. I only have an idea for a workaround, which doesn't satisfy me. So does anybody know how to solve this problem?=20 Best regards, Markus Kratz ------_=_NextPart_001_01C7CEA2.83867780 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi = Markus,

 

I don’t think it is possible = to accomplish this.  You could define a Boolean-field as child of the repeater, but this means that only within one repeaterrow, you will have = a radiobutton.

 

I think you could accomplish the = behaviour you want by doing something like this:

 

<fd:form xmlns:fd=3D"http://apache.org/cocoon/forms/1.0#definition&q= uot;>

  <fd:widgets>

    <fd:repeater = id=3D”products”>

      = <fd:widgets>

    =     <fd:booleanfield id=3D"isSelected">

      =     <fd:datatype base=3D"boolean"/>

  =
<fd:on-value-changed>

        =     <javascript>

          =     event.source.form.getAttribute("controller&q= uot;).handleIsSelectedValueChanged(event, viewData);   

    =
</javascript>  &nbs=
p;  
  </fd:on-value-changed><=
/o:p>

    =     </fd:booleanfield> =

 

         &nbs= p; // OTHER WIDGETS

 

      = </fd:widgets>

    </fd:repeater> =

  </fd:widgets>

</fd:form>

 

Your javascript controller would look similar = to:

**********************************************************= ****************

Function ShoppingCart() {

    = this.form =3D new = Form("context://??/??/shoppingcart.fd");

    this.form.setAttribute("controller", this);

}

 

ShoppingCart.prototype.handleIsSelectedValueChanged =3D = function(event, viewData) {

    Var productsRepeater =3D this.form.form.lookupWidget(“products”);

    Var isSelected =3D = event.source.getValue().booleanValue();

    //only in case isSelected =3D=3D true = we need to deselect any other selected product

    if (isSelected) = {

        var rowIndex = =3D = productsRepeater.indexOf(event.source.parent);

        for (var i =3D = 0; i < productsRepeater.getSize(); i++) {

         &nbs= p;  var row =3D productsRepeater.getRow(i);

         &nbs= p;  //we only need to set the values of the other rows to = false

         &nbs= p;  if (i !=3D rowIndex) {

         &nbs= p;      row.lookupWidget(“isSelected”).setValue(false);

         &nbs= p;  }

        = }

    }

}

**********************************************************= ****************

 

Hope this helps,

 

Cheers,

Robby Pelssers

 

 

 =

 


Van: = Markus Kratz [mailto:markuskratz@googlemail.com]
Verzonden: woensdag, juli = 2007 11:31
Aan: users@cocoon.apache.org
Onderwerp: Radiobuttons = in CForm Repeater

 

Hi,

I need a radio button for each item in a CForms repeater, so that the = user of this form can select only one item as default.  The repeater is = used, because there are also other needed widgets in the rows.

When I use a boolean-field with the styling "radio" inside the repeater, it is transformed to checkboxes with different names. So even = if it would be transformed to radiobuttons, it wouldn't work like I = suspected.

When I use a selection-list inside the repeater, there is a = selection-list for each row in the repeater. Also not what I expect.

I only have an idea for a workaround, which doesn't satisfy me. So does = anybody know how to solve this problem?

Best regards,
Markus Kratz

------_=_NextPart_001_01C7CEA2.83867780--