Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form data not mapping to bean automatically

 
C.P Sanchalanam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic