You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Antonis Lebesis <an...@gmail.com> on 2006/06/20 03:34:01 UTC

Request parameters in action forward

Hello,
  I have a jsp (foo.jsp) that displays information about a certain
foo. I have defined a LoadFooAction, that prepares the foo object and
the SubmitFooAction, that is called when I want to change the
appearance of foo in foo.jsp [suppose that foo is a list of bars and
that I want to change the order of bars (by name, by date etc)].

  In struts-config.xml I have defined the following:
  <action path="/loadFoo" type="LoadFooAction" name="FooForm">
    <forward name="success" path="/foo.jsp"/>
  </action>
  <action path="/submitFoo" type="SubmitFoo" name="FooForm">
    <forward name="reload" path="/loadFoo.do" redirect="true"/>
  </action>

  In order to identify which foo to load, I have added a parameter in
loadFoo, called id, ie
    http://my.foo.site/loadFoo.do&id=23

  The problem is that when I press submit in foo.jsp, the execute
method in SubmitFooAction redirects the browser to
http://my.foo.site/loadFoo.do, loosing the id parameter from the url.
I can store either foo or "id=23" to session and retrieve them from
there when the id parameter is not present, but what happens when the
session expires and the user presses refresh or if the user decides to
bookmark the page? I end up with a loadFoo.do without any information
about which foo to display.

  Has any of you dealt with this problem before? The only thing that I
can think of is to redirect the user to a different (perhaps error)
page when no info is available, but I would really like to be able to
do something better than that.

Thanks in advance,
Antonis

PS. I know it's long, but it's 4:30 in the morning (EEST)...

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


Re: Request parameters in action forward

Posted by Antonis Lebesis <an...@gmail.com>.
Thanks Lance. This the solution I was looking for...

Antonis

