You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Omar Carvajal <ta...@carvajalonline.com> on 2010/08/20 07:48:37 UTC

Calling different pages depending on browser

Hey all,

I wanted to know if there was a way to get my app to call different pages
depending on the browser that is being used.

For example if the application is being accessed from an iPhone, it should
go to the page /mobile for example. And if FireFox is used, it should load
/desktop.

How could I achieve this?

Thanks in advance,

Omar

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Calling different pages depending on browser

Posted by Omar Carvajal <ta...@carvajalonline.com>.
Thanks guys!

That did it, I just created a dispatcher service that checks the User
Agent and from there I redirect the user to the page he needs to go. I knew
I had to check the User Agent header, I just didn't know where to do it.

Omar

On Fri, 20 Aug 2010 09:43:38 +0200, "Joost Schouten (mailing lists)"
<jo...@jsportal.com> wrote:
> This [1] is some code from one of my pages doing what you ask for. You
> could also wrap this in a dispatcher, use rewrite rules on your http
> server or tuckey.org java rewrite filter.
> 
> Good luck,
> Joost
> 
> 
> [1]: forward iphone users to another page
> @Inject
>     private RequestGlobals requestGlobals;
> 
>     @OnEvent(value = EventConstants.ACTIVATE)
>     private Object activate() {
> 
>         HttpServletRequest httpServletRequest =
> requestGlobals.getHTTPServletRequest();
>         String userAgent = httpServletRequest.getHeader("User-Agent");
>         if(userAgent.contains("iPhone")) {
>             //return a page, link URL etc. to forward wherever you
> want them to go
>         }
> 
>         return null;
>     }
> 
> On Fri, Aug 20, 2010 at 8:19 AM, Kalle Korhonen
> <ka...@gmail.com> wrote:
>> Use the User-Agent header (e.g
http://en.wikipedia.org/wiki/User_agent).
>>
>> Kalle
>>
>>
>> On Thu, Aug 19, 2010 at 10:48 PM, Omar Carvajal
>> <ta...@carvajalonline.com> wrote:
>>> Hey all,
>>>
>>> I wanted to know if there was a way to get my app to call different
>>> pages
>>> depending on the browser that is being used.
>>>
>>> For example if the application is being accessed from an iPhone, it
>>> should
>>> go to the page /mobile for example. And if FireFox is used, it should
>>> load
>>> /desktop.
>>>
>>> How could I achieve this?
>>>
>>> Thanks in advance,
>>>
>>> Omar
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Calling different pages depending on browser

Posted by "Joost Schouten (mailing lists)" <jo...@jsportal.com>.
This [1] is some code from one of my pages doing what you ask for. You
could also wrap this in a dispatcher, use rewrite rules on your http
server or tuckey.org java rewrite filter.

Good luck,
Joost


[1]: forward iphone users to another page
@Inject
    private RequestGlobals requestGlobals;

    @OnEvent(value = EventConstants.ACTIVATE)
    private Object activate() {

        HttpServletRequest httpServletRequest =
requestGlobals.getHTTPServletRequest();
        String userAgent = httpServletRequest.getHeader("User-Agent");
        if(userAgent.contains("iPhone")) {
            //return a page, link URL etc. to forward wherever you
want them to go
        }

        return null;
    }

On Fri, Aug 20, 2010 at 8:19 AM, Kalle Korhonen
<ka...@gmail.com> wrote:
> Use the User-Agent header (e.g http://en.wikipedia.org/wiki/User_agent).
>
> Kalle
>
>
> On Thu, Aug 19, 2010 at 10:48 PM, Omar Carvajal
> <ta...@carvajalonline.com> wrote:
>> Hey all,
>>
>> I wanted to know if there was a way to get my app to call different pages
>> depending on the browser that is being used.
>>
>> For example if the application is being accessed from an iPhone, it should
>> go to the page /mobile for example. And if FireFox is used, it should load
>> /desktop.
>>
>> How could I achieve this?
>>
>> Thanks in advance,
>>
>> Omar
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Calling different pages depending on browser

Posted by Kalle Korhonen <ka...@gmail.com>.
Use the User-Agent header (e.g http://en.wikipedia.org/wiki/User_agent).

Kalle


On Thu, Aug 19, 2010 at 10:48 PM, Omar Carvajal
<ta...@carvajalonline.com> wrote:
> Hey all,
>
> I wanted to know if there was a way to get my app to call different pages
> depending on the browser that is being used.
>
> For example if the application is being accessed from an iPhone, it should
> go to the page /mobile for example. And if FireFox is used, it should load
> /desktop.
>
> How could I achieve this?
>
> Thanks in advance,
>
> Omar
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org