You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Carl Smith <cc...@yahoo.com> on 2005/10/19 04:13:00 UTC

form.submit() issue with

I seem to have a issue using <html:button>'s onclick. My value of onclick is a javascript performing form.submit(), but I found out this is not working. However if I chang my button to <html:submit> then the javascript is working. Why this is the case? Thanks.

		
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

Re: form.submit() issue with

Posted by "Mark J." <ma...@gmail.com>.
Hi Carl,

Mind telling us the cause of your problem?

On 10/20/05, Carl Smith <cc...@yahoo.com> wrote:
> Thank you Martin on this information. This issue was resolved. Basically there was another error in my jsp that cause this issue. Now it is working fine. Simply put <html:button> does support form.submit() when correctly code in onclick.
>
> I will however have another issue with sturts validator when using form.submit(), which I will initiate another topic.
>
> Thanks.
>
> Martin Gainty <mg...@hotmail.com> wrote:
> Referencing
> http://struts.apache.org/api/org/apache/struts/taglib/html/BaseHandlerTag.html#triedJstlSuccess
>
> To quote the doc
> org.apache.struts.taglib.html.BaseHandlerTag
> Base class for tags that render form elements capable of including
> JavaScript event handlers and/or CSS Style attributes. This class does not
> implement the doStartTag() or doEndTag() methods. Subclasses should provide
> appropriate implementations of these.
>
> the underlying base class class of SubmitButton is in fact
> org.apache.struts.taglib.html.BaseHandlerTag which has an onClick event you
> can use
>
> then again why would your javascript function be calling
> JavaScriptFunction()
> { form.submit(); }
> when your submit logic is already processing the onClick event ?
>
> M-
> ----- Original Message -----
> From: "Carl Smith"
> To: "Struts Users Mailing List"
> Cc: "Struts Users Mailing List"
> Sent: Wednesday, October 19, 2005 3:45 PM
> Subject: Re: form.submit() issue with
>
>
> > What I really want to know is how to use and still using
> > onclick to call javascript to submit the form.
> >
> > Martin Gainty wrote:Good Morning Carl
> >
> > excerpted from Craig:
> > The challenge with doing this is that the JSP tags run on the server (as
> > the
> > page is being generated), while the JavaScript runs on the client side. To
> > integrate the two, you need your tags (and other JSP code) to dynamically
> > generate the JavaScript functions themselves -- sort of having a program
> > write a program -- so that the JavaScript is customized to your particular
> > need on this particular page.
> >
> > A very trivial example is the way that the tag deals with the
> > "focus" attribute. If you specify it, a dynamically generated bit of
> > JavaScript is created to set the input focus, which includes the name of
> > the
> > field you want initial focus assigned to.
> >
> > html:submit (submit button class) is derived from same parent as html:form
> > (javax.servlet.jsp.tagext.TagSupport)
> > so the characteristic of a server side Tag class(dynamically) generating
> > JavaScript holds true
> >
> > Does this answer your question?
> > Martin-
> >
> > ----- Original Message -----
> > From: "Carl Smith"
> > To: "Struts Users Mailing List"
> > Sent: Tuesday, October 18, 2005 10:13 PM
> > Subject: form.submit() issue with
> >
> >
> >>I seem to have a issue using 's onclick. My value of onclick
> >>is a javascript performing form.submit(), but I found out this is not
> >>working. However if I chang my button to then the javascript
> >>is working. Why this is the case? Thanks.
> >>
> >>
> >> ---------------------------------
> >> Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> >
> > ---------------------------------
> > Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
> ---------------------------------
>  Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
>

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


Re: form.submit() issue with

Posted by Carl Smith <cc...@yahoo.com>.
Thank you Martin on this information. This issue was resolved. Basically there was another error in my jsp that cause this issue. Now it is working fine. Simply put <html:button> does support form.submit() when correctly code in onclick.
 
I will however have another issue with sturts validator when using form.submit(), which I will initiate another topic.
 
Thanks.

Martin Gainty <mg...@hotmail.com> wrote:
Referencing
http://struts.apache.org/api/org/apache/struts/taglib/html/BaseHandlerTag.html#triedJstlSuccess

