This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have created a simple CRUD java program using Hibernate
However I need to implement form validation one of the content entry boxes to prevent null values.
Can anyone suggest the simplest way this could be achieved?
I have posted my action.class below
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Joined: Mar 31, 2012
ive tried this method however because my action class is using data entered from my customer model i get the following error which im not sure there is any solution
Cannot make a static reference to the non-static method getName() from the type Customer
If the parameter is on the form that the user is submitting, then if they leave it blank the value should be an empty string, "", not null.
But anyway, just wanted to recommend that, if you are going to validate the parameter manually (instead of using the validation framwork), then I suggest using the Commons StringUtils. This class should be on your classpath already in one of the Commons libraries needed for Struts2.
So, instead of hecking the length of the string, checking for null, etc., you can just do:
Joined: Mar 31, 2012
Thanks for your help but I changed my vaildation method to use struts2 .xml form validation instead
It works! but i'm still unable to get the UI error message to showup on my .jsp page - can you help?
Your right those are good links & i tried adding the key variables and comprehending properties file but still not seeing any UI messages.
I think we are going down the wrong avenue here because the xml validation is working; so the correct fields are being identified its only the messages that are not being shown.
It makes me think the problem is on the .jsp view not holding the required error field