On 6/21/06, Lance Semmens <la...@marketpipe.com> wrote:
> You can use an org.apache.struts.action.ActionRedirect
>
> ActionForward forward = mapping.findForward("reload");
> ActionRedirect redirect = new ActionRedirect(forward);
> redirect.addParameter("id", idValue);
> return redirect;
>
>
> Antonis Lebesis wrote:
> > Hi,
> >  I do have a SelectFooAction (actually it's called ChooseFooAction
> > :)). There is another problem though:
> >  This action is used in more than one places so I have to add a
> > parameter called action in it's url (action=display for a simple user,
> > action=edit for the admin etc). Since I have a lot of foo's, I have a
> > form in this page to select which category of Foo's to display. When
> > the user selects  a category, the page is reloaded (through another
> > "reload" mapping) which leads us from selectFoo.do?action=display to
> > selectFoo.do.
> >  Do you see a pattern here ;)?
> >
> > Antonis
> >
> > On 6/21/06, Monkeyden <mo...@gmail.com> wrote:
> >> >The only thing that I
> >> >can think of is to redirect the user to a different (perhaps error)
> >>
> >> exactly, send them back to wherever they go to select the foo they
> >> want to
> >> look at.  Do you have a SelectFooAction?
> >>
> >>
> >> On 6/20/06, Antonis Lebesis <an...@gmail.com> wrote:
> >> >
> >> > Thank you Don.
> >> > I have done that and the session expiry problem is solved. The
> >> > bookmark problem still exists though...
> >> > There is a way to overcome this as well:
> >> >
> >> >   ActionForward forward = new ActionForward();
> >> >   forward.setPath(mapping.findForward("reload").getPath() + "&id=23");
> >> >
> >> > which redirects to http://my.foo.site/loadFoo.do&id=23 , but this is
> >> > a hack I wouldn't like to use (plus I would have to change the code
> >> > for ~60 classes many of which are DispatchActions: a lot of work
> >> > :))...
> >> >
> >> > Antonis
> >> >
> >> >
> >> > On 6/20/06, Don Vawter <do...@vawter.com> wrote:
> >> > > Can you take the request parameter and populate a hidden form field
> >> > > with it? Mixing request params with form fields
> >> > > has caused me grief more than once.
> >> > >
> >> > > On Jun 19, 2006, at 7:34 PM, Antonis Lebesis wrote:
> >> > >
> >> > > > Hello,
> >> > > >  I have a jsp (foo.jsp) that displays information about a certain
> >> > > > foo. I have defined a LoadFooAction, that prepares the foo
> >> object and
> >> > > > the SubmitFooAction, that is called when I want to change the
> >> > > > appearance of foo in foo.jsp [suppose that foo is a list of
> >> bars and
> >> > > > that I want to change the order of bars (by name, by date etc)].
> >> > > >
> >> > > >  In struts-config.xml I have defined the following:
> >> > > >  <action path="/loadFoo" type="LoadFooAction" name="FooForm">
> >> > > >    <forward name="success" path="/foo.jsp"/>
> >> > > >  </action>
> >> > > >  <action path="/submitFoo" type="SubmitFoo" name="FooForm">
> >> > > >    <forward name="reload" path="/loadFoo.do" redirect="true"/>
> >> > > >  </action>
> >> > > >
> >> > > >  In order to identify which foo to load, I have added a
> >> parameter in
> >> > > > loadFoo, called id, ie
> >> > > >    http://my.foo.site/loadFoo.do&id=23
> >> > > >
> >> > > >  The problem is that when I press submit in foo.jsp, the execute
> >> > > > method in SubmitFooAction redirects the browser to
> >> > > > http://my.foo.site/loadFoo.do, loosing the id parameter from
> >> the url.
> >> > > > I can store either foo or "id=23" to session and retrieve them
> >> from
> >> > > > there when the id parameter is not present, but what happens
> >> when the
> >> > > > session expires and the user presses refresh or if the user
> >> decides to
> >> > > > bookmark the page? I end up with a loadFoo.do without any
> >> information
> >> > > > about which foo to display.
> >> > > >
> >> > > >  Has any of you dealt with this problem before? The only thing
> >> that I
> >> > > > can think of is to redirect the user to a different (perhaps
> >> error)
> >> > > > page when no info is available, but I would really like to be
> >> able to
> >> > > > do something better than that.
> >> > > >
> >> > > > Thanks in advance,
> >> > > > Antonis
> >> > > >
> >> > > > PS. I know it's long, but it's 4:30 in the morning (EEST)...
> >> > > >
> >> > > >
> >> ---------------------------------------------------------------------
> >> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > > > For additional commands, e-mail: user-help@struts.apache.org
> >> > > >
> >> > >
> >> > >
> >> > >
> >> ---------------------------------------------------------------------
> >> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > > For additional commands, e-mail: user-help@struts.apache.org
> >> > >
> >> > >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> > For additional commands, e-mail: user-help@struts.apache.org
> >> >
> >> >
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
>
> --
> Lance Semmens
> Marketpipe Limited
> a. 7 Soho Square, London W1D 3QB, UK
> t. +44 20 7297 8401
> f. +44 20 7297 8427
> e. lance.semmens@marketpipe.com
> w. www.marketpipe.com
>
>
>

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


Re: Request parameters in action forward

Posted by Lance Semmens <la...@marketpipe.com>.
You can use an org.apache.struts.action.ActionRedirect

ActionForward forward = mapping.findForward("reload");
ActionRedirect redirect = new ActionRedirect(forward);
redirect.addParameter("id", idValue);
return redirect;


