Originally posted by Vijay Bala:
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
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Let nothing stop you! Not even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|