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 <chris.cranf...@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-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

Reply via email to