tags:

views:

40

answers:

1

Greetings,

This is a simple question I believe, but nonetheless it is stumping me right now.

I have a TestForm class with your usual getters/setters...for example I have an "id" field with "getId" and "setId" methods.

My form is populated in an action class correctly (which I know from stepping through the Eclipse debugger) just before it is sent to the jsp page which has the code below:

<html:form action="/AppropriateAction">  
<bean:define id="testFormA" name="TestForm" type="com.whatever.form.TestForm" />

form = <bean:write name="testFormA" />##  
id = <bean:write name="testFormA" property="id" />##  

</html:form>  

My output looks like this:

form = com.whatever.form.TestForm13a3x4##

id = ##

Now I know that the page can see the form correctly due to the first line of the output, but if this is the case then why does the id show that it is empty from this statement:

id = <bean:write name="testFormA" property="id" />##  

What am I doing wrong to access the id field of my form on this jsp page?

Many thanks!

+1  A: 

writing properties from a form with bean:write is possible with using the form name. in your case you can use the following code:

form: <bean:write name="TestForm"/>##
id = <bean:write name="TestForm" property="id" />

This should work better i guess

Salandur
Your answer is clear and I appreciate that. However, I have implemented the code exactly as you have it above and am still receiving this as output:form = com.whatever.form.TestForm13a3x4##id = ##What else could I try or what am I missing?
risingTide
is the form correctly linked to the action in the struts-config.xml? it is strange btw that the form output is printet as com.whatever.form.TestForm13a3x5, it should be ...TestForm@13a3x4. if you view the generated page, does it look correct?
Salandur