Antonis Lebesis wrote:
> Hi,
>  I do have a SelectFooAction (actually it's called ChooseFooAction
> :)). There is another problem though:
>  This action is used in more than one places so I have to add a
> parameter called action in it's url (action=display for a simple user,
> action=edit for the admin etc). Since I have a lot of foo's, I have a
> form in this page to select which category of Foo's to display. When
> the user selects  a category, the page is reloaded (through another
> "reload" mapping) which leads us from selectFoo.do?action=display to
> selectFoo.do.
>  Do you see a pattern here ;)?
>
> Antonis
>
> On 6/21/06, Monkeyden <mo...@gmail.com> wrote:
>> >The only thing that I
>> >can think of is to redirect the user to a different (perhaps error)
>>
>> exactly, send them back to wherever they go to select the foo they 
>> want to
>> look at.  Do you have a SelectFooAction?
>>
>>
>> On 6/20/06, Antonis Lebesis <an...@gmail.com> wrote:
>> >
>> > Thank you Don.
>> > I have done that and the session expiry problem is solved. The
>> > bookmark problem still exists though...
>> > There is a way to overcome this as well:
>> >
>> >   ActionForward forward = new ActionForward();
>> >   forward.setPath(mapping.findForward("reload").getPath() + "&id=23");
>> >
>> > which redirects to http://my.foo.site/loadFoo.do&id=23 , but this is
>> > a hack I wouldn't like to use (plus I would have to change the code
>> > for ~60 classes many of which are DispatchActions: a lot of work
>> > :))...
>> >
>> > Antonis
>> >
>> >
>> > On 6/20/06, Don Vawter <do...@vawter.com> wrote:
>> > > Can you take the request parameter and populate a hidden form field
>> > > with it? Mixing request params with form fields
>> > > has caused me grief more than once.
>> > >
>> > > On Jun 19, 2006, at 7:34 PM, Antonis Lebesis wrote:
>> > >
>> > > > Hello,
>> > > >  I have a jsp (foo.jsp) that displays information about a certain
>> > > > foo. I have defined a LoadFooAction, that prepares the foo 
>> object and
>> > > > the SubmitFooAction, that is called when I want to change the
>> > > > appearance of foo in foo.jsp [suppose that foo is a list of 
>> bars and
>> > > > that I want to change the order of bars (by name, by date etc)].
>> > > >
>> > > >  In struts-config.xml I have defined the following:
>> > > >  <action path="/loadFoo" type="LoadFooAction" name="FooForm">
>> > > >    <forward name="success" path="/foo.jsp"/>
>> > > >  </action>
>> > > >  <action path="/submitFoo" type="SubmitFoo" name="FooForm">
>> > > >    <forward name="reload" path="/loadFoo.do" redirect="true"/>
>> > > >  </action>
>> > > >
>> > > >  In order to identify which foo to load, I have added a 
>> parameter in
>> > > > loadFoo, called id, ie
>> > > >    http://my.foo.site/loadFoo.do&id=23
>> > > >
>> > > >  The problem is that when I press submit in foo.jsp, the execute
>> > > > method in SubmitFooAction redirects the browser to
>> > > > http://my.foo.site/loadFoo.do, loosing the id parameter from 
>> the url.
>> > > > I can store either foo or "id=23" to session and retrieve them 
>> from
>> > > > there when the id parameter is not present, but what happens 
>> when the
>> > > > session expires and the user presses refresh or if the user 
>> decides to
>> > > > bookmark the page? I end up with a loadFoo.do without any 
>> information
>> > > > about which foo to display.
>> > > >
>> > > >  Has any of you dealt with this problem before? The only thing 
>> that I
>> > > > can think of is to redirect the user to a different (perhaps 
>> error)
>> > > > page when no info is available, but I would really like to be 
>> able to
>> > > > do something better than that.
>> > > >
>> > > > Thanks in advance,
>> > > > Antonis
>> > > >
>> > > > PS. I know it's long, but it's 4:30 in the morning (EEST)...
>> > > >
>> > > > 
>> ---------------------------------------------------------------------
>> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > > > For additional commands, e-mail: user-help@struts.apache.org
>> > > >
>> > >
>> > >
>> > > 
>> ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > > For additional commands, e-mail: user-help@struts.apache.org
>> > >
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


-- 
Lance Semmens
Marketpipe Limited
a. 7 Soho Square, London W1D 3QB, UK
t. +44 20 7297 8401
f. +44 20 7297 8427
e. lance.semmens@marketpipe.com
w. www.marketpipe.com 


Re: Request parameters in action forward

