You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Cedric Dumoulin <ce...@lifl.fr> on 2001/07/02 11:59:52 UTC

Re: Struts with different User-Agents

  Hi Sean,

  Check the "multi-channel" example in Components Framework. It could give you
some ideas. In your case, a channel will be the browser type.
  In this example, a same url map to different views according to user
privilege. Mapping is specified in configuration files. There is one default
configuration file, and one file for each 'channel' (like for i18n). Channel
files can extends default one, allowing to rewrite only what is needed.

  To adapt the example to your case, you need to write your own
DefinitionFactory. You can simply copy or extends the one provided in channel
example. Then, overload method getDefinitionsFactoryKey(...), in order to return
a String identifying your channel (ex : mozilla_6.0). This string will be used
to name your configuration file. This later  contains definitions of views,
themselves containing real jsp url.

   Hope this help,

    Cedric

Components sites :
  http://www.lifl.fr/~dumoulin/components/
  (mirror) : http://www.geocities.com/cedricdumoulin/components/



Sean wrote:

> Hello All,
>
> Had a few questions I was looking for some possible help on.  I am in the
> process of developing a web application that needs to render different views
> based on the users browser type and the version number of that browser.  It
> is pretty easy to parse out the User-Agent field of the HTTP header to get
> the version and number (with some obvious rules as to parsing order etc.
> like in the Cocoon Sitemap)
>
> The question I have is, does anyone have a redirection/servlet or
> objects/examples on how this can be done easily from within struts ... after
> the Form object is created, the action is create, the backend business logic
> is performed (which will be the same irreguardless of browser), I need to
> redirect to a different view based on the browser but I still want to submit
> actions to be common and not reference the new type .... does anyone have
> any ideas on this?  Obviously this only needs to be done once (determine
> what view heirarchy to be used) like at login.  I was thinking of defining
> something like this
>
> /views/
>    /default/
>    /mozilla/6.0
>    /msie/5.5
>    /msie/5.0
>    /mspie/2.0
>    /avantgo/1.0
>
> etc etc ... if a browser was not "explicitly" supported it would goto
> /default ...
>
> The input would be somewhere like
>
> /control
>    /send/...
>    /retreive/...
>    /login
>    /logout
>
> etc etc ... obviously this is the same irreguardless of browser type.
>
> Has anyone tried to do this? Have any examples? Or maybe can direct me to
> something with functionality simular to what I am trying to do?  I
> appreciate the help and can give more detail if needed.
>
> Sean
>
> P.S. If custom development is needed I would be interested in submitting a
> "reusable" framework back into struts if people are interested.