You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richard Sayre <ri...@gmail.com> on 2011/02/01 18:50:10 UTC

Changing The Result Page

I am making a mobile site for my current web application.  I have a
huge number of actions that return to JSP pages.  I have a mobile
detection class written.

Is there a way that I can change the result page if the user is on a
mobile device?

I want to avoid having to write this in all my actions:

if(mobile) {

  return SUCCESS_MOBILE

} else {

  return SUCCESS

}


If I could change the result page it would make it easier.  For
example if it is mobile then I replace the result page of
/mydir/myPage.jsp to /mydir/myPage-m.jsp.

Any suggestions?

Thank you,

Rich

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


Re: Changing The Result Page

Posted by st...@gmail.com.
Have you considered Sitemesh?

On Tue, Feb 1, 2011 at 11:50 AM, Richard Sayre <ri...@gmail.com>wrote:

> I am making a mobile site for my current web application.  I have a
> huge number of actions that return to JSP pages.  I have a mobile
> detection class written.
>
> Is there a way that I can change the result page if the user is on a
> mobile device?
>
> I want to avoid having to write this in all my actions:
>
> if(mobile) {
>
>  return SUCCESS_MOBILE
>
> } else {
>
>  return SUCCESS
>
> }
>
>
> If I could change the result page it would make it easier.  For
> example if it is mobile then I replace the result page of
> /mydir/myPage.jsp to /mydir/myPage-m.jsp.
>
> Any suggestions?
>
> Thank you,
>
> Rich
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Changing The Result Page

Posted by Richard Sayre <ri...@gmail.com>.
This looks like a good Idea.  I will test it and Dave N's suggestion as well.

Thank you All