Posted by Antonis Lebesis <an...@gmail.com>.
Hi,
  I do have a SelectFooAction (actually it's called ChooseFooAction
:)). There is another problem though:
  This action is used in more than one places so I have to add a
parameter called action in it's url (action=display for a simple user,
action=edit for the admin etc). Since I have a lot of foo's, I have a
form in this page to select which category of Foo's to display. When
the user selects  a category, the page is reloaded (through another
"reload" mapping) which leads us from selectFoo.do?action=display to
selectFoo.do.
  Do you see a pattern here ;)?

Antonis

On 6/21/06, Monkeyden <mo...@gmail.com> wrote:
> >The only thing that I
> >can think of is to redirect the user to a different (perhaps error)
>
> exactly, send them back to wherever they go to select the foo they want to
> look at.  Do you have a SelectFooAction?
>
>
> On 6/20/06, Antonis Lebesis <an...@gmail.com> wrote:
> >
> > Thank you Don.
> > I have done that and the session expiry problem is solved. The
> > bookmark problem still exists though...
> > There is a way to overcome this as well:
> >
> >   ActionForward forward = new ActionForward();
> >   forward.setPath(mapping.findForward("reload").getPath() + "&id=23");
> >
> > which redirects to http://my.foo.site/loadFoo.do&id=23 , but this is
> > a hack I wouldn't like to use (plus I would have to change the code
> > for ~60 classes many of which are DispatchActions: a lot of work
> > :))...
> >
> > Antonis
> >
> >
> > On 6/20/06, Don Vawter <do...@vawter.com> wrote:
> > > Can you take the request parameter and populate a hidden form field
> > > with it? Mixing request params with form fields
> > > has caused me grief more than once.
> > >
> > > On Jun 19, 2006, at 7:34 PM, Antonis Lebesis wrote:
> > >
> > > > Hello,
> > > >  I have a jsp (foo.jsp) that displays information about a certain
> > > > foo. I have defined a LoadFooAction, that prepares the foo object and
> > > > the SubmitFooAction, that is called when I want to change the
> > > > appearance of foo in foo.jsp [suppose that foo is a list of bars and
> > > > that I want to change the order of bars (by name, by date etc)].
> > > >
> > > >  In struts-config.xml I have defined the following:
> > > >  <action path="/loadFoo" type="LoadFooAction" name="FooForm">
> > > >    <forward name="success" path="/foo.jsp"/>
> > > >  </action>
> > > >  <action path="/submitFoo" type="SubmitFoo" name="FooForm">
> > > >    <forward name="reload" path="/loadFoo.do" redirect="true"/>
> > > >  </action>
> > > >
> > > >  In order to identify which foo to load, I have added a parameter in
> > > > loadFoo, called id, ie
> > > >    http://my.foo.site/loadFoo.do&id=23
> > > >
> > > >  The problem is that when I press submit in foo.jsp, the execute
> > > > method in SubmitFooAction redirects the browser to
> > > > http://my.foo.site/loadFoo.do, loosing the id parameter from the url.
> > > > I can store either foo or "id=23" to session and retrieve them from
> > > > there when the id parameter is not present, but what happens when the
> > > > session expires and the user presses refresh or if the user decides to
> > > > bookmark the page? I end up with a loadFoo.do without any information
> > > > about which foo to display.
> > > >
> > > >  Has any of you dealt with this problem before? The only thing that I
> > > > can think of is to redirect the user to a different (perhaps error)
> > > > page when no info is available, but I would really like to be able to
> > > > do something better than that.
> > > >
> > > > Thanks in advance,
> > > > Antonis
> > > >
> > > > PS. I know it's long, but it's 4:30 in the morning (EEST)...
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>

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


[HELP] I use struts + Velocity, I couldn't submit 1 form with unicode information! :(

Posted by Pham Anh Tuan <an...@ichi-corp.jp>.
Hi all,

I use Struts framework + Velocity, and I have a form with a text field, 
something like below:

