混合JSF标记和HTML [英] Mixing JSF Tag and HTML
问题描述
我刚开始使用JSF 2.0,但发现自己将JSF标签与标准HTML标签混合使用 以实现所需的布局. 尽管我使用facelets来布局页面,但我认为我不禁要混合使用组件.
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
推荐答案
这不是一个坏习惯.很好使用JSF组件的唯一原因是可以在JSF组件树中对其进行访问.在这里使用<h:panelGroup layout="block">
而不是<div>
会是更糟糕的做法.但是,如果要使用容器对其进行内容进行Ajax更新,那么<h:panelGroup id="foo" layout="block">
和带有xmlns:jsf="http://xmlns.jcp.org/jsf"
命名空间的"html5友好型" <div jsf:id="foo">
一样好.
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?
这篇关于混合JSF标记和HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!