File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Form data not mapping to bean automatically

C.P Sanchalanam

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="" 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="" value="<c ut value='${}' />" 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 my assumption wrong?

Please help...

Abhilash George

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..

I agree. Here's the link:
subject: Form data not mapping to bean automatically
jQuery in Action, 3rd edition