You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Manuel Vilar <mv...@neocom.fr> on 2002/04/18 16:55:27 UTC

TILES : Dealing with Channel and contentType

Hello all of you !

I am new user with struts & tiles !

My question is quite basic :

I want to use tiles channels mechanism to handle two clients medias. "html"
and "vdxml"
( "vdxml" is a french specific media language, but in this example we could
have spoke about "wml"  instead )

My fisrt web application called page is "index.jsp"  :
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="comp" %>
<comp:insert definition="mainLayout" flush="false" />

I touched the Tiles "ChannelFactorySet.java" (which extends FactorySet.java)
to select the good channel when
getDefinitionsFactoryKey()  is involved. In the function, if the key is not
defined (channel key) I analyse the request
header "user-agent" to tell the function which "user-agent" respective key
to use and to set.

I defined the two component definitions files :
ComponentDefinitions_html.xml
ComponentDefinitions_vdxml.xml

Each definition file contains a  "mainLayout" definition with the path
setted to the media oriented respective "Layout.jsp" :

In ComponentDefinitions_html.xml :
<definition name="mainLayout" path="/html/Layout.jsp">
</definition>
where "/html/Layout.jsp" contains :
	<HTML>
		...some html code here...
	</HTML>

In ComponentDefinitions_vdxml.xml :
<definition name="mainLayout" path="/vdxml/Layout.jsp">
</definition>

where "/html/Layout.jsp" contains :
<?xml version="1.0" encoding="ISO-8859-1" ?><%@ page
contentType="text/vdxml" %>
<!DOCTYPE VDXML SYSTEM "C:\J2EE\FlirtDev\vdxml.dtd">
<VDXML>
	... some vdxml code here ...
</VDXML>

It works fine with html media. ( Internet Explorer )
But with vdxml, the media browser ( vdxml Browser ) indicates that it
received a wrong contentType ("text/html" ).
Of course it would have received the "text/vdxml" contentType defined in the
"/vdxml/Layout.jsp".

I certainly missed something. Can any one help me ?

Thanks in advance,

Manuel ( A new french developper in J2EE world but an old one in C++ )

P.S.
If you read this, I appologize because of borrowing you with quite novice
question !
You certainly guess that I am not used to English, sorry about that, but I
promise I will practice more !




Manuel Vilar
Service developpement
01 45 15 03 32



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


Re: TILES : Dealing with Channel and contentType

Posted by Cedric Dumoulin <ce...@lifl.fr>.
  Hello,

  Look like your contentType directive is not taken into account !
Playing a little bit with the directive, it appear that it is  taken into
account only if set in the first jsp page encountered. In your example, you have
put it in the layout.jsp, which I suppose is inserted from another page (like
index.jsp). So, layout.jsp is your second page encountered ;-( .
  Maybe you can try to use struts action as entry point. Your Struts actions
forward to a definition inserting appropriate layout.jsp.

  Hope this help,

     Cedric

P.S. : Such question may better be asked in struts-user list

Manuel Vilar wrote:

> Hello all of you !
>
> I am new user with struts & tiles !
>
> My question is quite basic :
>
> I want to use tiles channels mechanism to handle two clients medias. "html"
> and "vdxml"
> ( "vdxml" is a french specific media language, but in this example we could
> have spoke about "wml"  instead )
>
> My fisrt web application called page is "index.jsp"  :
> <%@ taglib uri="/WEB-INF/tiles.tld" prefix="comp" %>
> <comp:insert definition="mainLayout" flush="false" />
>
> I touched the Tiles "ChannelFactorySet.java" (which extends FactorySet.java)
> to select the good channel when
> getDefinitionsFactoryKey()  is involved. In the function, if the key is not
> defined (channel key) I analyse the request
> header "user-agent" to tell the function which "user-agent" respective key
> to use and to set.
>
> I defined the two component definitions files :
> ComponentDefinitions_html.xml
> ComponentDefinitions_vdxml.xml
>
> Each definition file contains a  "mainLayout" definition with the path
> setted to the media oriented respective "Layout.jsp" :
>
> In ComponentDefinitions_html.xml :
> <definition name="mainLayout" path="/html/Layout.jsp">
> </definition>
> where "/html/Layout.jsp" contains :
>         <HTML>
>                 ...some html code here...
>         </HTML>
>
> In ComponentDefinitions_vdxml.xml :
> <definition name="mainLayout" path="/vdxml/Layout.jsp">
> </definition>
>
> where "/html/Layout.jsp" contains :
> <?xml version="1.0" encoding="ISO-8859-1" ?><%@ page
> contentType="text/vdxml" %>
> <!DOCTYPE VDXML SYSTEM "C:\J2EE\FlirtDev\vdxml.dtd">
> <VDXML>
>         ... some vdxml code here ...
> </VDXML>
>
> It works fine with html media. ( Internet Explorer )
> But with vdxml, the media browser ( vdxml Browser ) indicates that it
> received a wrong contentType ("text/html" ).
> Of course it would have received the "text/vdxml" contentType defined in the
> "/vdxml/Layout.jsp".
>
> I certainly missed something. Can any one help me ?
>
> Thanks in advance,
>
> Manuel ( A new french developper in J2EE world but an old one in C++ )
>
> P.S.
> If you read this, I appologize because of borrowing you with quite novice
> question !
> You certainly guess that I am not used to English, sorry about that, but I
> promise I will practice more !
>
> Manuel Vilar
> Service developpement
> 01 45 15 03 32
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


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