You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Michael Borgwardt <br...@brazils-animeland.de> on 2004/12/14 14:12:51 UTC

Using HTML in a page assembled with tiles

Hi,

I'm having a Problem with MyFaces: I use tiles, and whenever I try
to use non-JSF stuff (such as plain HTML) in a page inserted with 
tiles into a "template", it is output at the end, after all the JSF 
stuff. Attempts to use <f:verbatim> around either the <tiles:insert>
tag or in the inserted page around the plain HTML result in a
total mess.

Is it really not possible to use HTML in a tiles page with JSF or
am I doing something wrong?

My code looks like this:

---- test1.jsp ----

<%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %>
<%@ taglib uri="/WEB-INF/tld/struts-tiles.tld"  prefix="tiles" %>
<html>
<f:view> 
<head>
  <title>Test</title>
</head>
  <body>
	  <f:subview id="content">
      <tiles:insert attribute="content" flush="false"/>
	  </f:subview>
  </body>
</f:view>
</html>

---- test2.jsp ----

<%@ taglib uri="/WEB-INF/tld/myfaces_html.tld" prefix="h" %>
<%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %>

<h1><h:outputText style="font-size:16px" value="Test"/></h1>

---- tiles.xml excerpt ----
 
    <definition name="/tilesTest.tiles" path="/test1.jsp">
        <put name="content"   value="/test2.jsp" />
    </definition>

---- output when requesting tilesTest.faces ----


<html> 
<head>
  <title>Test</title>
</head>
  <body>	  
      <span style="font-size:16px">Test</span>

<h1></h1>

  </body>
</html>

--------

But of course I'd like the text to appear between the <h1> tags.




Michael Borgwardt





Re: Using HTML in a page assembled with tiles

Posted by Michael Borgwardt <br...@brazils-animeland.de>.
On Tue, 14 Dec 2004, Heath Borders wrote:

> Generally, our solution has been to use more verbatims, not less.
> 
> I try to have every piece of plain text wrapped in a verbatim tag if I
> can (and I think we do).


That's exactly what I tried, and you saw the result: total garbage.

-- 
Michael Borgwardt


RE: Using HTML in a page assembled with tiles

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Heath, yes
that is that what I am doing too

<f:verbatim><br/></f:verbatim>

but sometimes I use
<h:outputText value="<h1>foo-bar</h1>" escape="false"/>

regards,
matthias

> -----Original Message-----
> From: Heath Borders [mailto:heath.borders@gmail.com] 
> Sent: Tuesday, December 14, 2004 5:42 PM
> To: MyFaces Discussion
> Subject: Re: Using HTML in a page assembled with tiles
> 
> 
> Generally, our solution has been to use more verbatims, not less.
> 
> I try to have every piece of plain text wrapped in a verbatim 
> tag if I can (and I think we do).
> 
> 
> On Tue, 14 Dec 2004 16:58:29 +0100 (CET), Michael Borgwardt 
> <br...@brazils-animeland.de> wrote:
> > On Tue, 14 Dec 2004, Heath Borders wrote:
> > 
> > > A rule of thumb is that if you have any non-tag content (i.e. 
> > > plaintext, html) inside a jsf tag it needs to go in a verbatim.
> > 
> > According to the "Core JavaServer Faces" book, this is only 
> true for 
> > jsf tags that render their children, which is the case only 
> for a few 
> > JSF-HTML tags.
> > 
> > > >From your example, it looks like you should have:
> > >
> > > <%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %> <%@ 
> > > taglib uri="/WEB-INF/tld/struts-tiles.tld"  
> prefix="tiles" %> <html>
> > > <f:view>
> > > <f:verbatim>
> > > <head>
> > >  <title>Test</title>
> > 
> > No, the HTML is the tiles template is being rendered just 
> fine without 
> > any use of <f:verbatim>, it's the *inserted* page where it doesn't 
> > work. And there, <f:verbatim> just fucks up the result completely, 
> > e.g. if test1.jsp looks like this:
> > 
> > <f:verbatim>
> > <h1>
> > </f:verbatim>
> > <h:outputText style="font-size:16px" value="Test"/> <f:verbatim>
> > </h1>
> > </f:verbatim>
> > 
> > It gets rendered as:
> > 
> > <h1>
> > <span style="font-size:16px">
> > <br/>&lt;h1&gt;
> > <br/></span><span style="font-size:16px">
> > <br/>&lt;/h1&gt;
> > <br/></span>
> > 
> > --
> > Michael Borgwardt
> > 
> > 
> 
> 
> -- 
> -Heath Borders-Wing
> hborders@mail.win.org
> 


Re: Using HTML in a page assembled with tiles

Posted by Heath Borders <he...@gmail.com>.
Generally, our solution has been to use more verbatims, not less.

