Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
    Bookmark Topic Watch Topic
  • New Topic

Dynamic FormBean Population  RSS feed

Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
I have 3 classes. I am having a problem trying to pass the 2nd parameter to the validate(,) method in the
Temp class.
Here is the code :
class Parmfields {
String fldName;
boolean reqd;
abstract class Temp extends HttpServlet {
// Formbean stores the form input fields into a JavaBean and is not shown here.
public void checkFields(Parmfields[] parms, Formbean userFormBean) {

for (i=0;i< parms.length;i++) {

//if its a required field,validate the form field

if (parms[i].reqd) {

validate(parms[i].fldName,userFormBean.get + parms[i].fldName + () );//<======

// Here i want to use the diff. get methods of the FormBean as the 2nd parameter
// i.e getProdName(),getProdId() etc where the diff properties are populated
// dynamically.I can't figure out away to do that dynamically.
// I am planning to overload the validate() method for the diff data types for the 2nd
// parameter

}// end if

} //end for

} // end checkFields()
} // end Temp

class ConcreteTemp extends Temp {
init() }
Parmfields[] parmarray = [{ProdName,true},{ProdId,false},{ProdCust,true},...... ]

I have been thinking about using userformBean.getClass().getMethods() and then looping thru the
Method [] to get my String value but i still have the problem of trying to use it with
Also, can anyone point me to where i can see the code for how JSP implements the type conversion for
<jsp:getProperty> converting the properties into string. I could maybe use the idea to avoid
overloading my validate() method for the diff field types.
Thanx in advance,
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Asked and answered in the JSP forum
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!