struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wellie W. Chao" <wc...@caraveltech.com>
Subject Tricky javascript problem performing programmatic form submit with struts
Date Sat, 06 Apr 2002 16:22:28 GMT
I spent a good hour hunting down the source of my problem with trying to
programmatically submit a form and thought I'd share the solution for others
who are using struts. I wanted to have a select list automatically cause its
containing form to submit when the value of the select list changed. This is
useful for simple sorts or subsearches in a search result list.

In my JSP page, I had the following code:

<html:select property="mySelectName"
             onchange="this.form.submit()">
  <html:options name="mySelectOptionCollection">
</html:select>

I kept getting "Object doesn't support this property or method" from my
browser. Finally I figured out that by default, struts gives <html:submit/>
tags a name of "submit". Thus there was a namespace collision in the form
object, with the submit button overriding the form's submit method. I fixed
the problem by changing the name of the submit button. Something like this
works great:

<html:submit property="submitProperty" value="The Label I Want"/>

Perhaps the default name for submit buttons could be changed in struts in
the future to avoid such namespace collisions, especially with very standard
methods and properties like form.submit?


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


Mime
View raw message