You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rajat Pandit <ra...@centergroupinc.com> on 2003/11/04 07:09:36 UTC

validation not working

hello all,
i have a form, which inputs a number of units. the problem is that in 
case of a validation error. the page does not return back to the form. 
and just stops.
the following are the extract of my validation method and 
struts-config.xml file.

if anyone could point out somethng i am missing. i am now closing to 
banging my head on the desk now!!.

<!-- struts file -->

         <action path="/updateProduct"
                 type="com.hedging.admin.productmanagement.updateProduct"
                 name="addStateForm"
                 validate="true"
                 scope="request"
                 input="/pages/layouts/updateProductForm.jsp">
             <set-property property="loginRequired" value="true" />
             <forward name="showForm" 
path="/pages/layouts/updateProductForm.jsp" />
         </action>
<!-- struts file -->


<!--validation method -->
    public ActionErrors validate (ActionMapping mapping,
                                  HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
         if ((this.getNoOfStates() < 0) || (this.getNoOfStates() > 100))
            System.err.println("---> Error occured!!!");
            errors.add("noOfStates",
                        new ActionError("errors.toManyStates"));
        }
        return errors;
    }

<!-- end of validation method -->

-- 


Rajat Pandit | rajatp@centergroupinc.com
+91 612 3117606
[ Developer and Part Time Human Being]



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: validation not working

Posted by Rajat Pandit <ra...@centergroupinc.com>.
hello dirk,
thanks a lot man!, i couldnt though follow ur advice, sinci i also had 
to pass argument to the action. which is not possible in the <input... tag.
but i got the idea, it was becoz of the bean which iwas in the request 
scope. i fixed it by saving it in the session scope.
now just got one more question. i somehow feel very guilty when is save 
objects in the session scope. is there someone i can ensure that they 
are effectively removed from the scope by the container itself. but any 
programatic tips u might want to add?
thanks anyways man!!
rajatp

