You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alvaro Martinez <in...@wanadoo.es> on 2003/12/05 16:56:11 UTC

Re: repost: validator & retrieving data

I don't know if the proposal of Anant works. I know my proposal works well.
You must use the same bean in the page "proccess" and the page "prepare".
For e.g.
  <action path="/prepare"
    type="xxxx"
    name="bean"
    scope="request">
   <forward name="success" path="Process.jsp"/>
  </action>
  <action path="/process"
    type="xxxx"
    name="bean"
    scope="request"
    input="/prepare.jsp"
    validate="true">
   <forward name="success" path="Main.jsp"/>
  </action>

Alvaro Martinez

----- Original Message ----- 
From: <an...@wipro.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, February 05, 2004 3:52 PM
Subject: RE: repost: validator & retrieving data



Sorry there was a typo in last one

Hi,

You don't need to have two actions but you can have different mappings
for the same action class

For e.g.
<action name="formbean" path="abcdisplay" type="AbcAction.java" >
<forward name="success" path="jsp name" />
</action>
<action name="formbean"  path="abcProcess" type="AbcAction.java"
validate="true" input="abcErrorShow">
<forward name="success" path="results jsp" />
</action>
<action name="formbean" path="abcErrorShow" type="AbcAction.java">
<forward name="success" path="jsp name" />
</action>


Now in the action class use

If(mapping.getPath().equals(abcdisplay)){
Get data from backend
}
Else if(mapping.getPath().equals(abcProcess)){
Process data from backend
}
Else if(mapping.getPath().equals(abcErrorShow)){
Populate data from form bean itself
}


Regards

Anant

-----Original Message-----
From: Leonardo Francalanci [mailto:lfrancalanci@simtel.ie]
Sent: Thursday, February 05, 2004 5:44 PM
To: struts-user@jakarta.apache.org
Subject: repost: validator & retrieving data


I'm sorry but nobody answered my question...
Could somebody help me?


I'm using validator for my pages. Searching the mailing list I found
that I should use 2 actions:

"If there are 2 actions, one to "prepare" the page and one to "process"
the user input, we define the input attribute value of the "process"
action mapping to be the URL of the "prepare" action."

I think it's right, but now I have this problem:
The "prepare" page retrieves data from the db. If validation fails, the
user is forwarded from the "process" action to the "prepare" action. In
this case I don't want to retrieve data from the db, but leave what
the user entered before. In other words I want to retrieve data only if
the user asked for the "prepare" action, not when he is redirected to
the "prepare" action from the input property of "process" action.

Is there a way to do that?

The only way i found is an hidden field, but I don't like it...



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



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


Confidentiality Notice

The information contained in this electronic message and any attachments to
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.

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


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


Re: R: repost: validator & retrieving data

Posted by Hubert Rabago <ja...@yahoo.com>.
The values that you read from the DB need to come from somewhere.
Perhaps you can store them in a session attribute (then clear it once the
form passes validation).  Oh, yeah, an action has to prepare them, so maybe
you can use the same action, except that before it reads from the DB, it
checks if the values are already available from session attributes.

- Hubert 

--- Leonardo Francalanci <lf...@simtel.ie> wrote:
> I don't think I made myself clear.
> 
> I can't set the input of the "process" action to the jsp of the prepare
> action because in the prepare action I get data from the db to
> fill a listbox.
> 
> If I used your solution in case of a validation error my list box
> would not be filled.
> 
> But if I set the input to the "prepare" action the values the user entered
> would be resetted to the values in the db.
> 
> That's way I need to know, in the prepare action, if I'm coming
> from a validation error or a simple "GET".
> Did I make myself clearer?
> 
> Thank you
> 
> > -----Messaggio originale-----
> > Da: Alvaro Martinez [mailto:inforalv@wanadoo.es]
> > Inviato: venerd� 5 dicembre 2003 16.56
> > A: Struts Users Mailing List
> > Oggetto: Re: repost: validator & retrieving data
> >
> >
> > I don't know if the proposal of Anant works. I know my proposal
> > works well.
> > You must use the same bean in the page "proccess" and the page "prepare".
> > For e.g.
> >   <action path="/prepare"
> >     type="xxxx"
> >     name="bean"
> >     scope="request">
> >    <forward name="success" path="Process.jsp"/>
> >   </action>
> >   <action path="/process"
> >     type="xxxx"
> >     name="bean"
> >     scope="request"
> >     input="/prepare.jsp"
> >     validate="true">
> >    <forward name="success" path="Main.jsp"/>
> >   </action>
> >
> > Alvaro Martinez
> >
> > ----- Original Message -----
> > From: <an...@wipro.com>
> > To: <st...@jakarta.apache.org>
> > Sent: Thursday, February 05, 2004 3:52 PM
> > Subject: RE: repost: validator & retrieving data
> >
> >
> >
> > Sorry there was a typo in last one
> >
> > Hi,
> >
> > You don't need to have two actions but you can have different mappings
> > for the same action class
> >
> > For e.g.
> > <action name="formbean" path="abcdisplay" type="AbcAction.java" >
> > <forward name="success" path="jsp name" />
> > </action>
> > <action name="formbean"  path="abcProcess" type="AbcAction.java"
> > validate="true" input="abcErrorShow">
> > <forward name="success" path="results jsp" />
> > </action>
> > <action name="formbean" path="abcErrorShow" type="AbcAction.java">
> > <forward name="success" path="jsp name" />
> > </action>
> >
> >
> > Now in the action class use
> >
> > If(mapping.getPath().equals(abcdisplay)){
> > Get data from backend
> > }
> > Else if(mapping.getPath().equals(abcProcess)){
> > Process data from backend
> > }
> > Else if(mapping.getPath().equals(abcErrorShow)){
> > Populate data from form bean itself
> > }
> >
> >
> > Regards
> >
> > Anant
> >
> > -----Original Message-----
> > From: Leonardo Francalanci [mailto:lfrancalanci@simtel.ie]
> > Sent: Thursday, February 05, 2004 5:44 PM
> > To: struts-user@jakarta.apache.org
> > Subject: repost: validator & retrieving data
> >
> >
> > I'm sorry but nobody answered my question...
> > Could somebody help me?
> >
> >
> > I'm using validator for my pages. Searching the mailing list I found
> > that I should use 2 actions:
> >
> > "If there are 2 actions, one to "prepare" the page and one to "process"
> > the user input, we define the input attribute value of the "process"
> > action mapping to be the URL of the "prepare" action."
> >
> > I think it's right, but now I have this problem:
> > The "prepare" page retrieves data from the db. If validation fails, the
> > user is forwarded from the "process" action to the "prepare" action. In
> > this case I don't want to retrieve data from the db, but leave what
> > the user entered before. In other words I want to retrieve data only if
> > the user asked for the "prepare" action, not when he is redirected to
> > the "prepare" action from the input property of "process" action.
> >
> > Is there a way to do that?
> >
> > The only way i found is an hidden field, but I don't like it...
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> > Confidentiality Notice
> >
> > The information contained in this electronic message and any
> > attachments to
> > this message are intended
> > for the exclusive use of the addressee(s) and may contain confidential or
> > privileged information. If
> > you are not the intended recipient, please notify the sender at Wipro or
> > Mailadmin@wipro.com immediately
> > and destroy all copies of this message and any attachments.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

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


