| Author |
String value substitution
|
nachagoni rishi
Greenhorn
Joined: Oct 14, 2004
Posts: 26
|
|
Is there any way i can replace "ticketNumber==null" and "plateNumber==null" with value of errorField, so that my code is shorter. public ActionErrors validate( ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); HttpSession session = request.getSession(); String errorField = (String) session.getAttribute("errorField"); if (errorField.equalsIgnoreCase("ticketNumber")) { if ((ticketNumber == null) || (ticketNumber.trim().length() == 0)) errors.add(errorField,new ActionError("error." + errorField + ".null")); } if (errorField.equalsIgnoreCase("plateNumber")) { if ((plateNumber == null) || (plateNumber.trim().length() == 0)) errors.add(errorField,new ActionError("error." + errorField + ".null")); } return errors; }
|
 |
alan do
Ranch Hand
Joined: Apr 14, 2005
Posts: 354
|
|
|
import the GenericValidator class and use the isBlankOrNull method.
|
-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
|
 |
 |
|
|
subject: String value substitution
|
|
|