Dirk Markert wrote:
> Hello Rajat,
> 
>   
> 
> ***************************************************************
> 
> 
> 
> RP> Dirk Markert wrote:
> 
> 
>>>Hello,
>>>
>>>  
>>>
>>>***************************************************************
>>>
>>>RP> hello all,
>>>RP> i have a form, which inputs a number of units. the problem is that in 
>>>RP> case of a validation error. the page does not return back to the form.
>>>You want to return to updateProductForm.jsp? Does this jsp depend on
>>>beans stored in request scope?
> 
> 
> RP> yes itdoes depend on a bean stored in the request scope.
> Then in you have to use an action as the input attribute of your
> action mapping, ie not input="/pages/layouts/updateProductForm.jsp"
> but something like input="/prepareUpdateForm.do". In this action prepare your
> request and forward to your jsp.
> RP> the actual 
> RP> problem thati forsee is that that it is possible the validation and 
> RP> calling the executing the Action.execute() despite the fact that there 
> RP> where error in the ActionForm.
> 
> 
> 
>>>RP> and just stops.
>>>What do you mean by "just stops"?
> 
> RP> calls nothing because the in case of an invalid input there is no 
> RP> corresponding action in the Action.execute() and also its not supposed 
> RP> to be the case as the ActionForm acts like a firewall and wouldnt let it 
> RP> pass to the Action unless the ActionForm.validate() returns a null. 
> RP> :(((((((((((((((( (i guess u can see how sad i am)
> 
> 
>>>RP> the following are the extract of my validation method and 
>>>RP> struts-config.xml file.
>>>
>>>RP> if anyone could point out somethng i am missing. i am now closing to 
>>>RP> banging my head on the desk now!!.
>>>
>>>RP> <!-- struts file -->
>>>
>>>RP>          <action path="/updateProduct"
>>>RP>                  type="com.hedging.admin.productmanagement.updateProduct"
>>>RP>                  name="addStateForm"
>>>RP>                  validate="true"
>>>RP>                  scope="request"
>>>RP>                  input="/pages/layouts/updateProductForm.jsp">
>>>RP>              <set-property property="loginRequired" value="true" />
>>>RP>              <forward name="showForm" 
>>>RP> path="/pages/layouts/updateProductForm.jsp" />
>>>RP>          </action>
>>>RP> <!-- struts file -->
>>>
>>>
>>>RP> <!--validation method -->
>>>RP>     public ActionErrors validate (ActionMapping mapping,
>>>RP>                                   HttpServletRequest request) {
>>>RP>         ActionErrors errors = new ActionErrors();
>>>RP>          if ((this.getNoOfStates() < 0) || (this.getNoOfStates() > 100))
>>>RP>             System.err.println("---> Error occured!!!");
>>>RP>             errors.add("noOfStates",
>>>RP>                         new ActionError("errors.toManyStates"));
>>>RP>         }
>>>RP>         return errors;
>>>RP>     }
>>>
>>>RP> <!-- end of validation method -->
>>>
>>>
>>>
>>>
>>>Regards,
>>>Dirk
>>>
>>>+------- Quality leads ---------------------------------------+
>>>| Dirk Markert                     dirk.markert@dr-markert.de |
>>>| Dr. Markert Softwaretechnik AG                              |
>>>| Joseph-von-Fraunhofer-Str. 20                               |
>>>| 44227 Dortmund                                              |
>>>+---------------------------------->>>>>>> to success! <<<<<<-+ 
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
> 
> 
> 
> 
> 
> Regards,
> Dirk
> 
> +------- Quality leads ---------------------------------------+
> | Dirk Markert                     dirk.markert@dr-markert.de |
> | Dr. Markert Softwaretechnik AG                              |
> | Joseph-von-Fraunhofer-Str. 20                               |
> | 44227 Dortmund                                              |
> +---------------------------------->>>>>>> to success! <<<<<<-+ 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

-- 


Rajat Pandit | rajatp@centergroupinc.com
+91 612 3117606
[ Developer and Part Time Human Being]



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re[2]: validation not working

Posted by Dirk Markert <di...@dr-markert.de>.
Hello Rajat,

  

***************************************************************



RP> Dirk Markert wrote:

>> Hello,
>> 
>>   
>> 
>> ***************************************************************
>> 
>> RP> hello all,
>> RP> i have a form, which inputs a number of units. the problem is that in 
>> RP> case of a validation error. the page does not return back to the form.
>> You want to return to updateProductForm.jsp? Does this jsp depend on
>> beans stored in request scope?

RP> yes itdoes depend on a bean stored in the request scope.
Then in you have to use an action as the input attribute of your
action mapping, ie not input="/pages/layouts/updateProductForm.jsp"
but something like input="/prepareUpdateForm.do". In this action prepare your
request and forward to your jsp.
RP> the actual 
RP> problem thati forsee is that that it is possible the validation and 
RP> calling the executing the Action.execute() despite the fact that there 
RP> where error in the ActionForm.


>> RP> and just stops.
>> What do you mean by "just stops"?
RP> calls nothing because the in case of an invalid input there is no 
RP> corresponding action in the Action.execute() and also its not supposed 
RP> to be the case as the ActionForm acts like a firewall and wouldnt let it 
RP> pass to the Action unless the ActionForm.validate() returns a null. 
RP> :(((((((((((((((( (i guess u can see how sad i am)

>> 
>> RP> the following are the extract of my validation method and 
>> RP> struts-config.xml file.
>> 
>> RP> if anyone could point out somethng i am missing. i am now closing to 
>> RP> banging my head on the desk now!!.
>> 
>> RP> <!-- struts file -->
>> 
>> RP>          <action path="/updateProduct"
>> RP>                  type="com.hedging.admin.productmanagement.updateProduct"
>> RP>                  name="addStateForm"
>> RP>                  validate="true"
>> RP>                  scope="request"
>> RP>                  input="/pages/layouts/updateProductForm.jsp">
>> RP>              <set-property property="loginRequired" value="true" />
>> RP>              <forward name="showForm" 
>> RP> path="/pages/layouts/updateProductForm.jsp" />
>> RP>          </action>
>> RP> <!-- struts file -->
>> 
>> 
>> RP> <!--validation method -->
>> RP>     public ActionErrors validate (ActionMapping mapping,
>> RP>                                   HttpServletRequest request) {
>> RP>         ActionErrors errors = new ActionErrors();
>> RP>          if ((this.getNoOfStates() < 0) || (this.getNoOfStates() > 100))
>> RP>             System.err.println("---> Error occured!!!");
>> RP>             errors.add("noOfStates",
>> RP>                         new ActionError("errors.toManyStates"));
>> RP>         }
>> RP>         return errors;
>> RP>     }
>> 
>> RP> <!-- end of validation method -->
>> 
>> 
>> 
>> 
>> Regards,
>> Dirk
>> 
>> +------- Quality leads ---------------------------------------+
>> | Dirk Markert                     dirk.markert@dr-markert.de |
>> | Dr. Markert Softwaretechnik AG                              |
>> | Joseph-von-Fraunhofer-Str. 20                               |
>> | 44227 Dortmund                                              |
>> +---------------------------------->>>>>>> to success! <<<<<<-+ 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>> 




Regards,
Dirk

+------- Quality leads ---------------------------------------+
| Dirk Markert                     dirk.markert@dr-markert.de |
| Dr. Markert Softwaretechnik AG                              |
| Joseph-von-Fraunhofer-Str. 20                               |
| 44227 Dortmund                                              |
+---------------------------------->>>>>>> to success! <<<<<<-+ 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: validation not working

Posted by Rajat Pandit <ra...@centergroupinc.com>.

Dirk Markert wrote:

> Hello,
> 
>   
> 
> ***************************************************************
> 
> RP> hello all,
> RP> i have a form, which inputs a number of units. the problem is that in 
> RP> case of a validation error. the page does not return back to the form.
> You want to return to updateProductForm.jsp? Does this jsp depend on
> beans stored in request scope?

yes itdoes depend on a bean stored in the request scope. the actual 
problem thati forsee is that that it is possible the validation and 
calling the executing the Action.execute() despite the fact that there 
where error in the ActionForm.


> RP> and just stops.
> What do you mean by "just stops"?
calls nothing because the in case of an invalid input there is no 
corresponding action in the Action.execute() and also its not supposed 
to be the case as the ActionForm acts like a firewall and wouldnt let it 
pass to the Action unless the ActionForm.validate() returns a null. 
:(((((((((((((((( (i guess u can see how sad i am)

> 
> RP> the following are the extract of my validation method and 
> RP> struts-config.xml file.
> 
> RP> if anyone could point out somethng i am missing. i am now closing to 
> RP> banging my head on the desk now!!.
> 
> RP> <!-- struts file -->
> 
> RP>          <action path="/updateProduct"
> RP>                  type="com.hedging.admin.productmanagement.updateProduct"
> RP>                  name="addStateForm"
> RP>                  validate="true"
> RP>                  scope="request"
> RP>                  input="/pages/layouts/updateProductForm.jsp">
> RP>              <set-property property="loginRequired" value="true" />
> RP>              <forward name="showForm" 
> RP> path="/pages/layouts/updateProductForm.jsp" />
> RP>          </action>
> RP> <!-- struts file -->
> 
> 
> RP> <!--validation method -->
> RP>     public ActionErrors validate (ActionMapping mapping,
> RP>                                   HttpServletRequest request) {
> RP>         ActionErrors errors = new ActionErrors();
> RP>          if ((this.getNoOfStates() < 0) || (this.getNoOfStates() > 100))
> RP>             System.err.println("---> Error occured!!!");
> RP>             errors.add("noOfStates",
> RP>                         new ActionError("errors.toManyStates"));
> RP>         }
> RP>         return errors;
> RP>     }
> 
> RP> <!-- end of validation method -->
> 
> 
> 
> 
> Regards,
> Dirk
> 
> +------- Quality leads ---------------------------------------+
> | Dirk Markert                     dirk.markert@dr-markert.de |
> | Dr. Markert Softwaretechnik AG                              |
> | Joseph-von-Fraunhofer-Str. 20                               |
> | 44227 Dortmund                                              |
> +---------------------------------->>>>>>> to success! <<<<<<-+ 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

-- 


Rajat Pandit | rajatp@centergroupinc.com
+91 612 3117606
[ Developer and Part Time Human Being]



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: validation not working

Posted by Dirk Markert <di...@dr-markert.de>.
Hello,

  

***************************************************************

RP> hello all,
RP> i have a form, which inputs a number of units. the problem is that in 
RP> case of a validation error. the page does not return back to the form.
You want to return to updateProductForm.jsp? Does this jsp depend on
beans stored in request scope?
RP> and just stops.
What do you mean by "just stops"?

RP> the following are the extract of my validation method and 
RP> struts-config.xml file.

RP> if anyone could point out somethng i am missing. i am now closing to 
RP> banging my head on the desk now!!.

RP> <!-- struts file -->

RP>          <action path="/updateProduct"
RP>                  type="com.hedging.admin.productmanagement.updateProduct"
RP>                  name="addStateForm"
RP>                  validate="true"
RP>                  scope="request"
RP>                  input="/pages/layouts/updateProductForm.jsp">
RP>              <set-property property="loginRequired" value="true" />
RP>              <forward name="showForm" 
RP> path="/pages/layouts/updateProductForm.jsp" />
RP>          </action>
RP> <!-- struts file -->


RP> <!--validation method -->
RP>     public ActionErrors validate (ActionMapping mapping,
RP>                                   HttpServletRequest request) {
RP>         ActionErrors errors = new ActionErrors();
RP>          if ((this.getNoOfStates() < 0) || (this.getNoOfStates() > 100))
RP>             System.err.println("---> Error occured!!!");
RP>             errors.add("noOfStates",
RP>                         new ActionError("errors.toManyStates"));
RP>         }
RP>         return errors;
RP>     }

RP> <!-- end of validation method -->




Regards,
Dirk

+------- Quality leads ---------------------------------------+
| Dirk Markert                     dirk.markert@dr-markert.de |
| Dr. Markert Softwaretechnik AG                              |
| Joseph-von-Fraunhofer-Str. 20                               |
| 44227 Dortmund                                              |
+---------------------------------->>>>>>> to success! <<<<<<-+ 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org