You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by i n <in...@gmail.com> on 2005/12/06 02:05:31 UTC

Discovering which submit button was pressed, on page load

Hi,

I have a form with multiple submit buttons.  When the form is submitted (and
before validation occurs, and before the button listeners get called), I
want to find out some information about how the request was submitted.

* How I can determine the submitting button?  I have tried implementing
PageValidateListener, and looking at the PageEvent, but can't seem to find
the button's name.
* Assume the button is inside a @For component, and the button's listener is
parameterized with the row number (e.g., doSubmit(Integer index)).  How can
I determine this number upon page load?

Any help is appreciated.
Thanks

RE: Discovering which submit button was pressed, on page load

Posted by Patrick Casey <pa...@adelphia.net>.
	Not unless your button listeners rewind before your widgets, nope.
In 3.0.3 the rewind process was basically top to bottom so putting your
button on top of the form did the trick. I seem to recall though that Howard
changed it for 4.0 so that button listeners now run after widget rewind, but
there might be a flag to specify the old behavior. Somebody more familiar
with 4.0 could answer that for you though.

	--- Pat

> -----Original Message-----
> From: i n [mailto:in1500@gmail.com]
> Sent: Monday, December 05, 2005 5:47 PM
> To: Tapestry users
> Subject: Re: Discovering which submit button was pressed, on page load
> 
> Many thanks for everyone's answers.
> 
>         The quick answer is: short of doing some client side javascript,
> you
> > can't tell.
> >
> >         You could try using button listeners,
> 
> 
> 
> The problem is that this would bypass the form validation.  Is there any
> way
> I can *force* validation within the button listener, after I've done the
> necessary processing?
> 
> My entire problem boils down to - I need to perform some actions on the
> data
> source, depending on the button pressed, before validation of the data
> source occurs.
> 
> or the selected and tag
> > attributes of the submit button to differentiate button pushes. These
> > though
> > are set during the rewind cycle so you won't be able to intuit this
> > information.
> >
> >         One approach you could do would be to interrogate the servlet
> > request manually and try to figure out which button was pushed that way,
> > but
> > I hesitate to suggest it because it basically involves an aggressive
> > end-run
> > around Tapestry.
> >
> >         --- Pat
> > > -----Original Message-----
> > > From: i n [mailto:in1500@gmail.com]
> > > Sent: Monday, December 05, 2005 5:06 PM
> > > To: tapestry-user@jakarta.apache.org
> > > Subject: Discovering which submit button was pressed, on page load
> > >
> > > Hi,
> > >
> > > I have a form with multiple submit buttons.  When the form is
> submitted
> > > (and
> > > before validation occurs, and before the button listeners get called),
> I
> > > want to find out some information about how the request was submitted.
> > >
> > > * How I can determine the submitting button?  I have tried
> implementing
> > > PageValidateListener, and looking at the PageEvent, but can't seem to
> > find
> > > the button's name.
> > > * Assume the button is inside a @For component, and the button's
> > listener
> > > is
> > > parameterized with the row number (e.g., doSubmit(Integer index)).
> How
> > > can
> > > I determine this number upon page load?
> > >
> > > Any help is appreciated.
> > > Thanks
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Discovering which submit button was pressed, on page load

Posted by i n <in...@gmail.com>.
Many thanks for everyone's answers.

        The quick answer is: short of doing some client side javascript, you
> can't tell.
>
>         You could try using button listeners,



The problem is that this would bypass the form validation.  Is there any way
I can *force* validation within the button listener, after I've done the
necessary processing?

My entire problem boils down to - I need to perform some actions on the data
source, depending on the button pressed, before validation of the data
source occurs.

or the selected and tag
> attributes of the submit button to differentiate button pushes. These
> though
> are set during the rewind cycle so you won't be able to intuit this
> information.
>
>         One approach you could do would be to interrogate the servlet
> request manually and try to figure out which button was pushed that way,
> but
> I hesitate to suggest it because it basically involves an aggressive
> end-run
> around Tapestry.
>
>         --- Pat
> > -----Original Message-----
> > From: i n [mailto:in1500@gmail.com]
> > Sent: Monday, December 05, 2005 5:06 PM
> > To: tapestry-user@jakarta.apache.org
> > Subject: Discovering which submit button was pressed, on page load
> >
> > Hi,
> >
> > I have a form with multiple submit buttons.  When the form is submitted
> > (and
> > before validation occurs, and before the button listeners get called), I
> > want to find out some information about how the request was submitted.
> >
> > * How I can determine the submitting button?  I have tried implementing
> > PageValidateListener, and looking at the PageEvent, but can't seem to
> find
> > the button's name.
> > * Assume the button is inside a @For component, and the button's
> listener
> > is
> > parameterized with the row number (e.g., doSubmit(Integer index)).  How
> > can
> > I determine this number upon page load?
> >
> > Any help is appreciated.
> > Thanks
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

Re: Discovering which submit button was pressed, on page load

Posted by Konstantin Ignatyev <kg...@yahoo.com>.
Look at my old post
http://article.gmane.org/gmane.comp.java.tapestry.user/19946/match=ignatyev+submit
hope it is helpful

--- i n <in...@gmail.com> wrote:

> Hi,
> 
> I have a form with multiple submit buttons.  When
> the form is submitted (and
> before validation occurs, and before the button
> listeners get called), I
> want to find out some information about how the
> request was submitted.
> 
> * How I can determine the submitting button?  I have
> tried implementing
> PageValidateListener, and looking at the PageEvent,
> but can't seem to find
> the button's name.
> * Assume the button is inside a @For component, and
> the button's listener is
> parameterized with the row number (e.g.,
> doSubmit(Integer index)).  How can
> I determine this number upon page load?
> 
> Any help is appreciated.
> Thanks
> 


Konstantin Ignatyev




PS: If this is a typical day on planet earth, humans will add fifteen million tons of carbon to the atmosphere, destroy 115 square miles of tropical rainforest, create seventy-two miles of desert, eliminate between forty to one hundred species, erode seventy-one million tons of topsoil, add 2,700 tons of CFCs to the stratosphere, and increase their population by 263,000

Bowers, C.A.  The Culture of Denial:  Why the Environmental Movement Needs a Strategy for Reforming Universities and Public Schools.  New York:  State University of New York Press, 1997: (4) (5) (p.206)

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: Discovering which submit button was pressed, on page load

Posted by Patrick Casey <pa...@adelphia.net>.
	The quick answer is: short of doing some client side javascript, you
can't tell.

	You could try using button listeners, or the selected and tag
attributes of the submit button to differentiate button pushes. These though
are set during the rewind cycle so you won't be able to intuit this
information.

	One approach you could do would be to interrogate the servlet
request manually and try to figure out which button was pushed that way, but
I hesitate to suggest it because it basically involves an aggressive end-run
around Tapestry.

	--- Pat
> -----Original Message-----
> From: i n [mailto:in1500@gmail.com]
> Sent: Monday, December 05, 2005 5:06 PM
> To: tapestry-user@jakarta.apache.org
> Subject: Discovering which submit button was pressed, on page load
> 
> Hi,
> 
> I have a form with multiple submit buttons.  When the form is submitted
> (and
> before validation occurs, and before the button listeners get called), I
> want to find out some information about how the request was submitted.
> 
> * How I can determine the submitting button?  I have tried implementing
> PageValidateListener, and looking at the PageEvent, but can't seem to find
> the button's name.
> * Assume the button is inside a @For component, and the button's listener
> is
> parameterized with the row number (e.g., doSubmit(Integer index)).  How
> can
> I determine this number upon page load?
> 
> Any help is appreciated.
> Thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org