Re: Client type request...

yayo <[email protected]> Sun, 6 Mar 2005 12:56:48 +0000 (UTC)
Newsgroups gmane.comp.java.strutscx.user
Message-ID <[email protected]>
Hi again!

I've done a servlet whose only purpose is to check the client type and change
the StrutsCXConstants.XSL_KEY value from the request to follow some naming like
this:

I've been looking arround in the STXX page and they do something similar to this
but withing struts configuration file. So the actions are the same as they where
but the forwards change to apply different XSL transformations to the resulting
XMLdata.

I cut'n' paste the comments I added to the web.xml of my app and the servlet
configuration so you can find out how it works:

  <!-- XSLSelector -->
  <servlet>
    <servlet-name>XSLSelector</servlet-name>
    <description>
        Selects a different XSL File namefrom within StrutsCX config
        depending on the the client type
        Just prepends the client type as I specify here.
        
        There's also a webroot relative url where to forward when done.
        
        There must be a typeX where X is the number of client type
        there'll be a search to find out the client types enumerated
        and build configurations for each of the typeX enumerated.
        
        The rest of the params are name.param where the name was defined
        as the client typeX param.
        
        NAME                    VALUES          DEFAULT         MEANING
        name.policy             append,prepend  prepend         whether to
append or prepend the client name to the StrutsCX String
        name.name               any string      ""              the string to
append or prepend
        name.user-agent         any string      ""              the string to
search in the user-agent header value in order to identify this client type
        name.accept             any string      ""              the string to
search in the accept header value in order to identify this client type
        name.accept-language    any string      ""              the string to
search in the accept-language header value in order to identify this client type
        
        The search will be done following this steps:
            - accept-language  --> this will allow map two servlets, one for
lang and other for client type
            - accept ------------> you can simply create a WML presentation and
redirect all WML clients to that
            - user-agent --------> for specified point at XSL transformations
    </description>
    <servlet-class>tk.yayo.strutscx.util.XSLSelectorServlet</servlet-class>
    <init-param>
        <param-name>url</param-name>
        <param-value>/StrutsCXServlet</param-value>
    </init-param>
    <!-- params for iexplorer -->
    <init-param>
        <param-name>type0</param-name>
        <param-value>ie</param-value>
    </init-param>
    <init-param>
        <param-name>ie.policy</param-name>
        <param-value>prepend</param-value>
    </init-param>
    <init-param>
        <param-name>ie.name</param-name>
        <param-value>ie</param-value>
    </init-param>
    <init-param>
        <param-name>ie.user-agent</param-name>
        <param-value>MSIE</param-value>
    </init-param>    
    <!-- params for default __ defaults to ie! -->
    <init-param>
        <param-name>type1</param-name>
        <param-value>default</param-value>
    </init-param>
    <init-param>
        <param-name>default.name</param-name>
        <param-value>ie</param-value>
    </init-param>
    <init-param>
        <param-name>default.policy</param-name>
        <param-value>prepend</param-value>
    </init-param>
  </servlet>
  

If anyone wants it just ask me... It's not so good but it works!
The search is done once in a session, it stores the configBean under the session
and if not present it searches...

okiz, see ya!



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click