I try to have every piece of plain text wrapped in a verbatim tag if I
can (and I think we do).


On Tue, 14 Dec 2004 16:58:29 +0100 (CET), Michael Borgwardt
<br...@brazils-animeland.de> wrote:
> On Tue, 14 Dec 2004, Heath Borders wrote:
> 
> > A rule of thumb is that if you have any non-tag content (i.e.
> > plaintext, html) inside a jsf tag it needs to go in a verbatim.
> 
> According to the "Core JavaServer Faces" book, this is only true for
> jsf tags that render their children, which is the case only for
> a few JSF-HTML tags.
> 
> > >From your example, it looks like you should have:
> >
> > <%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %>
> > <%@ taglib uri="/WEB-INF/tld/struts-tiles.tld"  prefix="tiles" %>
> > <html>
> > <f:view>
> > <f:verbatim>
> > <head>
> >  <title>Test</title>
> 
> No, the HTML is the tiles template is being rendered just fine
> without any use of <f:verbatim>, it's the *inserted* page where
> it doesn't work. And there, <f:verbatim> just fucks up the
> result completely, e.g. if test1.jsp looks like this:
> 
> <f:verbatim>
> <h1>
> </f:verbatim>
> <h:outputText style="font-size:16px" value="Test"/>
> <f:verbatim>
> </h1>
> </f:verbatim>
> 
> It gets rendered as:
> 
> <h1>
> <span style="font-size:16px">
> <br/>&lt;h1&gt;
> <br/></span><span style="font-size:16px">
> <br/>&lt;/h1&gt;
> <br/></span>
> 
> --
> Michael Borgwardt
> 
> 


-- 
-Heath Borders-Wing
hborders@mail.win.org

Re: Using HTML in a page assembled with tiles

Posted by Michael Borgwardt <br...@brazils-animeland.de>.
On Tue, 14 Dec 2004, Heath Borders wrote:

> A rule of thumb is that if you have any non-tag content (i.e.
> plaintext, html) inside a jsf tag it needs to go in a verbatim.

According to the "Core JavaServer Faces" book, this is only true for
jsf tags that render their children, which is the case only for
a few JSF-HTML tags.

> >From your example, it looks like you should have:
> 
> <%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %>
> <%@ taglib uri="/WEB-INF/tld/struts-tiles.tld"  prefix="tiles" %>
> <html>
> <f:view>
> <f:verbatim>
> <head>
>  <title>Test</title>

No, the HTML is the tiles template is being rendered just fine
without any use of <f:verbatim>, it's the *inserted* page where
it doesn't work. And there, <f:verbatim> just fucks up the
result completely, e.g. if test1.jsp looks like this:

<f:verbatim>
<h1>
</f:verbatim>
<h:outputText style="font-size:16px" value="Test"/>
<f:verbatim>
</h1>
</f:verbatim>

It gets rendered as:

<h1>
<span style="font-size:16px">
<br/>&lt;h1&gt;
<br/></span><span style="font-size:16px">
<br/>&lt;/h1&gt;
<br/></span>



-- 
Michael Borgwardt


Re: Using HTML in a page assembled with tiles

Posted by Heath Borders <he...@gmail.com>.
A rule of thumb is that if you have any non-tag content (i.e.
plaintext, html) inside a jsf tag it needs to go in a verbatim.
Tiles tags don't need to be wrapped in a verbatim tag as long as
they're contained within the subview tag.  We're using HTML in our
layouts and doing just fine.

>From your example, it looks like you should have:

<%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %>
<%@ taglib uri="/WEB-INF/tld/struts-tiles.tld"  prefix="tiles" %>
<html>
<f:view>
<f:verbatim>
<head>
 <title>Test</title>
</head>
 <body>
</f:verbatim>
         <f:subview id="content">
     <tiles:insert attribute="content" flush="false"/>
         </f:subview>
<f:verbatim>
 </body>
</f:verbatim>
</f:view>
</html>


