Hello again all,
I'm currently trying to get a product working here and its driving me
nuts.
Ive been working all day on a stupidly complicated way of filling form
values. Ill skip the complicated part out and give you the current
part of the problem i just cannot understand.
Basically, one of my jsp's is forwarding to search.do?
searchTermLanguage="English". This uses:
<action path="/articles/search" forward="/WEB-INF/jsp/articles/
searchForm.jsp" name="AdvancedSearchForm" validate="false"
scope="session"/>
on searchForm.jsp, there is a form input element named
"searchTermLanguage". At the point this page loads, i /thought/ that
searchTermLanguage field would automatically fill with the term
"English". But it isn't.
Could someone tell me why? pretty please? If i have to come into work
again tomorrow and sit glaring at eclipse im going to go on some sort
of spree.
Graeme
Joe Attardi - 06 Dec 2007 15:58 GMT
> Basically, one of my jsp's is forwarding to search.do?
> searchTermLanguage="English". This uses:
[quoted text clipped - 7 lines]
> searchTermLanguage field would automatically fill with the term
> "English". But it isn't.
Does the AdvancedSearchForm have a setter method
setSearchTermLanguage(String)?
When you request an action in Struts, it takes the parameters passed (in
this case searchTermLanguage) and looks for a corresponding setter
method (following the normal JavaBeans convention). If it finds one, it
calls it, passing in the value.
gwoodhouse@gmail.com - 06 Dec 2007 16:03 GMT
> gwoodho...@gmail.com wrote:
> > Basically, one of my jsp's is forwarding to search.do?
[quoted text clipped - 16 lines]
> method (following the normal JavaBeans convention). If it finds one, it
> calls it, passing in the value.
Yes it does,
Thanks for the suggestion, ill try debugging the setter method to see
if it does in fact set.
gwoodhouse@gmail.com - 06 Dec 2007 16:13 GMT
On Dec 6, 4:03 pm, "gwoodho...@gmail.com" <gwoodho...@gmail.com>
wrote:
> > gwoodho...@gmail.com wrote:
> > > Basically, one of my jsp's is forwarding to search.do?
[quoted text clipped - 21 lines]
> Thanks for the suggestion, ill try debugging the setter method to see
> if it does in fact set.
It seems that the value is indeed set.
I also set a break point on the reset method of my form. The problem
being that by the time it gets to the reset method the value is
already null again - its been lossed between it being set and the form
being reset as the page loads.
I guess my job now is to find why the heck the form is losing its
values! Any help would be very very very appreciated.
gwoodhouse@gmail.com - 30 Jan 2008 12:53 GMT
Sorry for my late response,
I found the problem with my code: I had set the scope to "session",
this was dumping and creating a whole new form for me. Setting the
form to request instead fixed my problem.
Hope this helps anyone else that searches for a similar problem.
Owen Jacobson - 06 Dec 2007 19:34 GMT
On Dec 6, 7:49 am, "gwoodho...@gmail.com" <gwoodho...@gmail.com>
wrote:
> Hello again all,
>
[quoted text clipped - 22 lines]
>
> Graeme
Assuming for the moment that your ActionForm is being populated and
preserved for the request...
Keep in mind that struts will only populate form fields for you if you
use the <html:foo> taglib elements (<html:text>, <html:select>, etc).
It can't automatically fill in <input> elements' value attributes for
you.
You can, of course, populate the value attribute yourself if you don't
want to use the HTML taglib, using f.e. value="$
{myFormName.someProperty}".