You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vaneet Sharma <va...@crisil.com> on 2006/08/24 13:08:45 UTC

Validation in Struts DisptachAction

Hii

I am using Struts  DispatchAction and i am facing  a peculiar problem 
while validating .
Now i want to validate ,my action form only in insert or update mode.
For read mode i want to prevent validation.
To achive this is am writing validation="false" in the action mapping , 
and i am manually calling validation in insert and update methods of my 
action class.


         DynaActionForm frm=(DynaActionForm)form;
          ActionErrors  errors=frm.validate(mapping,request);
         if ( errors != null && !errors.isEmpty() ) {
                           saveErrors(request, errors);
                  return (mapping.findForward("validationfailure"));
                }
        ........

But when i am doing validation in this way.
It is always trying to validate the action , even in read mode also.
Can anybody tell me why is this happening.

Thanx in advance


Disclaimer : 
This message and any attachments (hereinafter referred to as the Said Information) are  intended solely for the addressee. The Said Information is confidential and may be privileged and is also prohibited from disclosure. Access, use, copying, distribution or e-use of the Said Information by anyone except the addressee is unauthorized. If you are not the intended addressee, please destroy all copies of  the Said Information in your possession and also delete the same from your computer. Any views expressed in the Said Information are those of the individual sender except where the sender, with due authority of CRISIL Ltd./CRISIL MarketWire Ltd./Global Data Services of India Ltd. specifically states them to be the views of CRISIL Ltd./CRISIL MarketWire Ltd./Global Data Services of India Ltd. Nothing contained in the Said Information is capable or intended to create any legally binding obligations on the sender  CRISIL Ltd./CRISIL MarketWire Ltd./Global Data Services of India L
 td. who accept no responsibility, whatsoever, for loss or damage from the use of  the Said Information including damage from viruses.

RE: Validation in Struts DisptachAction

Posted by "Sherwood, Reg" <Re...@aliant.ca>.
Hi Vaneet
 
I'm no expert on this to be sure; but I ran into a similiar issue.  What I did was provided the check for the Read only mode in the forms validate method; if read only mode the validate method returned null; otherwise it invoked the super.validate method which performs the normal validation checks on the form.
 
Hope this helps.
 
Reg

________________________________

From: Vaneet Sharma [mailto:vasharma@crisil.com]
Sent: Thu 24/08/2006 8:08 AM
To: struts-user@jakarta.apache.org
Subject: Validation in Struts DisptachAction



Hii

I am using Struts  DispatchAction and i am facing  a peculiar problem
while validating .
Now i want to validate ,my action form only in insert or update mode.
For read mode i want to prevent validation.
To achive this is am writing validation="false" in the action mapping ,
and i am manually calling validation in insert and update methods of my
action class.


         DynaActionForm frm=(DynaActionForm)form;
          ActionErrors  errors=frm.validate(mapping,request);
         if ( errors != null && !errors.isEmpty() ) {
                           saveErrors(request, errors);
                  return (mapping.findForward("validationfailure"));
                }
        ........

But when i am doing validation in this way.
It is always trying to validate the action , even in read mode also.
Can anybody tell me why is this happening.

Thanx in advance


Disclaimer :
This message and any attachments (hereinafter referred to as the Said Information) are  intended solely for the addressee. The Said Information is confidential and may be privileged and is also prohibited from disclosure. Access, use, copying, distribution or e-use of the Said Information by anyone except the addressee is unauthorized. If you are not the intended addressee, please destroy all copies of  the Said Information in your possession and also delete the same from your computer. Any views expressed in the Said Information are those of the individual sender except where the sender, with due authority of CRISIL Ltd./CRISIL MarketWire Ltd./Global Data Services of India Ltd. specifically states them to be the views of CRISIL Ltd./CRISIL MarketWire Ltd./Global Data Services of India Ltd. Nothing contained in the Said Information is capable or intended to create any legally binding obligations on the sender  CRISIL Ltd./CRISIL MarketWire Ltd./Global Data Services of India L
 td. who accept no responsibility, whatsoever, for loss or damage from the use of  the Said Information including damage from viruses.




RE: Validation in Struts DisptachAction

Posted by "Saeed, Rada" <ra...@eds.com>.
Sharma,
     If insert, update and read modes, are represented by 3 different
submits that trigger the actions,
make them 3 different action mappings, then put validate="false" in the
read action mapping, and true in the rest.


<action path="/readAction" name="yourForm" validate="false"
scope="session" input="viewDefinition" 
	type="com.gme.urAction" parameter="read">
<forward name="definitionPage" path="formatDefinition"></forward>
</action>

<action path="/insertAction" name="yourForm" validate="true"
scope="session" input="viewDefinition" 
	type="com.gme.urAction" parameter="insert">
<forward name="definitionPage" path="formatDefinition"></forward>
</action>

<action path="/updateAction" name="yourForm" validate="true"
scope="session" input="viewDefinition" 
	type="com.gme.urAction" parameter="update">
<forward name="definitionPage" path="formatDefinition"></forward>
</action>
  	
  	
-----Original Message-----
From: Vaneet Sharma [mailto:vasharma@crisil.com] 
Sent: Thursday, August 24, 2006 2:09 PM
To: struts-user@jakarta.apache.org
Subject: Validation in Struts DisptachAction

Hii

I am using Struts  DispatchAction and i am facing  a peculiar problem
while validating .
Now i want to validate ,my action form only in insert or update mode.
For read mode i want to prevent validation.
To achive this is am writing validation="false" in the action mapping ,
and i am manually calling validation in insert and update methods of my
action class.


         DynaActionForm frm=(DynaActionForm)form;
          ActionErrors  errors=frm.validate(mapping,request);
         if ( errors != null && !errors.isEmpty() ) {
                           saveErrors(request, errors);
                  return (mapping.findForward("validationfailure"));
                }
        ........

But when i am doing validation in this way.
It is always trying to validate the action , even in read mode also.
Can anybody tell me why is this happening.

Thanx in advance


Disclaimer : 
This message and any attachments (hereinafter referred to as the Said
Information) are  intended solely for the addressee. The Said
Information is confidential and may be privileged and is also prohibited
from disclosure. Access, use, copying, distribution or e-use of the Said
Information by anyone except the addressee is unauthorized. If you are
not the intended addressee, please destroy all copies of  the Said
Information in your possession and also delete the same from your
computer. Any views expressed in the Said Information are those of the
individual sender except where the sender, with due authority of CRISIL
Ltd./CRISIL MarketWire Ltd./Global Data Services of India Ltd.
specifically states them to be the views of CRISIL Ltd./CRISIL
MarketWire Ltd./Global Data Services of India Ltd. Nothing contained in
the Said Information is capable or intended to create any legally
binding obligations on the sender  CRISIL Ltd./CRISIL MarketWire
Ltd./Global Data Services of India L  td. who accept no responsibility,
whatsoever, for loss or damage from the use of  the Said Information
including damage from viruses.

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