On Tue, Feb 1, 2011 at 3:14 PM, Chris Pratt <th...@gmail.com> wrote:
> To extend on this idea, instead of requiring all your actions to add a
> getBtype(), you could use an interceptor that determine's the Browser Type
> and sets a context attribute you could access using:
>
> <result>/${#btype}/Profile.jsp</result>
>
>  (*Chris*)
>
> On Tue, Feb 1, 2011 at 10:36 AM, Greg Lindholm <gr...@gmail.com>wrote:
>
>> You could also add a "btype" (browser type) macro to your jsp paths like
>> this...
>>
>> <result>/struts2/${btype}/Profile.jsp</result>
>>
>> Your actions would have to have a getBtype() method that supplied that
>> portion of the path.
>>
>> This assumes you keep the mobile jsp pages in a separate directory
>> then the desktop.
>>
>> Another way is to create a custom result type ( extend
>> org.apache.struts2.dispatcher.ServletDispatcherResult) have it mung
>> with your paths and set it to be the default result-type.
>>
>> (One of the things I love about Struts 2 is number of options you have
>> to solve a problem).
>>
>>
>> On Tue, Feb 1, 2011 at 12:56 PM, Dave Newton <da...@gmail.com>
>> wrote:
>> > Interceptor w/ pre-result listener?
>> >
>> > Dave
>> >
>> > On Tue, Feb 1, 2011 at 12:50 PM, Richard Sayre <richardsayre@gmail.com
>> >wrote:
>> >
>> >> I am making a mobile site for my current web application.  I have a
>> >> huge number of actions that return to JSP pages.  I have a mobile
>> >> detection class written.
>> >>
>> >> Is there a way that I can change the result page if the user is on a
>> >> mobile device?
>> >>
>> >> I want to avoid having to write this in all my actions:
>> >>
>> >> if(mobile) {
>> >>
>> >>  return SUCCESS_MOBILE
>> >>
>> >> } else {
>> >>
>> >>  return SUCCESS
>> >>
>> >> }
>> >>
>> >>
>> >> If I could change the result page it would make it easier.  For
>> >> example if it is mobile then I replace the result page of
>> >> /mydir/myPage.jsp to /mydir/myPage-m.jsp.
>> >>
>> >> Any suggestions?
>> >>
>> >> Thank you,
>> >>
>> >> Rich
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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: Changing The Result Page

Posted by Chris Pratt <th...@gmail.com>.
To extend on this idea, instead of requiring all your actions to add a
getBtype(), you could use an interceptor that determine's the Browser Type
and sets a context attribute you could access using:

<result>/${#btype}/Profile.jsp</result>

  (*Chris*)

On Tue, Feb 1, 2011 at 10:36 AM, Greg Lindholm <gr...@gmail.com>wrote:

> You could also add a "btype" (browser type) macro to your jsp paths like
> this...
>
> <result>/struts2/${btype}/Profile.jsp</result>
>
> Your actions would have to have a getBtype() method that supplied that
> portion of the path.
>
> This assumes you keep the mobile jsp pages in a separate directory
> then the desktop.
>
> Another way is to create a custom result type ( extend
> org.apache.struts2.dispatcher.ServletDispatcherResult) have it mung
> with your paths and set it to be the default result-type.
>
> (One of the things I love about Struts 2 is number of options you have
> to solve a problem).
>
>
> On Tue, Feb 1, 2011 at 12:56 PM, Dave Newton <da...@gmail.com>
> wrote:
> > Interceptor w/ pre-result listener?
> >
> > Dave
> >
> > On Tue, Feb 1, 2011 at 12:50 PM, Richard Sayre <richardsayre@gmail.com
> >wrote:
> >
> >> I am making a mobile site for my current web application.  I have a
> >> huge number of actions that return to JSP pages.  I have a mobile
> >> detection class written.
> >>
> >> Is there a way that I can change the result page if the user is on a
> >> mobile device?
> >>
> >> I want to avoid having to write this in all my actions:
> >>
> >> if(mobile) {
> >>
> >>  return SUCCESS_MOBILE
> >>
> >> } else {
> >>
> >>  return SUCCESS
> >>
> >> }
> >>
> >>
> >> If I could change the result page it would make it easier.  For
> >> example if it is mobile then I replace the result page of
> >> /mydir/myPage.jsp to /mydir/myPage-m.jsp.
> >>
> >> Any suggestions?
> >>
> >> Thank you,
> >>
> >> Rich
> >>
> >> ---------------------------------------------------------------------
> >> 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: Changing The Result Page

Posted by Greg Lindholm <gr...@gmail.com>.
You could also add a "btype" (browser type) macro to your jsp paths like this...

<result>/struts2/${btype}/Profile.jsp</result>

Your actions would have to have a getBtype() method that supplied that
portion of the path.

This assumes you keep the mobile jsp pages in a separate directory
then the desktop.

Another way is to create a custom result type ( extend
org.apache.struts2.dispatcher.ServletDispatcherResult) have it mung
with your paths and set it to be the default result-type.

(One of the things I love about Struts 2 is number of options you have
to solve a problem).


On Tue, Feb 1, 2011 at 12:56 PM, Dave Newton <da...@gmail.com> wrote:
> Interceptor w/ pre-result listener?
>
> Dave
>
> On Tue, Feb 1, 2011 at 12:50 PM, Richard Sayre <ri...@gmail.com>wrote:
>
>> I am making a mobile site for my current web application.  I have a
>> huge number of actions that return to JSP pages.  I have a mobile
>> detection class written.
>>
>> Is there a way that I can change the result page if the user is on a
>> mobile device?
>>
>> I want to avoid having to write this in all my actions:
>>
>> if(mobile) {
>>
>>  return SUCCESS_MOBILE
>>
>> } else {
>>
>>  return SUCCESS
>>
>> }
>>
>>
>> If I could change the result page it would make it easier.  For
>> example if it is mobile then I replace the result page of
>> /mydir/myPage.jsp to /mydir/myPage-m.jsp.
>>
>> Any suggestions?
>>
>> Thank you,
>>
>> Rich
>>
>> ---------------------------------------------------------------------
>> 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: Changing The Result Page

Posted by Dave Newton <da...@gmail.com>.
Interceptor w/ pre-result listener?

Dave

On Tue, Feb 1, 2011 at 12:50 PM, Richard Sayre <ri...@gmail.com>wrote:

> I am making a mobile site for my current web application.  I have a
> huge number of actions that return to JSP pages.  I have a mobile
> detection class written.
>
> Is there a way that I can change the result page if the user is on a
> mobile device?
>
> I want to avoid having to write this in all my actions:
>
> if(mobile) {
>
>  return SUCCESS_MOBILE
>
> } else {
>
>  return SUCCESS
>
> }
>
>
> If I could change the result page it would make it easier.  For
> example if it is mobile then I replace the result page of
> /mydir/myPage.jsp to /mydir/myPage-m.jsp.
>
> Any suggestions?
>
> Thank you,
>
> Rich
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>