File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Form data not mapping to bean automatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Form data not mapping to bean automatically" Watch "Form data not mapping to bean automatically" New topic
Author

Form data not mapping to bean automatically

C.P Sanchalanam
Greenhorn

Joined: Aug 05, 2006
Posts: 15
Hi there,

I am bit new to struts framework and currently implimenting an application using struts 1.2.7. I am breaking my head to fix the following issue..any help is truly appreciated.

If I use struts tablib to display property "name" of a bean "project" It works fine(maps request parameter 'name' to the bean automatically).
<html:text property="project.name" size="10"/>

But, if I change the above code to use standard html <input> element along with JSTL 'c ut', 'name' is not being mapped to the bean automatically as it did with the previous code(shown above).

<input type="text" name="project.name" value="<c ut value='${project.name}' />" size="10" >

Any help to fix this issue? Do i have to explicitly map request data(name) to the bean manually? I have assumed that, if the request contains any of the parameters that match the properties of the formbean then struts will take care of automatically mapping request data to the bean...is my assumption wrong?

Please help...

Thanks,
sanchi
Abhilash George
Greenhorn

Joined: Apr 28, 2006
Posts: 13
hi there
Yes your assumption regarding field names in request getting mapped to formbean property with the same name is correct . I used
<INPUT type="text" name="meter" value="caloriemeter" size="20"> in my jsp
with meter being a field in my form . I could check the value getting set in the setMeter(String mtr) method of my formbean. I am not sure about the JSTL part of your code. You can check the value that is coming into the set"Parametername" method in your form..


george
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form data not mapping to bean automatically