Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Client-side validation using ValidatorActionForm

 
Cliff Edwards
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

This question refers to Struts 1.2.7.

I'm trying to use the feature of the validator that enables you to specify an action to validate instead of a form. (I'm using a form class that extends ValidatorActionForm.) This form is used by several actions, each in their own way.

The problem is-- actions begin with a slash. So what do you code in the onsubmit parameter in the JSP? The spec says to put "validate" in front of the form/action name, but the action name begins with a slash.

For example, my action is /Login. That would make the onsubmit look like this: onsubmit="return validate/Login(this);". This won't work.

How do you handle this? -- or can you refer me to an article that address this situation?

Thanks!
 
Cliff Edwards
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since posting my question today, I've learned that client-side validation works OK by specifying: onsubmit="return validateUserForm(this);" within the form definition in the calling JSP. I can't find specific documentation about this, but it seems to work.

But I get the following javascript error each time. However, It doesn't seem to affect proper execution; everything seems to work OK.


Error: [Exception... "'Permission denied to get property XULElement.selectedIndex' when calling method: [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame :: http://localhost:9080/xxxxx/login.jsp :: validateRequired :: line 286" data: no]
Source File: http://localhost:9080/xxxxxx/login.jsp
Line: 286

.... Sure would like to see a detailed article describing the use of the Struts validator using multiple actions with a common form.

Cheers,
Robert
 
Cliff Edwards
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To sum up: So, when using the validator to check multiple actions that share a common form bean, you code your form class to extend ValidatorActionForm, and specify actions instead of forms everywhere EXCEPT within the onsubmit Javascript command. Within the onsubmit command, you specify the form name, as it is in the struts-config file.

Cheers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic