Originally posted by Merrill Higginson:
If a form bean does not exist in its specified scope (request or session), Struts instantiates it prior to displaying the JSP. By "form bean", I mean the class specified in your struts-config.xml file.
Before we go any further, though, I need to understand more about what you're trying to accomplish. Are you trying to immediately change the value in one field when the user enters something in another? If so, you won't accomplish this at all by changing the value attribute of a Struts html:text tag. The only way to do this is with JavaScript, which means you would probably write some JavaScript code to be executed by the "onblur" event of the field being changed by the user that would then change the value of the field you want automatically changed. Example:
Note that the above should be "onblur" instead of "on_blur", but I had to change it to get around the JavaRanch filters. In this example, as soon as the user enters a value in field1 and moves the cursor away from it, field2 will be populated with the same value.
The reason the value attribute won't help you in this case is that it determines the value of a field before the HTML is sent back to the browser, so any changes made by the client will not have any effect.
[ December 06, 2007: Message edited by: Merrill Higginson ]
Hello
I tried it with the formbean that is associated with the action of the form, and still the value is not adduced.
The background is that I have a js function triggered off the onSubmit that creates an array of the form element values and processes them. I would like to get that array, as it is processed not the form element values at the time of submit, as a single parameter to the Action. Because I want the values as processed in the js function sent to the Action, I am stuck in that I cant access that js array or iterate it as the value of the multiple <html:text property="sameVar" value="iteratedValueFromJSArray"/>
I may just have to rethink the approach, as I dont thinnk it can be done this way. Correct? tia.