To quote the doc
org.apache.struts.taglib.html.BaseHandlerTag
Base class for tags that render form elements capable of including 
JavaScript event handlers and/or CSS Style attributes. This class does not 
implement the doStartTag() or doEndTag() methods. Subclasses should provide 
appropriate implementations of these.

the underlying base class class of SubmitButton is in fact 
org.apache.struts.taglib.html.BaseHandlerTag which has an onClick event you 
can use

then again why would your javascript function be calling
JavaScriptFunction()
{ form.submit(); }
when your submit logic is already processing the onClick event ?

M-
----- Original Message ----- 
From: "Carl Smith" 
To: "Struts Users Mailing List" 
Cc: "Struts Users Mailing List" 
Sent: Wednesday, October 19, 2005 3:45 PM
Subject: Re: form.submit() issue with 


> What I really want to know is how to use and still using 
> onclick to call javascript to submit the form.
>
> Martin Gainty wrote:Good Morning Carl
>
> excerpted from Craig:
> The challenge with doing this is that the JSP tags run on the server (as 
> the
> page is being generated), while the JavaScript runs on the client side. To
> integrate the two, you need your tags (and other JSP code) to dynamically
> generate the JavaScript functions themselves -- sort of having a program
> write a program -- so that the JavaScript is customized to your particular
> need on this particular page.
>
> A very trivial example is the way that the tag deals with the
> "focus" attribute. If you specify it, a dynamically generated bit of
> JavaScript is created to set the input focus, which includes the name of 
> the
> field you want initial focus assigned to.
>
> html:submit (submit button class) is derived from same parent as html:form
> (javax.servlet.jsp.tagext.TagSupport)
> so the characteristic of a server side Tag class(dynamically) generating
> JavaScript holds true
>
> Does this answer your question?
> Martin-
>
> ----- Original Message ----- 
> From: "Carl Smith"
> To: "Struts Users Mailing List"
> Sent: Tuesday, October 18, 2005 10:13 PM
> Subject: form.submit() issue with
>
>
>>I seem to have a issue using 's onclick. My value of onclick
>>is a javascript performing form.submit(), but I found out this is not
>>working. However if I chang my button to then the javascript
>>is working. Why this is the case? Thanks.
>>
>>
>> ---------------------------------
>> Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
> ---------------------------------
> Yahoo! Music Unlimited - Access over 1 million songs. Try it free. 

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


		
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

Re: form.submit() issue with

Posted by Martin Gainty <mg...@hotmail.com>.
Referencing
http://struts.apache.org/api/org/apache/struts/taglib/html/BaseHandlerTag.html#triedJstlSuccess

To quote the doc
org.apache.struts.taglib.html.BaseHandlerTag
Base class for tags that render form elements capable of including 
JavaScript event handlers and/or CSS Style attributes. This class does not 
implement the doStartTag() or doEndTag() methods. Subclasses should provide 
appropriate implementations of these.

the underlying base class class of SubmitButton is in fact 
org.apache.struts.taglib.html.BaseHandlerTag which has an onClick event you 
can use

then again why would your javascript function be calling
JavaScriptFunction()
{ form.submit(); }
when your submit logic is already processing the onClick event ?

M-
----- Original Message ----- 
From: "Carl Smith" <cc...@yahoo.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Cc: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Wednesday, October 19, 2005 3:45 PM
Subject: Re: form.submit() issue with <html:button>


> What I really want to know is how to use <html:button> and still using 
> onclick to call javascript to submit the form.
>
> Martin Gainty <mg...@hotmail.com> wrote:Good Morning Carl
>
> excerpted from Craig:
> The challenge with doing this is that the JSP tags run on the server (as 
> the
> page is being generated), while the JavaScript runs on the client side. To
> integrate the two, you need your tags (and other JSP code) to dynamically
> generate the JavaScript functions themselves -- sort of having a program
> write a program -- so that the JavaScript is customized to your particular
> need on this particular page.
>
> A very trivial example is the way that the tag deals with the
> "focus" attribute. If you specify it, a dynamically generated bit of
> JavaScript is created to set the input focus, which includes the name of 
> the
> field you want initial focus assigned to.
>
> html:submit (submit button class) is derived from same parent as html:form
> (javax.servlet.jsp.tagext.TagSupport)
> so the characteristic of a server side Tag class(dynamically) generating
> JavaScript holds true
>
> Does this answer your question?
> Martin-
>
> ----- Original Message ----- 
> From: "Carl Smith"
> To: "Struts Users Mailing List"
> Sent: Tuesday, October 18, 2005 10:13 PM
> Subject: form.submit() issue with
>
>
>>I seem to have a issue using 's onclick. My value of onclick
>>is a javascript performing form.submit(), but I found out this is not
>>working. However if I chang my button to then the javascript
>>is working. Why this is the case? Thanks.
>>
>>
>> ---------------------------------
>> Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
> ---------------------------------
> Yahoo! Music Unlimited - Access over 1 million songs. Try it free. 

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


