struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ruben Carvalho" <Ruben.Carva...@siemens.com>
Subject RE: Need some help
Date Thu, 18 Sep 2003 14:40:37 GMT
Dear Natalie,
 
1000000000 thank yous for your help. The problem was I wasn't calling the super.validate()
method. You don't really need to set the page attribute inside your validate method. Your
validate method has to look like this:
 
public ActionErrors validate(ActionMapping mapping,
                               HttpServletRequest request) {

              return super.validate(mapping,request);
}
 
Now, inside every JSP you want to use with the form, you only have to set the property page:
<html:hidden property="page" value="0"> 
<html:hidden property="page" value="1"> 
<html:hidden property="page" value="2">
 
depending on witch JSP you are, 1st, 2nd or 3rd. Of course you can do it inside an Action
too.
 
As soon as I saw your validate method I slapped my front and said 3 bad words :)
 
Many thanks again for your help.
 
Ruben Carvalho

	-----Mensagem original----- 
	De: Natalie D Rassmann [mailto:natalie.d.rassmann@lmco.com] 
	Enviada: qui 18-09-2003 14:26 
	Para: Struts Users Mailing List 
	Cc: 
	Assunto: Re: Need some help
	
	

	Ruben,
	
	After many trials, I finally got the page attribute to work.  This is what I did.
	
	I am using a DynaValidatorForm so I created my own Form class and extended DynaValidatorForm.
 I only have one method in
	there; the validator method.
	
	Here is a copy of my source code....
	
	public class ReviewRecordForm extends DynaValidatorForm {
	
	  public ActionErrors validate(ActionMapping mapping,
	                               HttpServletRequest request) {
	
	    String screen = request.getParameter("page");
	
	    //set page property in form
	    this.setPage(Integer.parseInt(request.getParameter("page")));
	
	    //Call the Validator Framework
	    ActionErrors errors = super.validate(mapping,request);
	
	    return errors;
	
	  }
	}
	
	In my validation.xml file, I added the page="X" attribute to the field property line.  (Where
"X" is the page number).  Here
	is a sample from my validation.xml file:
	
	       <field property="phaseSelected" depends="required,isNotSelectOption" page="0">
	          <arg0 key="label.revRec.phase"/>
	       </field>
	
	       <field property="dispositionSelected" depends="required,isNotSelectOption" page="3">
	          <arg0 key="label.revRec.disposition"/>
	       </field>
	
	I wrote the isNotSelectOption validation rule.
	
	I hope this helps....
	
	Natalie
	
	Ruben Carvalho wrote:
	
	> Did anyone work with Struts validation and the page attribute in the field tag? To validate
different parts of the form?
	>
	> I'm really "stucked in a moment and I can't get out of it".
	>
	> Thank you,
	>
	> Rúben Carvalho
	
	

Mime
View raw message