Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixing JSF Tag and HTML

Tags:

jsf-2

I just started out using JSF 2.0 but I found myself mixing JSF tags with standard HTML tag to achieve the desired layout. Although I am using the facelets to layout my pages, but I think I cant help but mix components.

<ui:define name="content">
    <h:form>
        <h:commandButton value="Search" action="#{myBean.handleSearch}"/>
        <h:commandButton value="Reset" action="#{myBean.handleReset}"/>
        <div>
            <!-- Some JSF component -->
        </div>

I have been thinking if I have been running into bad practice. Any source of info for this? Thanks

like image 421
Mark Estrada Avatar asked Sep 14 '11 15:09

Mark Estrada


1 Answers

This is not a bad practice. This is perfectly fine. The only reason to use a JSF component is to have access to it in the JSF component tree. It would be a more poor practice to use <h:panelGroup layout="block"> instead of <div> here. But if it was a container of which you'd like to ajax-update its content, then a <h:panelGroup id="foo" layout="block"> would have been perfectly fine as would an 'html5-friendly' <div jsf:id="foo"> with the xmlns:jsf="http://xmlns.jcp.org/jsf" namespace.

For a bit of history, you may find this useful: JSF vs HTML(JSP) for enterprise portals UI layer. Which one to Choose? and WHY?

like image 53
BalusC Avatar answered Oct 19 '22 15:10

BalusC