Re: form.submit() issue with

Posted by Carl Smith <cc...@yahoo.com>.
What I really want to know is how to use <html:button> and still using onclick to call javascript to submit the form.

Martin Gainty <mg...@hotmail.com> wrote:Good Morning Carl

excerpted from Craig:
The challenge with doing this is that the JSP tags run on the server (as the 
page is being generated), while the JavaScript runs on the client side. To 
integrate the two, you need your tags (and other JSP code) to dynamically 
generate the JavaScript functions themselves -- sort of having a program 
write a program -- so that the JavaScript is customized to your particular 
need on this particular page.

A very trivial example is the way that the tag deals with the 
"focus" attribute. If you specify it, a dynamically generated bit of 
JavaScript is created to set the input focus, which includes the name of the 
field you want initial focus assigned to.

html:submit (submit button class) is derived from same parent as html:form 
(javax.servlet.jsp.tagext.TagSupport)
so the characteristic of a server side Tag class(dynamically) generating 
JavaScript holds true

Does this answer your question?
Martin-

----- Original Message ----- 
From: "Carl Smith" 
To: "Struts Users Mailing List" 
Sent: Tuesday, October 18, 2005 10:13 PM
Subject: form.submit() issue with 


>I seem to have a issue using 's onclick. My value of onclick 
>is a javascript performing form.submit(), but I found out this is not 
>working. However if I chang my button to then the javascript 
>is working. Why this is the case? Thanks.
>
>
> ---------------------------------
> Yahoo! Music Unlimited - Access over 1 million songs. Try it free. 

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



		
---------------------------------
 Yahoo! Music Unlimited - Access over 1 million songs. Try it free.

Re: form.submit() issue with

Posted by Martin Gainty <mg...@hotmail.com>.
Good Morning Carl

excerpted from Craig:
The challenge with doing this is that the JSP tags run on the server (as the 
page is being generated), while the JavaScript runs on the client side. To 
integrate the two, you need your tags (and other JSP code) to dynamically 
generate the JavaScript functions themselves -- sort of having a program 
write a program -- so that the JavaScript is customized to your particular 
need on this particular page.

A very trivial example is the way that the <html:form> tag deals with the 
"focus" attribute. If you specify it, a dynamically generated bit of 
JavaScript is created to set the input focus, which includes the name of the 
field you want initial focus assigned to.

html:submit (submit button class) is derived from same parent as html:form 
(javax.servlet.jsp.tagext.TagSupport)
so the characteristic of a server side Tag class(dynamically) generating 
JavaScript holds true

Does this answer your question?
Martin-

----- Original Message ----- 
From: "Carl Smith" <cc...@yahoo.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, October 18, 2005 10:13 PM
Subject: form.submit() issue with <html:button>


>I seem to have a issue using <html:button>'s onclick. My value of onclick 
>is a javascript performing form.submit(), but I found out this is not 
>working. However if I chang my button to <html:submit> then the javascript 
>is working. Why this is the case? Thanks.
>
>
> ---------------------------------
> Yahoo! Music Unlimited - Access over 1 million songs. Try it free. 

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


Re: form.submit() issue with

Posted by Aldo Vadillo Batista <al...@gmail.com>.
Have you put *submit()* correctly? It works:
 <html:button onclick="document.forms[0].submit();" />

 2005/10/19, Carl Smith <cc...@yahoo.com>:
>
> I seem to have a issue using <html:button>'s onclick. My value of onclick
> is a javascript performing form.submit(), but I found out this is not
> working. However if I chang my button to <html:submit> then the javascript
> is working. Why this is the case? Thanks.
>
>
> ---------------------------------
> Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
>