You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Chrisi <ne...@googlemail.com> on 2006/05/21 15:50:09 UTC

Mixing plain HTML and JSF-Tags

Hi Gerald,

you wrote:

> It`s not best practice to have jsf corresponding tags and
> plain html on the same page ...

Sure, it would be nice to have jsf pages without plain html.
But in reallity this wouldn't happen:

In 90% of the projects I know, HTML is delivered from web-designer experts.
Those people don't know about JSF and components. And I think they
don't have to.
In real projects this HTML is taken as the view component and the
developer enhances the view with bean values and some navigation
rules.
But it isn't practical to force the developer to remap all the HTML
into JSF components (and for complex HTML this doesn't really work).

When looking at JSF example-applications I always see mixing of plain
html and JSF components. It works for f:view.
The question is: Why doesn't it work for f:subview?  Is there a
workaround without wrapping anything in jsf-tags or using facelets?

Greetings
Chrisi


On 5/20/06, Gerald Müllan <bi...@gmail.com> wrote:
> Hi,
>
> I see the main problem in this that you mix up jsf presentation with
> html markup. It`s not best practice to have jsf corresponding tags and
> plain html on the same page. Try where ever possible to use only jsf
> related stuff.
>
> Normally it should be possible to get along with your requirements
> when doing it like this.
> If not, you can also use tomahawks <t:html> component. Furthermore
> <t:document> can help out.
>
> Apart from your problem, doing it like this makes you independent from
> html renderkit.
>
> cheers,
>
> Gerald
>
> On 5/20/06, Chrisi <ne...@googlemail.com> wrote:
> > Hi Andrew,
> >
> > thanks for response.
> > It's a pitty.  We can't use facelets in our project currently.
> >
> > There must be a way to use subviews without messing the things up
> > without using facelets, or?
> >
> > On 5/20/06, Andrew Robinson <an...@gmail.com> wrote:
> > > Facelets.
> > >
> > > Does includes very nicely (no subviews), is faster than JSP and you
> > > don't need verbatim tags.
> > >
> > > On 5/20/06, Chrisi <ne...@googlemail.com> wrote:
> > > > Hello,
> > > >
> > > > I'm driving crazy with myfaces:
> > > >
> > > > I've got an JSF page with the following content:
> > > >
> > > > <p>
> > > > Some HTML tags and text
> > > > </p>
> > > > <h:outputText value="And here JSF text" />
> > > >
> > > > Let it run and you see
> > > > "
> > > > Some HTML tags and text
> > > > And here JSF text
> > > > "
> > > > on your browser. That's ok!
> > > >
> > > >
> > > > Now I wanna make some refactoring and like to put the
> > > > content into a subview. The content from above is inlcuded als follow:
> > > >
> > > > <f:subview id="test">
> > > >         <jsp:include page="test.jsp" />
> > > >   </f:subview>
> > > >
> > > > I let it run again and you see the output messed up (lines are not in order):
> > > > "
> > > > And here JSF text
> > > > Some HTML tags and text
> > > > "
> > > >
> > > > When putting <f:verbatim> or <t:htmlTag> around the HTML in the
> > > > subview it seems to work.
> > > > But that's no adequate way. It messes up you view-code and makes it unreadable!
> > > >
> > > > Why is there a different behavior in subview vs. views?
> > > >
> > > > What is the way to go?????
> > > >
> > > >
> > > >
> > > > Thanks and Greetings
> > > > Chrisi
> > > >
> > >
> >
> >
> > --
> > Thanks and Greetings
> > Chrisi
> >
>
>
> --
> Gerald Müllan
> Schelleingasse 2/11
> 1040 Vienna, Austria
> 0043 699 11772506
> Bierbrauen@gmail.com
>

Re: Mixing plain HTML and JSF-Tags

Posted by Kevin Galligan <ma...@kgalligan.com>.
You may be in the market for facelets.  See the following...

https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-use-jsfc

It is possible to map simple input elements to jsf ui objects, but keeping
standard html syntax.  I haven't personally used this, and I assume it
wouldn't work for more complex objects, but its something to look at.

You might be able to use composition in facelets for more complex
situations.  For example, lets say you wanted a table in the page.  I don't
imagine the table tag and the panelGrid objects play well together with the
jsfc attribute, but you could have the following on the page...

<html xmlns:h="http://java.sun.com/jsf/html" xmlns:f="
http://java.sun.com/jsf/core">
(etc)...
<ui:insert name="customTable">
      <table>
            <tr><td>This is a sample name</td><td><input type="text"
value="This is a sample input object"/></td></tr>
      </table>
</ui:insert>
(more fluff)...
</html>

