You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Filipe David Manana <fd...@ieee.org> on 2008/01/23 16:50:23 UTC

Struts2 getting action's full URL

Hi,

is there anyway to get, from within an Action's code, a string with
the full URL for that action (including query string with current
value of the parameters) ?
I already took a look at ActionSupport, ActionContext and
ActionInvocation javadoc, but nothing there fits my needs.

thanks

-- 
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.

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


Re: Struts2 getting action's full URL

Posted by Filipe David Manana <fd...@ieee.org>.
Good ideia. I just made the select box submit the form whenever a new
option is selected, via the onchange event. The form's target is the
same action, with hidden parameters, except for the select box, which
targets one of the parameters.

Thanks for your suggestions.

On 1/23/08, Dave Newton <ne...@yahoo.com> wrote:
> --- Filipe David Manana <fd...@ieee.org> wrote:
> > Basically I am creating a page that contains a select box.
> > When the user changes the selected item, it is redirected to an URL.
> > The value of each item in the select box corresponds to the URL of the
> > current page but with different values for the action's parameters
> > (passed in the query string).
>
> While I'm not a huge fan of that UI pattern, I'd probably be more inclined to
> consider something like submitting the form onchange and setting up a result
> that takes the parameter into account somehow or letting the framework do it
> on its own.
>
> d.
>
> >
> > That's why I am falling back to Servlet spec :)
> > Of course, I gladly accept suggestions for a more elegant solution.
> >
> > for now httpservlet request has what I need,
> > HttpServletRequest req = ServletActionContext.getRequest();
> >
> > cheers
> >
> > On Jan 23, 2008 5:20 PM, Dave Newton <ne...@yahoo.com> wrote:
> > > --- Filipe David Manana <fd...@ieee.org> wrote:
> > > > is there anyway to get, from within an Action's code, a string with
> > > > the full URL for that action (including query string with current
> > > > value of the parameters) ?
> > > > I already took a look at ActionSupport, ActionContext and
> > > > ActionInvocation javadoc, but nothing there fits my needs.
> > >
> > > Get it from the request.
> > >
> > > Including a query string means you're already tied to the servlet spec (I
> > > think); actions are supposed to be isolated from that level of
> > granularity,
> > > so requiring the query string pretty much implies you're breaking that
> > > isolation.
> > >
> > > d.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> >
> >
> > --
> > Filipe David Manana,
> > fdmanana@ieee.org
> >
> > Obvious facts are like secrets to those not trained to see them.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>


-- 
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.

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


Re: Struts2 getting action's full URL

Posted by Dave Newton <ne...@yahoo.com>.
--- Filipe David Manana <fd...@ieee.org> wrote:
> Basically I am creating a page that contains a select box.
> When the user changes the selected item, it is redirected to an URL.
> The value of each item in the select box corresponds to the URL of the
> current page but with different values for the action's parameters
> (passed in the query string).

While I'm not a huge fan of that UI pattern, I'd probably be more inclined to
consider something like submitting the form onchange and setting up a result
that takes the parameter into account somehow or letting the framework do it
on its own.

d.

> 
> That's why I am falling back to Servlet spec :)
> Of course, I gladly accept suggestions for a more elegant solution.
> 
> for now httpservlet request has what I need,
> HttpServletRequest req = ServletActionContext.getRequest();
> 
> cheers
> 
> On Jan 23, 2008 5:20 PM, Dave Newton <ne...@yahoo.com> wrote:
> > --- Filipe David Manana <fd...@ieee.org> wrote:
> > > is there anyway to get, from within an Action's code, a string with
> > > the full URL for that action (including query string with current
> > > value of the parameters) ?
> > > I already took a look at ActionSupport, ActionContext and
> > > ActionInvocation javadoc, but nothing there fits my needs.
> >
> > Get it from the request.
> >
> > Including a query string means you're already tied to the servlet spec (I
> > think); actions are supposed to be isolated from that level of
> granularity,
> > so requiring the query string pretty much implies you're breaking that
> > isolation.
> >
> > d.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> 
> 
> 
> -- 
> Filipe David Manana,
> fdmanana@ieee.org
> 
> Obvious facts are like secrets to those not trained to see them.
> 
> ---------------------------------------------------------------------
> 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: Struts2 getting action's full URL

Posted by Filipe David Manana <fd...@ieee.org>.
Basically I am creating a page that contains a select box.
When the user changes the selected item, it is redirected to an URL.
The value of each item in the select box corresponds to the URL of the
current page but with different values for the action's parameters
(passed in the query string).

That's why I am falling back to Servlet spec :)
Of course, I gladly accept suggestions for a more elegant solution.

for now httpservlet request has what I need,
HttpServletRequest req = ServletActionContext.getRequest();

cheers

On Jan 23, 2008 5:20 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- Filipe David Manana <fd...@ieee.org> wrote:
> > is there anyway to get, from within an Action's code, a string with
> > the full URL for that action (including query string with current
> > value of the parameters) ?
> > I already took a look at ActionSupport, ActionContext and
> > ActionInvocation javadoc, but nothing there fits my needs.
>
> Get it from the request.
>
> Including a query string means you're already tied to the servlet spec (I
> think); actions are supposed to be isolated from that level of granularity,
> so requiring the query string pretty much implies you're breaking that
> isolation.
>
> d.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
Filipe David Manana,
fdmanana@ieee.org

Obvious facts are like secrets to those not trained to see them.

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


Re: Struts2 getting action's full URL

Posted by Dave Newton <ne...@yahoo.com>.
--- Filipe David Manana <fd...@ieee.org> wrote:
> is there anyway to get, from within an Action's code, a string with
> the full URL for that action (including query string with current
> value of the parameters) ?
> I already took a look at ActionSupport, ActionContext and
> ActionInvocation javadoc, but nothing there fits my needs.

Get it from the request.

Including a query string means you're already tied to the servlet spec (I
think); actions are supposed to be isolated from that level of granularity,
so requiring the query string pretty much implies you're breaking that
isolation.

d.


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