On Tue, 14 Dec 2004 15:03:43 +0100, Matthias Wessendorf
<ma...@matthias-wessendorf.de> wrote:
> Michael,
> 
> what you could do is:
> <h:outputText style="font-size:16px" value="<h1>Test</h1>"
> escape="false"/>
> 
> HTH,
> Matthias
> 
> > -----Original Message-----
> > From: Michael Borgwardt [mailto:brazil@brazils-animeland.de]
> > Sent: Tuesday, December 14, 2004 2:13 PM
> > To: myfaces-user@incubator.apache.org
> > Subject: Using HTML in a page assembled with tiles
> >
> >
> > Hi,
> >
> > I'm having a Problem with MyFaces: I use tiles, and whenever
> > I try to use non-JSF stuff (such as plain HTML) in a page
> > inserted with
> > tiles into a "template", it is output at the end, after all the JSF
> > stuff. Attempts to use <f:verbatim> around either the
> > <tiles:insert> tag or in the inserted page around the plain
> > HTML result in a total mess.
> >
> > Is it really not possible to use HTML in a tiles page with
> > JSF or am I doing something wrong?
> >
> > My code looks like this:
> >
> > ---- test1.jsp ----
> >
> > <%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %>
> > <%@ taglib uri="/WEB-INF/tld/struts-tiles.tld"
> > prefix="tiles" %> <html> <f:view>
> > <head>
> >   <title>Test</title>
> > </head>
> >   <body>
> >         <f:subview id="content">
> >       <tiles:insert attribute="content" flush="false"/>
> >         </f:subview>
> >   </body>
> > </f:view>
> > </html>
> >
> > ---- test2.jsp ----
> >
> > <%@ taglib uri="/WEB-INF/tld/myfaces_html.tld" prefix="h" %>
> > <%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %>
> >
> > <h1><h:outputText style="font-size:16px" value="Test"/></h1>
> >
> > ---- tiles.xml excerpt ----
> >
> >     <definition name="/tilesTest.tiles" path="/test1.jsp">
> >         <put name="content"   value="/test2.jsp" />
> >     </definition>
> >
> > ---- output when requesting tilesTest.faces ----
> >
> >
> > <html>
> > <head>
> >   <title>Test</title>
> > </head>
> >   <body>
> >       <span style="font-size:16px">Test</span>
> >
> > <h1></h1>
> >
> >   </body>
> > </html>
> >
> > --------
> >
> > But of course I'd like the text to appear between the <h1> tags.
> >
> >
> >
> >
> > Michael Borgwardt
> >
> >
> >
> >
> 
> 


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org

RE: Using HTML in a page assembled with tiles

Posted by Michael Borgwardt <br...@brazils-animeland.de>.
On Tue, 14 Dec 2004, Matthias Wessendorf wrote:

> what you could do is:
> <h:outputText style="font-size:16px" value="<h1>Test</h1>"
> escape="false"/>

Yes, that's what I'm doing for now, but it's not a viable solution
for all but the most simple pages.

-- 
Michael Borgwardt


RE: Using HTML in a page assembled with tiles

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Michael,

what you could do is:
<h:outputText style="font-size:16px" value="<h1>Test</h1>"
escape="false"/>

HTH,
Matthias

> -----Original Message-----
> From: Michael Borgwardt [mailto:brazil@brazils-animeland.de] 
> Sent: Tuesday, December 14, 2004 2:13 PM
> To: myfaces-user@incubator.apache.org
> Subject: Using HTML in a page assembled with tiles
> 
> 
> Hi,
> 
> I'm having a Problem with MyFaces: I use tiles, and whenever 
> I try to use non-JSF stuff (such as plain HTML) in a page 
> inserted with 
> tiles into a "template", it is output at the end, after all the JSF 
> stuff. Attempts to use <f:verbatim> around either the 
> <tiles:insert> tag or in the inserted page around the plain 
> HTML result in a total mess.
> 
> Is it really not possible to use HTML in a tiles page with 
> JSF or am I doing something wrong?
> 
> My code looks like this:
> 
> ---- test1.jsp ----
> 
> <%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %> 
> <%@ taglib uri="/WEB-INF/tld/struts-tiles.tld"  
> prefix="tiles" %> <html> <f:view> 
> <head>
>   <title>Test</title>
> </head>
>   <body>
> 	  <f:subview id="content">
>       <tiles:insert attribute="content" flush="false"/>
> 	  </f:subview>
>   </body>
> </f:view>
> </html>
> 
> ---- test2.jsp ----
> 
> <%@ taglib uri="/WEB-INF/tld/myfaces_html.tld" prefix="h" %> 
> <%@ taglib uri="/WEB-INF/tld/myfaces_core.tld" prefix="f" %>
> 
> <h1><h:outputText style="font-size:16px" value="Test"/></h1>
> 
> ---- tiles.xml excerpt ----
>  
>     <definition name="/tilesTest.tiles" path="/test1.jsp">
>         <put name="content"   value="/test2.jsp" />
>     </definition>
> 
> ---- output when requesting tilesTest.faces ----
> 
> 
> <html> 
> <head>
>   <title>Test</title>
> </head>
>   <body>	  
>       <span style="font-size:16px">Test</span>
> 
> <h1></h1>
> 
>   </body>
> </html>
> 
> --------
> 
> But of course I'd like the text to appear between the <h1> tags.
> 
> 
> 
> 
> Michael Borgwardt
> 
> 
> 
>