Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Another "Validator Plugin" Problem

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any idea why dynavalidatorform or validatorform is not working?
 
Erap Estrada
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
It was the best of times. It was the worst of times. It was a tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic