cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robby Pelssers" <robby.pelss...@agp.nl>
Subject RE: Radiobuttons in CForm Repeater
Date Wed, 25 Jul 2007 09:59:32 GMT
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="http://apache.org/cocoon/forms/1.0#definition">

  <fd:widgets>

    <fd:repeater id="products">

      <fd:widgets>

        <fd:booleanfield id="isSelected">

          <fd:datatype base="boolean"/>

  <fd:on-value-changed>

            <javascript>

 
event.source.form.getAttribute("controller").handleIsSelectedValueChange
d(event, viewData);    

    </javascript>     
  </fd:on-value-changed>

        </fd:booleanfield> 

 

           // OTHER WIDGETS

 

      </fd:widgets>

    </fd:repeater> 

  </fd:widgets>

</fd:form>

 

Your javascript controller would look similar to:

************************************************************************
**

Function ShoppingCart() {

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

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

}

 

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

    Var productsRepeater = this.form.form.lookupWidget("products");

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

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

    if (isSelected) {

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

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

            var row = productsRepeater.getRow(i);

            //we only need to set the values of the other rows to false

            if (i != rowIndex) {

                row.lookupWidget("isSelected").setValue(false);

            }

        }

    }

}

************************************************************************
**

 

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


Mime
View raw message