R: repost: validator & retrieving data

Posted by Leonardo Francalanci <lf...@simtel.ie>.
I don't think I made myself clear.

I can't set the input of the "process" action to the jsp of the prepare
action because in the prepare action I get data from the db to
fill a listbox.

If I used your solution in case of a validation error my list box
would not be filled.

But if I set the input to the "prepare" action the values the user entered
would be resetted to the values in the db.

That's way I need to know, in the prepare action, if I'm coming
from a validation error or a simple "GET".
Did I make myself clearer?

Thank you

> -----Messaggio originale-----
> Da: Alvaro Martinez [mailto:inforalv@wanadoo.es]
> Inviato: venerdì 5 dicembre 2003 16.56
> A: Struts Users Mailing List
> Oggetto: Re: repost: validator & retrieving data
>
>
> I don't know if the proposal of Anant works. I know my proposal
> works well.
> You must use the same bean in the page "proccess" and the page "prepare".
> For e.g.
>   <action path="/prepare"
>     type="xxxx"
>     name="bean"
>     scope="request">
>    <forward name="success" path="Process.jsp"/>
>   </action>
>   <action path="/process"
>     type="xxxx"
>     name="bean"
>     scope="request"
>     input="/prepare.jsp"
>     validate="true">
>    <forward name="success" path="Main.jsp"/>
>   </action>
>
> Alvaro Martinez
>
> ----- Original Message -----
> From: <an...@wipro.com>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, February 05, 2004 3:52 PM
> Subject: RE: repost: validator & retrieving data
>
>
>
> Sorry there was a typo in last one
>
> Hi,
>
> You don't need to have two actions but you can have different mappings
> for the same action class
>
> For e.g.
> <action name="formbean" path="abcdisplay" type="AbcAction.java" >
> <forward name="success" path="jsp name" />
> </action>
> <action name="formbean"  path="abcProcess" type="AbcAction.java"
> validate="true" input="abcErrorShow">
> <forward name="success" path="results jsp" />
> </action>
> <action name="formbean" path="abcErrorShow" type="AbcAction.java">
> <forward name="success" path="jsp name" />
> </action>
>
>
> Now in the action class use
>
> If(mapping.getPath().equals(abcdisplay)){
> Get data from backend
> }
> Else if(mapping.getPath().equals(abcProcess)){
> Process data from backend
> }
> Else if(mapping.getPath().equals(abcErrorShow)){
> Populate data from form bean itself
> }
>
>
> Regards
>
> Anant
>
> -----Original Message-----
> From: Leonardo Francalanci [mailto:lfrancalanci@simtel.ie]
> Sent: Thursday, February 05, 2004 5:44 PM
> To: struts-user@jakarta.apache.org
> Subject: repost: validator & retrieving data
>
>
> I'm sorry but nobody answered my question...
> Could somebody help me?
>
>
> I'm using validator for my pages. Searching the mailing list I found
> that I should use 2 actions:
>
> "If there are 2 actions, one to "prepare" the page and one to "process"
> the user input, we define the input attribute value of the "process"
> action mapping to be the URL of the "prepare" action."
>
> I think it's right, but now I have this problem:
> The "prepare" page retrieves data from the db. If validation fails, the
> user is forwarded from the "process" action to the "prepare" action. In
> this case I don't want to retrieve data from the db, but leave what
> the user entered before. In other words I want to retrieve data only if
> the user asked for the "prepare" action, not when he is redirected to
> the "prepare" action from the input property of "process" action.
>
> Is there a way to do that?
>
> The only way i found is an hidden field, but I don't like it...
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> Confidentiality Notice
>
> The information contained in this electronic message and any
> attachments to
> this message are intended
> for the exclusive use of the addressee(s) and may contain confidential or
> privileged information. If
> you are not the intended recipient, please notify the sender at Wipro or
> Mailadmin@wipro.com immediately
> and destroy all copies of this message and any attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


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