<form method="POST" action="$link.setAction("/saveIt")">
    <table>
        <tr>
            <td>
                    <input type="text" name="something">
            </td>
        </tr>
    </table>
</form>

in velocity.properties file, I set:

input.encoding=UTF-8
output.encoding=UTF-8
hiz, but with all above, I couldn't save unicode value of something property 
into my DB (Mysql 4.1, I had set all utf-8) :(

but ... when I change the header of form tag like below, everything is fine, 
it's mean, I can save unicode value into DB :( ... I don't know why, help me 
plz :(

<form enctype="multipart/form-data" method="POST" 
action="$link.setAction("/saveIt")">

thanks in advance,

bowlkhin



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


Re: Request parameters in action forward

Posted by Monkeyden <mo...@gmail.com>.
>The only thing that I
>can think of is to redirect the user to a different (perhaps error)

exactly, send them back to wherever they go to select the foo they want to
look at.  Do you have a SelectFooAction?


On 6/20/06, Antonis Lebesis <an...@gmail.com> wrote:
>
> Thank you Don.
> I have done that and the session expiry problem is solved. The
> bookmark problem still exists though...
> There is a way to overcome this as well:
>
>   ActionForward forward = new ActionForward();
>   forward.setPath(mapping.findForward("reload").getPath() + "&id=23");
>
> which redirects to http://my.foo.site/loadFoo.do&id=23 , but this is
> a hack I wouldn't like to use (plus I would have to change the code
> for ~60 classes many of which are DispatchActions: a lot of work
> :))...
>
> Antonis
>
>
> On 6/20/06, Don Vawter <do...@vawter.com> wrote:
> > Can you take the request parameter and populate a hidden form field
> > with it? Mixing request params with form fields
> > has caused me grief more than once.
> >
> > On Jun 19, 2006, at 7:34 PM, Antonis Lebesis wrote:
> >
> > > Hello,
> > >  I have a jsp (foo.jsp) that displays information about a certain
> > > foo. I have defined a LoadFooAction, that prepares the foo object and
> > > the SubmitFooAction, that is called when I want to change the
> > > appearance of foo in foo.jsp [suppose that foo is a list of bars and
> > > that I want to change the order of bars (by name, by date etc)].
> > >
> > >  In struts-config.xml I have defined the following:
> > >  <action path="/loadFoo" type="LoadFooAction" name="FooForm">
> > >    <forward name="success" path="/foo.jsp"/>
> > >  </action>
> > >  <action path="/submitFoo" type="SubmitFoo" name="FooForm">
> > >    <forward name="reload" path="/loadFoo.do" redirect="true"/>
> > >  </action>
> > >
> > >  In order to identify which foo to load, I have added a parameter in
> > > loadFoo, called id, ie
> > >    http://my.foo.site/loadFoo.do&id=23
> > >
> > >  The problem is that when I press submit in foo.jsp, the execute
> > > method in SubmitFooAction redirects the browser to
> > > http://my.foo.site/loadFoo.do, loosing the id parameter from the url.
> > > I can store either foo or "id=23" to session and retrieve them from
> > > there when the id parameter is not present, but what happens when the
> > > session expires and the user presses refresh or if the user decides to
> > > bookmark the page? I end up with a loadFoo.do without any information
> > > about which foo to display.
> > >
> > >  Has any of you dealt with this problem before? The only thing that I
> > > can think of is to redirect the user to a different (perhaps error)
> > > page when no info is available, but I would really like to be able to
> > > do something better than that.
> > >
> > > Thanks in advance,
> > > Antonis
> > >
> > > PS. I know it's long, but it's 4:30 in the morning (EEST)...
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Request parameters in action forward

Posted by Antonis Lebesis <an...@gmail.com>.
Thank you Don.
  I have done that and the session expiry problem is solved. The
bookmark problem still exists though...
  There is a way to overcome this as well:

   ActionForward forward = new ActionForward();
   forward.setPath(mapping.findForward("reload").getPath() + "&id=23");

  which redirects to http://my.foo.site/loadFoo.do&id=23 , but this is