This could be on the "template" version of the page that a designer would
create.  You'd have to train them to work around the 'ui:insert' tag.  But I
think that would be it.  The "real" page would just be...

<html xmlns:h="http://java.sun.com/jsf/html" xmlns:f="
http://java.sun.com/jsf/core">
<ui:composition template="[point to template above]">
      <ui:define name="customTable">
         <h:panelGrid width="100%" columns="2">
        <h:panelGroup>
            NOT a sample name
        </h:panelGroup>
        <h:panelGroup>
            <h:inputText value="NOT a sample value"/>
        </h:panelGroup>
      </ui:define>
</ui:composition>
</html>

On 5/21/06, Chrisi <ne...@googlemail.com> wrote:
>
> Hi Gerald,
>
> you wrote:
>
> > It`s not best practice to have jsf corresponding tags and
> > plain html on the same page ...
>
> Sure, it would be nice to have jsf pages without plain html.
> But in reallity this wouldn't happen:
>
> In 90% of the projects I know, HTML is delivered from web-designer
> experts.
> Those people don't know about JSF and components. And I think they
> don't have to.
> In real projects this HTML is taken as the view component and the
> developer enhances the view with bean values and some navigation
> rules.
> But it isn't practical to force the developer to remap all the HTML
> into JSF components (and for complex HTML this doesn't really work).
>
> When looking at JSF example-applications I always see mixing of plain
> html and JSF components. It works for f:view.
> The question is: Why doesn't it work for f:subview?  Is there a
> workaround without wrapping anything in jsf-tags or using facelets?
>
> Greetings
> Chrisi
>
>
> On 5/20/06, Gerald Müllan <bi...@gmail.com> wrote:
> > Hi,
> >
> > I see the main problem in this that you mix up jsf presentation with
> > html markup. It`s not best practice to have jsf corresponding tags and
> > plain html on the same page. Try where ever possible to use only jsf
> > related stuff.
> >
> > Normally it should be possible to get along with your requirements
> > when doing it like this.
> > If not, you can also use tomahawks <t:html> component. Furthermore
> > <t:document> can help out.
> >
> > Apart from your problem, doing it like this makes you independent from
> > html renderkit.
> >
> > cheers,
> >
> > Gerald
> >
> > On 5/20/06, Chrisi <ne...@googlemail.com> wrote:
> > > Hi Andrew,
> > >
> > > thanks for response.
> > > It's a pitty.  We can't use facelets in our project currently.
> > >
> > > There must be a way to use subviews without messing the things up
> > > without using facelets, or?
> > >
> > > On 5/20/06, Andrew Robinson <an...@gmail.com> wrote:
> > > > Facelets.
> > > >
> > > > Does includes very nicely (no subviews), is faster than JSP and you
> > > > don't need verbatim tags.
> > > >
> > > > On 5/20/06, Chrisi <ne...@googlemail.com> wrote:
> > > > > Hello,
> > > > >
> > > > > I'm driving crazy with myfaces:
> > > > >
> > > > > I've got an JSF page with the following content:
> > > > >
> > > > > <p>
> > > > > Some HTML tags and text
> > > > > </p>
> > > > > <h:outputText value="And here JSF text" />
> > > > >
> > > > > Let it run and you see
> > > > > "
> > > > > Some HTML tags and text
> > > > > And here JSF text
> > > > > "
> > > > > on your browser. That's ok!
> > > > >
> > > > >
> > > > > Now I wanna make some refactoring and like to put the
> > > > > content into a subview. The content from above is inlcuded als
> follow:
> > > > >
> > > > > <f:subview id="test">
> > > > >         <jsp:include page="test.jsp" />
> > > > >   </f:subview>
> > > > >
> > > > > I let it run again and you see the output messed up (lines are not
> in order):
> > > > > "
> > > > > And here JSF text
> > > > > Some HTML tags and text
> > > > > "
> > > > >
> > > > > When putting <f:verbatim> or <t:htmlTag> around the HTML in the
> > > > > subview it seems to work.
> > > > > But that's no adequate way. It messes up you view-code and makes
> it unreadable!
> > > > >
> > > > > Why is there a different behavior in subview vs. views?
> > > > >
> > > > > What is the way to go?????
> > > > >
> > > > >
> > > > >
> > > > > Thanks and Greetings
> > > > > Chrisi
> > > > >
> > > >
> > >
> > >
> > > --
> > > Thanks and Greetings
> > > Chrisi
> > >
> >
> >
> > --
> > Gerald Müllan
> > Schelleingasse 2/11
> > 1040 Vienna, Austria
> > 0043 699 11772506
> > Bierbrauen@gmail.com
> >
>