You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by mark99 <ma...@vexeddigital.com> on 2009/05/18 19:11:11 UTC
Checkboxes within a loop in a form
Hi
I've got a problem implementing a form which renders checkboxes within a
loop, and then posts back the values of the checkboxes on form submission.
In my form submission handler, I need to know which checkboxes the user
checked.
What I'm looking to do is something like this:
Page:
<t:form>
<t:loop source="choices" value="choice">
<t:checkbox t:value="choice"/>
</t:loop>
<t:submit/>
</t:form>
Class:
void onSubmit() {
for(boolean b : choices)
System.out.println(b);
}
Where 'choices' is a List of booleans.
If I put @Persist on 'choices', the list is still null on postback, which I
expected. If I re-initialize the list on postback that doesn't help either
as I've lost the results from the form.
So what is the solution for doing this type of thing?
Thanks, Mark
--
View this message in context: http://www.nabble.com/Checkboxes-within-a-loop-in-a-form-tp23601662p23601662.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Checkboxes within a loop in a form
Posted by Dave Greggory <da...@yahoo.com>.
I believe you will need a submit notifier component.
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/SubmitNotifier.html
Wrap the submit notifier around <t:checkbox> and use the AfterSubmit event to capture its values.
----- Original Message ----
From: mark99 <ma...@vexeddigital.com>
To: users@tapestry.apache.org
Sent: Monday, May 18, 2009 1:11:11 PM
Subject: Checkboxes within a loop in a form
Hi
I've got a problem implementing a form which renders checkboxes within a
loop, and then posts back the values of the checkboxes on form submission.
In my form submission handler, I need to know which checkboxes the user
checked.
What I'm looking to do is something like this:
Page:
<t:form>
<t:loop source="choices" value="choice">
<t:checkbox t:value="choice"/>
</t:loop>
<t:submit/>
</t:form>
Class:
void onSubmit() {
for(boolean b : choices)
System.out.println(b);
}
Where 'choices' is a List of booleans.
If I put @Persist on 'choices', the list is still null on postback, which I
expected. If I re-initialize the list on postback that doesn't help either
as I've lost the results from the form.
So what is the solution for doing this type of thing?
Thanks, Mark
--
View this message in context: http://www.nabble.com/Checkboxes-within-a-loop-in-a-form-tp23601662p23601662.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org