tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Canfield <joshcanfi...@gmail.com>
Subject Re: Submit inside loop
Date Tue, 01 Nov 2011 18:33:19 GMT
onValidate is fired by your form after all of fields have been
processed, your fields also trigger an validate event. You may want to
be more specific about which field/form your validate method is
intended to service.

Here is a test:

<t:form t:id="form">
    <t:loop source="1..3" index="index">
        <t:submit t:id="top" value="ok ${index}" defer="false"/>
    <t:textfield t:id="text1"/>
    <t:textfield t:id="text2"/>
    <t:textfield t:id="text3"/>
    <t:loop source="1..3" index="index">
        <t:submit t:id="ok" value="ok ${index}" defer="false"/>

    private String text1;    @Property    private String text2;
@Property    private String text3;
    @Property    private int index;
    @Inject    private Logger log;

    private Environment environment;

    void onPrepare() {

    void onValidate() {

    void onValidate(String value) {
        log.info("onValidate('{}')", value);

    void onValidateFromText1(String value) {
        log.info("onValidateFromText1('{}')", value);

    void onSelected() {
        FormSupport formSupport = environment.peek(FormSupport.class);
        formSupport.defer(new Runnable() {

            public void run() {
                log.info("onSelected() deferred");

I typed a,b,c into the form fields, here is the output:

[INFO] pages.SubmitTests onPrepare()
[INFO] pages.SubmitTests onSelected()
[INFO] pages.SubmitTests onValidate('a')
[INFO] pages.SubmitTests onValidate()
[INFO] pages.SubmitTests onValidateFromText1('a')
[INFO] pages.SubmitTests onValidate('b')
[INFO] pages.SubmitTests onValidate()
[INFO] pages.SubmitTests onValidate('c')
[INFO] pages.SubmitTests onValidate()
[INFO] pages.SubmitTests onSelected() deferred
[INFO] pages.SubmitTests onValidate()

You can see that the onValidate is called for each field, in addition
to the single parameter onValidate, and the targeted

Writing this example makes me think there should be a way to get the
component that is actually triggering an event. I don't think that's
currently possible...


On Tue, Nov 1, 2011 at 8:33 AM, George Christman
<gchristman@cardaddy.com> wrote:
> Thanks Josh, I got it working. I do have one question though, I notice it
> runs things in the following order.
> onSelected
> onValidate
> formSupport.defer run code
> back to onValidate
> and back to onSelected
> Should I somehow be preventing it from rerunning the onValidate onSelected a
> second time?
> Thanks,
> George
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Submit-inside-loop-tp4946513p4955519.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

View raw message