a hack I wouldn't like to use (plus I would have to change the code
for ~60 classes many of which are DispatchActions: a lot of work
:))...

Antonis


On 6/20/06, Don Vawter <do...@vawter.com> wrote:
> Can you take the request parameter and populate a hidden form field
> with it? Mixing request params with form fields
> has caused me grief more than once.
>
> On Jun 19, 2006, at 7:34 PM, Antonis Lebesis wrote:
>
> > Hello,
> >  I have a jsp (foo.jsp) that displays information about a certain
> > foo. I have defined a LoadFooAction, that prepares the foo object and
> > the SubmitFooAction, that is called when I want to change the
> > appearance of foo in foo.jsp [suppose that foo is a list of bars and
> > that I want to change the order of bars (by name, by date etc)].
> >
> >  In struts-config.xml I have defined the following:
> >  <action path="/loadFoo" type="LoadFooAction" name="FooForm">
> >    <forward name="success" path="/foo.jsp"/>
> >  </action>
> >  <action path="/submitFoo" type="SubmitFoo" name="FooForm">
> >    <forward name="reload" path="/loadFoo.do" redirect="true"/>
> >  </action>
> >
> >  In order to identify which foo to load, I have added a parameter in
> > loadFoo, called id, ie
> >    http://my.foo.site/loadFoo.do&id=23
> >
> >  The problem is that when I press submit in foo.jsp, the execute
> > method in SubmitFooAction redirects the browser to
> > http://my.foo.site/loadFoo.do, loosing the id parameter from the url.
> > I can store either foo or "id=23" to session and retrieve them from
> > there when the id parameter is not present, but what happens when the
> > session expires and the user presses refresh or if the user decides to
> > bookmark the page? I end up with a loadFoo.do without any information
> > about which foo to display.
> >
> >  Has any of you dealt with this problem before? The only thing that I
> > can think of is to redirect the user to a different (perhaps error)
> > page when no info is available, but I would really like to be able to
> > do something better than that.
> >
> > Thanks in advance,
> > Antonis
> >
> > PS. I know it's long, but it's 4:30 in the morning (EEST)...
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Request parameters in action forward

Posted by Don Vawter <do...@vawter.com>.
Can you take the request parameter and populate a hidden form field  
with it? Mixing request params with form fields
has caused me grief more than once.

On Jun 19, 2006, at 7:34 PM, Antonis Lebesis wrote:

> Hello,
>  I have a jsp (foo.jsp) that displays information about a certain
> foo. I have defined a LoadFooAction, that prepares the foo object and
> the SubmitFooAction, that is called when I want to change the
> appearance of foo in foo.jsp [suppose that foo is a list of bars and
> that I want to change the order of bars (by name, by date etc)].
>
>  In struts-config.xml I have defined the following:
>  <action path="/loadFoo" type="LoadFooAction" name="FooForm">
>    <forward name="success" path="/foo.jsp"/>
>  </action>
>  <action path="/submitFoo" type="SubmitFoo" name="FooForm">
>    <forward name="reload" path="/loadFoo.do" redirect="true"/>
>  </action>
>
>  In order to identify which foo to load, I have added a parameter in
> loadFoo, called id, ie
>    http://my.foo.site/loadFoo.do&id=23
>
>  The problem is that when I press submit in foo.jsp, the execute
> method in SubmitFooAction redirects the browser to
> http://my.foo.site/loadFoo.do, loosing the id parameter from the url.
> I can store either foo or "id=23" to session and retrieve them from
> there when the id parameter is not present, but what happens when the
> session expires and the user presses refresh or if the user decides to
> bookmark the page? I end up with a loadFoo.do without any information
> about which foo to display.
>
>  Has any of you dealt with this problem before? The only thing that I
> can think of is to redirect the user to a different (perhaps error)
> page when no info is available, but I would really like to be able to
> do something better than that.
>
> Thanks in advance,
> Antonis
>
> PS. I know it's long, but it's 4:30 in the morning (EEST)...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


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