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

struts beginner. Pls answer this.

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have jsp page. it contains two fields

<html:text property="username" />
<html:text property="password">

1. if i use two fields username, and password, Is getter and setter methods are necessary?

2. i have one page contains field name, datatype, length. i want to add both database column and generate getter and setter methods and display in the jsp.

Is it possible? if possible tell me. Actually it is a our own custom field display.

3. If it is not possible, kindly tell me your own suggestions.
Thanks

a.edward durai
 
Amit Ghai
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The associated ActionForm should have getter and setter for the username and password field. Hope you wanted to know this. Your question is not very clear..
 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excuse me, Thanks for your reply,

Ok. pls answer other questions
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your questions are not very clear, but if I understand you correctly, you are trying to generate fields dynamically, meaning that you don't know the name, type or length of the field until run-time.

One way to do this would be to define your ActionForm as type org.apache.struts.validator.LazyValidatorForm. This is a form bean provided by Struts that does not require you to define getters or setters for properties or to define them ahead of time in the struts-config.xml file. If you use this class as the ActionForm, any <html:text> fields that you define with any property name will be populated into the ActionForm bean when the form is submitted. All of the properties will be of type String, but if you have another field telling you what the correct type is, you can then convert to the correct type.

Here is the link to the javadoc for this class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic