> I am trying to get the submit results of a dynamic set of checkboxes
> and I'm stumped.

I'm not sure what you expect the value to be? Also, I don't see
t:context in the checkbox documentation, does that do something?

You are having trouble because you have a list of values going out,
but only a single value coming back in. For each checkbox selected in
the UI a value is passed back to the component. It calls the setter
for each value, overwriting the previous value and leaving you with
the last only the last one.

Try adding a setter for your property and collect the checked values in a list.

something like:

<t:loop source="list" value="item" index="listIndex">
       <t:checkbox t:id="checkbox" t:value="checkbox"/>${item}<br/>
</t:loop>

/** keep track of loop iterations */
private Integer listIndex;

/** loaded with selected checkbox values */
private List<String> selectedItems;

/**
 * Called with the form is posted for every checkbox that is checked.
 * Use the listIndex to grab the right value from the original list.
 **/
public void setCheckbox(boolean set) {
       if (selectedItems == null) selectedItems = new ArrayList<String>();
        selectedItems.add(list.get(listIndex));
}


Josh

On Thu, Jan 21, 2010 at 5:40 PM, Hilco Wijbenga
<hilco.wijbe...@gmail.com> wrote:
> Hi all,
>
> I am trying to get the submit results of a dynamic set of checkboxes
> and I'm stumped.
>
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";>
>  <body>
>    <t:form>
>      <t:loop source="list" value="item">
>        <t:checkbox t:id="checkbox" t:value="checkbox"
> t:context="item"/>${item}<br/>
>      </t:loop>
>      <t:submit/>
>    </t:form>
>  </body>
> </html>
>
>
> public class Test {
>  private final String[] list = new String[] { "Abc", "Defg", "Hijkl", "Mno" };
> �...@property private String item;
> �...@property private boolean checkbox;
>  public String[] getList() {
>    return list;
>  }
> }
>
> If I simply add "onSuccess()" I only get the result for "Mno". Adding
> one or more parameters (for item and checkbox) doesn't seem to work. I
> tried various other methods and combinations but nothing seems to do
> the trick.
>
> How do I do this?
>
> Cheers,
> Hilco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to