Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dynamic FormBean Population

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
userFormBean.???
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,
Vijay
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Asked and answered in the JSP forum
 
    Bookmark Topic Watch Topic
  • New Topic