You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "CRANFORD, CHRIS" <Ch...@setech.com> on 2012/01/13 18:00:03 UTC

Mobile Device Support

I have been asked to investigate adding mobile device support to an
existing Struts2 application.  I was wondering if others could explain
how you added mobile detection and view support for your Struts2
applications.  

Did you use an interceptor to set a session Boolean value and keyed your
view from that variable?  
Did your interceptor append/prefix your invocation result with a
"mobile" value so that different views were rendered?  

There are a number of ways to implement it obviously, but wanted to get
a feel for what others may have tried in the past and the obstacles that
may have surfaced to point you along a specific path.

Thanks in advance,
Chris


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


Re: Mobile Device Support

Posted by Christian Grobmeier <gr...@gmail.com>.
Look at responsive CSS frameworks. Actually I would not put anything
for this into struts code if possible, you should make it just a
css/javascript only trick:
http://idesignow.com/css/7-css-grid-layout-frameworks-for-responsive-web-design.html

I am a bootstrap fan, 2.0 is supporting responsive design

Using this you will not even have to differ between two different views.

If this is not possible, you can load css by screen type with
JavaScript. Again, touching Struts application for that is usually not
necessary and it is always a good idea to keep your presentation code
on the presentation side of life

my 2 cents of course other may think different

Cheers
Christian

On Fri, Jan 13, 2012 at 6:00 PM, CRANFORD, CHRIS
<Ch...@setech.com> wrote:
> I have been asked to investigate adding mobile device support to an
> existing Struts2 application.  I was wondering if others could explain
> how you added mobile detection and view support for your Struts2
> applications.
>
> Did you use an interceptor to set a session Boolean value and keyed your
> view from that variable?
> Did your interceptor append/prefix your invocation result with a
> "mobile" value so that different views were rendered?
>
> There are a number of ways to implement it obviously, but wanted to get
> a feel for what others may have tried in the past and the obstacles that
> may have surfaced to point you along a specific path.
>
> Thanks in advance,
> Chris
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>



-- 
http://www.grobmeier.de
https://www.timeandbill.de

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


Re: RE : Mobile Device Support

Posted by Maurizio Cucchiara <mc...@apache.org>.
Sure, it is nothing special, just a simple interceptor [1], I'm sure there
are many better ways to write it (you can distinguish tablet from mobile
phone, you can inject the pattern, and so on)

[1] http://pastebin.com/2v9sdZtw

Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 15 January 2012 20:49, <Ma...@ensam.eu> wrote:

> Are you agree to post the code of your interceptor ?
>

RE : Mobile Device Support

Posted by Ma...@ensam.eu.
Hi,

Your solution sounds better when you want to have a different display between mobile users and browser users.

Are you agree to post the code of your interceptor ?

I am thinking of making a mobile version of a calendar application. I am displaying a week based calendar for browsers users, but think it will be better to just display a daily one for mobile users. So I have to detect mobile users in my action.

Cordialy,

Matthieu MARC

----
Matthieu MARC
Service Informatique
Arts et Métiers ParisTech - Centre d'Angers
matthieu.marc@ensam.eu

________________________________________
De : maurizio.cucchiara@gmail.com [maurizio.cucchiara@gmail.com] de la part de Maurizio Cucchiara [mcucchiara@apache.org]
Date d'envoi : samedi 14 janvier 2012 09:26
À : Struts Users Mailing List
Objet : Re: Mobile Device Support

Although I consider very good what Christian said, sometimes the
client-side is not an option (f.i. you don't want to send the same amount
of data on mobile devices).
Conversely, sometimes the server-side could not be an option (f.i. you
might choose an not-intrusive way for your code, you can choose to write
every view logic on top your existing code).
Speaking of server-side, and especially regarding Struts, this is what I
usually do:
* I wrote an interceptor which being based on the agent parameter, put a
variable in the value stack context.
* the value of this var is used as the result folder (f.ex.
<result>/WEB-INF/${VIEW}/YOUR_PATH</result>). This allows you to define a
kind of hierarchy  writing a specific result only for those you really want
to overwrite
* on top of that I setup sitemesh (with its filter properly placed in terms
of ordering) which decorates the jsp depending on the path
(/WEB-INF/mobile/a.jsp uses a different decorator from
/WEB-INF/tablet/a.jsp)
* the same interceptor I checks if the action implements ViewAware
interface and eventually injects the view name inside the action itself.

I preferred this approach against the result decoupling, because I don't
want to start using a lot of wildcard.
The only drawback (if it is one) I noticed until now is that IntelliJ Idea
doesn't allow me to navigate result location by click.

My 2 cents too.


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 13 January 2012 18:00, CRANFORD, CHRIS <Ch...@setech.com> wrote:

> I have been asked to investigate adding mobile device support to an
> existing Struts2 application.  I was wondering if others could explain
> how you added mobile detection and view support for your Struts2
> applications.
>
> Did you use an interceptor to set a session Boolean value and keyed your
> view from that variable?
> Did your interceptor append/prefix your invocation result with a
> "mobile" value so that different views were rendered?
>
> There are a number of ways to implement it obviously, but wanted to get
> a feel for what others may have tried in the past and the obstacles that
> may have surfaced to point you along a specific path.
>
> Thanks in advance,
> Chris
>
>
> ---------------------------------------------------------------------
> 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: Mobile Device Support

Posted by Maurizio Cucchiara <mc...@apache.org>.
Although I consider very good what Christian said, sometimes the
client-side is not an option (f.i. you don't want to send the same amount
of data on mobile devices).
Conversely, sometimes the server-side could not be an option (f.i. you
might choose an not-intrusive way for your code, you can choose to write
every view logic on top your existing code).
Speaking of server-side, and especially regarding Struts, this is what I
usually do:
* I wrote an interceptor which being based on the agent parameter, put a
variable in the value stack context.
* the value of this var is used as the result folder (f.ex.
<result>/WEB-INF/${VIEW}/YOUR_PATH</result>). This allows you to define a
kind of hierarchy  writing a specific result only for those you really want
to overwrite
* on top of that I setup sitemesh (with its filter properly placed in terms
of ordering) which decorates the jsp depending on the path
(/WEB-INF/mobile/a.jsp uses a different decorator from
/WEB-INF/tablet/a.jsp)
* the same interceptor I checks if the action implements ViewAware
interface and eventually injects the view name inside the action itself.

I preferred this approach against the result decoupling, because I don't
want to start using a lot of wildcard.
The only drawback (if it is one) I noticed until now is that IntelliJ Idea
doesn't allow me to navigate result location by click.

My 2 cents too.


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 13 January 2012 18:00, CRANFORD, CHRIS <Ch...@setech.com> wrote:

> I have been asked to investigate adding mobile device support to an
> existing Struts2 application.  I was wondering if others could explain
> how you added mobile detection and view support for your Struts2
> applications.
>
> Did you use an interceptor to set a session Boolean value and keyed your
> view from that variable?
> Did your interceptor append/prefix your invocation result with a
> "mobile" value so that different views were rendered?
>
> There are a number of ways to implement it obviously, but wanted to get
> a feel for what others may have tried in the past and the obstacles that
> may have surfaced to point you along a specific path.
>
> Thanks in advance,
> Chris
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>