I am using Struts validation by extending action to ActionSupport.
When I try to put special character on the UI, then default actionErrors are adding up in the collections like Illegal characters were detected in the input, please remove them and try again.
Then I need to remove that default validation coming up on UI. I have no idea to deal with it.
My code is like this:
void validate(){
if (locationBean.getReasonTypeId() == 0)
{
addActionError("Error in reason");
}
if (ValidationHelper.checkRequiredField(locationBean.getName()))
{
addActionError("Error in Location name");
}
}
My validation action class is like this:
public class ValidationErrorJSONAction extends ActionSupport
{
private JSONObject jsonObject;
@SuppressWarnings("unchecked")
public String execute() throws Exception
{
jsonObject = new JSONObject();
jsonObject.put("actionErrors", new JSONArray(getActionErrors()));
jsonObject.put("fieldErrors",new JSONObject(getFieldErrors()));
TokenHelperJSON.appendToken(jsonObject);
return SUCCESS;
}
Hope it will help you to understand the problem.