This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Struts and the fly likes Another Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Another "Validator Plugin" Problem" Watch "Another "Validator Plugin" Problem" New topic
Author

Another "Validator Plugin" Problem

Erap Estrada
Ranch Hand

Joined: Nov 08, 2006
Posts: 92
I am hoping to use validation framework by extending "ValidatorForm" and comment out the "validate" method. But it seems that validation does not work and request goes to "Action" class even with empty field. Here are the snippet of my codes.

* struts-config.xml
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>


* form class
public class LoginForm extends ValidatorForm {

private String email;
private String password;

public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}


* validation.xml
<formset>
<form name="loginForm">
<field property="email" depends="required">
<arg key="no.email" resource="true"/>
</field>
<field property="password" depends="required">
<arg key="no.password" resource="true"/>
</field>
</form>
</formset>


PLEASE HELP!

[ April 19, 2007: Message edited by: Erap Estrada ]
[ April 19, 2007: Message edited by: Erap Estrada ]

SCJP with 98% by...
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
Is something like this in your struts-config.xml?



It is case sensitive as well.

Also, have you validated your validation.xml file and are you getting any exceptions when you start the app?
Erap Estrada
Ranch Hand

Joined: Nov 08, 2006
Posts: 92
Yes and here's my action mapping
<action-mappings>
<action path="/login"
scope="request"
name="loginForm"
input="/jsp/index.jsp"
validate="true"
type="com.whatever.LoginAction">
<forward name="success" path="/jsp/myTickets.jsp"/>
<forward name="failure" path="/jsp/index.jsp"/>
</action>
<action path="/addNewTicket" scope="session" forward="/jsp/newTicketForm.jsp"/>
</action-mappings>


Anything that i have missed? I have read 3 Struts books and read it again and again but the configuration is so simple to do, but for unknown reason, i can't make it run. I just want to use the basic validation through XML.

There were no errors on startup.

Thanks in advance Javaranch People.
[ April 20, 2007: Message edited by: Erap Estrada ]
Erap Estrada
Ranch Hand

Joined: Nov 08, 2006
Posts: 92
any idea why dynavalidatorform or validatorform is not working?
Erap Estrada
Ranch Hand

Joined: Nov 08, 2006
Posts: 92
FOUND THE SOLUTION:

This may help newbies of hours if not days of headaches.

The solution to my problem is, defining the actual path of "validator-rules.xml" in <plug-in> declaration in struts-config.xml.

(one reason i dont really like working on xml as it does not tell you the exact problem)

so instead of this:

make the declaration like this:


Now, the weird thing is, why cant the server see the "validator-rules.xml" where it can see the file "validation.xml" in the same folder.
Erap Estrada
Ranch Hand

Joined: Nov 08, 2006
Posts: 92
Another suspicion is, i have a bad "validator-rules.xml" that i downloaded from a certain website. Just to make sure, get the file from the struts core downloaded directly from their site.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Another "Validator Plugin" Problem
 
Similar Threads
STRUTS VALIDATOR FRAMEWORK
Form validation in struts
Cannot load a validator resource
problem in Struts Validation
Problem in struts validator