You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Salonen, Aki" <Ak...@wincor-nixdorf.com> on 2001/12/20 10:20:36 UTC

Multichannel support with Struts

Hello,
 
We have been developing web-application needing a multichannel support.
What I have thought is that we will have different jsp-pages for each
channel,
but same action objects.
 
So, directory structure would look like this:
 
/www-clients/*.jsp pages
/wap-clients/*.jsp pages
/xml-clients/*.jsp pages
 
Problem I'm facing is that I should have mechanism to set users channel (=
directory) at login,
and after that user would be browsing under specified directory.
 
This is not possible because ActionMapping configuration is not
directory insensitive.
 
As I have understood, all action mappings in struts-config.xml refer to
root of application like this;
/PostOrder.do, /Login.do
 
So actually Struts thinks actions are located in root directory.
I would like to access to same action object from different channels like
this:
/www-clients/PostOrder.do
/wap-clients/PostOrder.do
with same ActionObject configuration.
 
What would be best solution to make channels work?
 
Should I customize Struts ActionServlet to handle all *.do requests
directory insensitively?
Solution I'm thinking is that where ever directory I call ./PostOrder.do,
ActionServlet would match to /PostOrder.do action object.
 
What would be best way to solve this multichannel problem?
 
 
Best regards,
 
Aki
 

______________________________________________________________________

Aki Salonen 
Wincor Nixdorf Oy 
System Analyst <?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" />

PL 160,  02601 ESPOO, Finland 
Visiting adress: Majurinkatu 6 (Perkkaa)                
( Phone, direct: +358 10 511 5183,   Switch board: +358 10 511 4040 
2  Fax: +358 10 511 5502 
*  e-mail: < mailto:aki.salonen@wincor-nixdorf.com
<ma...@wincor-nixdorf.com> > 
web: http://www.wincor-nixdorf.com <http://www.wincor-nixdorf.com/>  

 

Re: Multichannel support with Struts

Posted by Ted Husted <hu...@apache.org>.
While the Struts Action paths may look like directory references, they
are really a flat name with no understanding of the conventional file
hierarchies.  Relative references like ../ or ./ aren't supported as
such. They are just treated like names that start with a dot. So, it may
not be a case insensivity issue, but a misunderstanding of how Struts
parses Action paths (it doesn't parse them at all).

What you really might want to do is adjust the ActionForwards
dynamically, depending on what client is being used. 

If your JSP structures are otherwise identical, then you could do
something like this at the end of an Action. 

        StringBuffer buffer = new
StringBuffer(getClientPrefix(request));

        ActionForward forward = mapping.findForward("continue");

        buffer.append(forward.getPath());

        return new ActionForward(buffer.toString(),);

Where getClientPrevis(request) is some sort of helper that returns 

/www-clients
/wap-clients
/xml-clients

as appropriate for the client session. 

If this were being done, you would probably want to make it standard
method on a base Action, so that all you had to do in a given Action as
call something like 

return getForward(request,"continue");

which would encapsulate the above. 

If the JSP page treees are less than identical, you can create separate
paths for each client in the Struts config, and then reuse the Action
classes in the Action Mappings. 

            <action 
                path="/wap-clients/Detail"
                type="app.Detail"

		....

                <forward 
                    name="continue"  
                    path="/wap-clients/Detail.jsp"/> 
            </action>

            <action 
                path="/www-clients/Detail"
                type="app.Detail"

		....

                <forward 
                    name="continue"  
                    path="/www-clients/Detail.jsp"/> 
            </action>


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

"Salonen, Aki" wrote:
> 
> Hello,
> 
> We have been developing web-application needing a multichannel support.
> What I have thought is that we will have different jsp-pages for each
> channel,
> but same action objects.
> 
> So, directory structure would look like this:
> 
> /www-clients/*.jsp pages
> /wap-clients/*.jsp pages
> /xml-clients/*.jsp pages
> 
> Problem I'm facing is that I should have mechanism to set users channel (=
> directory) at login,
> and after that user would be browsing under specified directory.
> 
> This is not possible because ActionMapping configuration is not
> directory insensitive.
> 
> As I have understood, all action mappings in struts-config.xml refer to
> root of application like this;
> /PostOrder.do, /Login.do
> 
> So actually Struts thinks actions are located in root directory.
> I would like to access to same action object from different channels like
> this:
> /www-clients/PostOrder.do
> /wap-clients/PostOrder.do
> with same ActionObject configuration.
> 
> What would be best solution to make channels work?
> 
> Should I customize Struts ActionServlet to handle all *.do requests
> directory insensitively?
> Solution I'm thinking is that where ever directory I call ./PostOrder.do,
> ActionServlet would match to /PostOrder.do action object.
> 
> What would be best way to solve this multichannel problem?
> 
> 
> Best regards,
> 
> Aki
> 
> 
> ______________________________________________________________________
> 
> Aki Salonen
> Wincor Nixdorf Oy
> System Analyst <?xml:namespace prefix = o ns =
> "urn:schemas-microsoft-com:office:office" />
> 
> PL 160,  02601 ESPOO, Finland
> Visiting adress: Majurinkatu 6 (Perkkaa)
> ( Phone, direct: +358 10 511 5183,   Switch board: +358 10 511 4040
> 2  Fax: +358 10 511 5502
> *  e-mail: < mailto:aki.salonen@wincor-nixdorf.com
> <ma...@wincor-nixdorf.com> >
> web: http://www.wincor-nixdorf.com <http://www.wincor-nixdorf.com/>
> 
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>