Hi Sean,
we've done this here, targetting various platforms.
what we had to do was:
build template action that automatically checks for browser and sets a
session bean with the type
wraps the mapping up an a class called MapperEx which when somebody does a
findForward, stick the platforms folder name at the beginning of the
forward.
our actions use a function called 'appPerform' and take an MapperEx instead
of ActionMapping
derive own actionservlet and override process validate to treat the input=
section of the mapping as a key into the forwards section - and uses the
mapperEx class to go back to right page... these are the new last lines of
the function... btw, in this code, uri comes from String uri =
mapping.getInput() a bit further up.
// The input field is used as an action forward name
MapperEx mapper = new MapperEx(mapping, request);
ActionForward forward = mapper.findForwardEx( uri );
RequestDispatcher rd = getServletContext().getRequestDispatcher(
forward.getPath() );
if (rd == null) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
internal.getMessage("requestDispatcher", uri));
return (false);
}
rd.forward(request, response);
return (false);
}
this is not very coherant but communication is not my strong point, lol. If
you want me to clarify anything, let me know.
Ned
----- Original Message -----
From: "Sean" <[EMAIL PROTECTED]>
To: "Struts Users" <[EMAIL PROTECTED]>
Sent: Friday, June 29, 2001 4:16 PM
Subject: Struts with different User-Agents
> 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.
>
>