阅读this answer后,我仍然难倒。我同意应该避免使用JSTL,并理解它的评估是如何在错误的阶段发生的。但是,根据facelets开发站点上的documentation,<ui:fragment>
标签似乎只支持两个属性,即id
和binding
。所以,即使一些实现支持rendered
,看起来你也会试图利用它。另一个建议是使用<h:panelGroup>
,但是,在响应中插入<div>
元素可能会导致不良副作用(如将内容从内联更改为块)。有没有人知道解决这个问题的方法?特别是,我试图如下:Facelet自定义组件 - 防止渲染
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition>
<ice:selectOneListbox binding="#{binding}" rendered="#{modeExisting}">
<f:selectItems
value="#{binding.allTagsSelectItems}" />
</ice:selectOneListbox>
<ice:inputText binding="#{binding.name}" />
<ice:inputText binding="#{binding.description}" />
</ui:composition>
</html>
这基本上是用来选择与选择时,将允许用户编辑它们的名称和描述元素的列表框。我可以在该块周围放置一个<ice:panelGroup>
,并使用它的呈现属性,但同样可能会有注入额外div的副作用。有什么办法可以做到这一点?
而且,它可能是值得一提的是,我使用这个的facelet-标签库配对上面的自定义组件:
<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>http://www.mitre.org/asias/jsf</namespace>
<tag>
<tag-name>configurationTagEditor</tag-name>
<source>../component/configurationTagEditor.xhtml</source>
</tag>
<tag>
<tag-name>configurationTagSelector</tag-name>
<source>../component/configurationTagSelector.xhtml</source>
</tag>
<tag>
<tag-name>configurationTagRegexTable</tag-name>
<source>../component/configurationTagRegexTable.xhtml</source>
</tag>
</facelet-taglib>
,让我在我的JSF XHTML使用:
...
<ice:panelTab label="Existing" styleClass="configurationTagsExisting">
<m:configurationTagEditor tag="#{configuration.existingTag}" />
</ice:panelTab>
...
谢谢,我不知道。我的参考资料是直接使用Icefaces而不是JSF的,而相应panelGroup元素的icefaces文档则说:“panelGroup组件在它的子组件周围呈现一个”div“元素,输出”style“属性的值作为“style”属性和“styleClass”属性的值作为“class”属性的值。“再次,谢谢,我将使用JSF panelGroup来达到此目的。 – Lucas 2010-12-03 18:59:55