• Post Reply 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

Error with validation

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

Ok I just implemented validation using the struts validator and all was going well, the errors were appearing. Until I changed something and then the following:

There was an unknown error performing the operation.

appeared where my error messages should be. It was working before so my question is does any one know of a small change I may have made that caused this?

Thanx for any help you can provide

Nicola
 
Nicola Guy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone help
 
Nicola Guy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I figured out thtat the validator isn't running .

I have a validate method in my assetForm and put in test cases there that run but I declared the following:

ActionErrors errors = super.validate(mapping, request);

at the start of the method, does anyone know why this then wouldn't access the validation.xml???

plz help me

Thanx
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check to see what assetForm is extending. It needs to be ValidatorForm.
 
Nicola Guy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it is any other ideas
 
J Haley
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
post you entire validate() method
 
Nicola Guy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
{
ActionErrors errors = super.validate(mapping, request);
if (errors == null)
errors = new ActionErrors();

/*ActionErrors errors = new ActionErrors();

if (id == null || id.equals(""))
{
errors.add("id", new ActionError("error.idblank"));

}

if (desc == null || desc.equals(""))
{
errors.add("desc", new ActionError("error.descriptionblank"));

}

if (startDate == null || startDate.equals(""))
{
errors.add("startDate", new ActionError("error.startdateblank"));

}*/

if (duration != null && duration.length() > 0)
{
try {
int i = Integer.parseInt(duration);
}
catch (NumberFormatException e){
errors.add("duration", new ActionError("error.durationnotint"));
}
}

if (this.ftv != null && this.ftv.length() > 0)
{
if (ftvGrade == null || ftvGrade.length() == 0)
errors.add("ftvGrade", new ActionError("error.ftvgraderequired"));
}

return errors;
}
}
 
J Haley
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you posted looks good. I've got a couple of thoughts listed below.

o Have you added the validator plugin to struts-config.xml?

o Is validation turned on in struts-config.xml, if not are you calling manually

o If you put a breakpoint or System.out.println in you validate method do you ever hit it.

o create case that will fail validation and display errors right after ActionErrors errors = super.validate(mapping, request) does any thing show up.

o after making changes in struts-config.xml and validation.xml are you restarting your server.

o Is validation.xml built corretly. Does the form name align with assetForm?
 
Nicola Guy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep I've done all that just not sure on this point.

I thought the super.validate started it manually??


o Is validation turned on in struts-config.xml, if not are you calling manually
 
J Haley
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By turned on in struts-config.xml I mean. Is the validate attribute tag set to "true".

<action name="assetForm" validate="true">

The super.validate will only be called if the validate() method that its in is called. This method can be run one of two ways. By setting you struts-config (see above) or you can run it as indicated below. This could occur from you execute() method.

errors = assetForm.validate(mapping, request);

I don't think I have any other ideas beyond this. Good Luck
 
Nicola Guy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The validate method is called because other validation that is held in it is displayed.
reply
    Bookmark Topic Watch Topic
  • New Topic