You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ju...@atosodsorigin.com on 2002/09/09 13:05:41 UTC

Problem with DynaValidatorForm y Page

Hello all, I'm trying to use a DynaValidatorForm with multiples pages,
but I do not get the "page" value to change. And the validation never happens.
Any one can tell me what's wrong or say me where can I find an example.

Thanks 

*.jsp
<html:form action='/pruDynamic.do'>
<html:hidden property="page" value="2"/>
</html:form>


In the action 

Integer page =(Integer)PropertyUtils.getSimpleProperty( form,"page");  --> 2
System.out.println("Page: "+((DynaValidatorForm)form).getPage()); --> 0


struts-config
  <form-beans>
    <form-bean name="pruDynamicForm" dynamic="true" type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="page" type="java.lang.Integer" initial="1" /></form-bean>
    <form-property name="name" type="java.lang.String" /></form-bean>
  </form-beans>


validation.xml
   <formset>
         <form    name="pruDynamicForm">
         <field    property="name" depends="required" page="1"> // never happens
         	     <arg0 key="pruForm.name"/>
         </field>
        </form>
   </formset>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Just one question. Does page works with DynaValidatorForm?

Posted by Ju...@atosodsorigin.com.
I've done this and know it works with DynaValidatorForm, just taking the page value
from the DynaForm and Setting it.

This is the only solution I have found.


public class MiDynaValidatorForm extends DynaValidatorForm {

    private static Log milog = LogFactory.getLog(MiDynaValidatorForm.class);

    public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {

        ServletContext application = getServlet().getServletContext();
        ActionErrors errors = new ActionErrors();


        try{
      	  Integer dinaPage =(Integer)PropertyUtils.getSimpleProperty( this,"page");
              if(dinaPage!=null) setPage(dinaPage.intValue()); <---------------------------------------------------setPage
        }catch(Exception e){
          if(!(e instanceof java.lang.NoSuchMethodException))
            milog.error(e.getMessage(),e);
        }


    Validator validator = StrutsValidatorUtil.initValidator(mapping.getAttribute(),
                                                            this,
                                                            application, request,
                                                            errors, page);

    try {
       validatorResults = validator.validate();
        } catch (ValidatorException e) {
       milog.error(e.getMessage(), e);
    }

        return errors;
    }

}



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Just one question. Does page works with DynaValidatorForm?

Posted by Eddie Bush <ek...@swbell.net>.
Have you:

* Looked at the struts-validator.war application?
* Read Chuck's book (he's got a whole chapter on the validator!) on 
theserverside.com?  (search for struts book review)

Those are the first two places I would hit.

Regards,

Eddie

JuanPedro.DeAndres@atosodsorigin.com wrote:

>If anyone have an example, that should make me happy .
>
>Thanks.
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Just one question. Does page works with DynaValidatorForm?

Posted by Ju...@atosodsorigin.com.
If anyone have an example, that should make me happy .

Thanks.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>