【发布时间】:2013-09-17 13:23:52
【问题描述】:
我正在尝试使用 icefaces 1.8 在 UI 片段中添加 JSF selectOneMenu,并且无论我做什么都无法渲染它。我可以让它在普通的 jspx 页面中呈现,但不能在 ui 片段中呈现。
<ui:fragment xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ice="http://www.icesoft.com/icefaces/component">
<ice:selectOneMenu id="myselect"
style="width:100px"
value="#{someField}"
rendered="true">
<f:selectItem itemValue="1" itemLabel="1"/>
<f:selectItem itemValue="2" itemLabel="2"/>
<f:selectItem itemValue="3" itemLabel="3"/>
</ice:selectOneMenu>
</ui:fragment>
我错过了一些基本的东西吗?我是 JSF 的新手。如果我将完全相同的 selectOneMenu 拉出到 jspx 中,它应该可以正常工作,但是当我包含一个 ui 片段时它不会。
编辑 BalusC:
该片段稍后在使用
拉入的 jspx 文件中使用<ui:include src="myfile.jspx">
<ui:param name="someField" value="#{beanName.someField}"
</ui:include>
我要离开现有的 .包含中还有更多内容可以按预期工作,我可以将 outputText 等其他组件添加到 ui:fragment 中,但它没有任何区别。完整片段如下。我也可以从 jspx 发布完整的包含。
<ui:fragment xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ice="http://www.icesoft.com/icefaces/component">
<ice:panelGrid cellspacing="0" cellpadding="0" columns="3">
<!-- This component is displayed when the form is opened for editing or display mode-->
<ice:panelGroup rendered="#{not beanName.outputOnlyView }">
<!-- This component is displayed when the form is opened for display mode in EDM stage-->
<ice:panelGroup rendered="#{beanName.displayMode}">
<ice:outputText
id="#{fieldId }"
style="#{inlineStyleField}"
value="#{fieldValue}" >
</ice:outputText>
</ice:panelGroup>
<ice:selectOneMenu id="myselect"
style="width:100px"
value="#{someField}"
rendered="#{not beanName.outputOnlyView}">
<f:selectItem itemValue="IntranetID" itemLabel="Intranet ID"/>
<f:selectItem itemValue="Name" itemLabel="Last Name, First Name"/>
<f:selectItem itemValue="KnownAs" itemLabel="Known As"/>
</ice:selectOneMenu>
<!-- This component is displayed when the form is opened for editing mode in Submitter stage-->
<ice:panelGroup rendered="#{!beanName.displayMode}" panelTooltip="#{fieldId}Help">
<ice:panelGrid style="#{inlineStyle}" cellspacing="0" cellpadding="0" columns="3">
<!-- Column 1 the component -->
<ice:selectInputText id="#{fieldId }"
binding="#{feildBinding}"
options="{frequency:0.4}"
rows="20"
width="100"
partialSubmit="true"
immediate="true"
autocomplete="true"
value="#{fieldValue}"
rendered="#{not beanName.outputOnlyView}"
readonly="#{beanName.globalReadOnly }"
listVar="employee"
listValue="#{beanName[employeeSelect].employeeNamePossibilities}"
valueChangeListener="#{beanName[valueChangeListener] }"
textChangeListener="#{beanName[textChangeListener]}">
<f:facet name="selectInputText">
<ice:panelGrid columns="1">
<ice:panelGrid columns="2" columnClasses="searchCol1,searchCol2">
<ice:outputText id="name" value="#{employee.name}"/>
<ice:outputText id="email" value="#{employee.email}"/>
</ice:panelGrid>
<ice:panelGrid columns="3" columnClasses="searchCol4,searchCol3,searchCol5">
<ice:outputText id="function" value="#{employee.function}"/>
<ice:outputText id="subfunction" value="#{employee.subfunction}"/>
<ice:outputText id="stat1" value="#{employee.stat1}"/>
</ice:panelGrid>
</ice:panelGrid>
</f:facet>
</ice:selectInputText>
<!-- Column 2: Error Messages for this component -->
<ice:message style="color:red;" id="#{fieldId}Error" for="#{fieldId}" showDetail="true"/>
<!-- Column 3: HoverHelp if required -->
<ui:include src="../inc-components-pcr/sub-components-pcr/hoverHelpColumnAndTooltip.jspx"/>
</ice:panelGrid>
</ice:panelGroup>
</ice:panelGroup>
</ice:panelGrid>
</ui:fragment>
【问题讨论】:
-
你最终是如何使用这个片段的?您究竟是从哪里了解到以这种方式编写代码的?如果您还没有基本概念和术语,请以复制'n'paste'n'runnable SSCCE 的形式发布问题。
-
嗨 BalusC。请看编辑。最终,片段被拉成更大的形式。使用片段以便我们可以进行标准的自动完成搜索。我只是想在同一行的自动完成搜索中添加一个下拉列表。
-
您使用
<ui:fragment>而不是<ui:composition>的确切原因是什么,如 Facelets 文档和所有健全的 Facelets 教程中所示? -
我正在使用已经存在的东西。将其更改为 ui:composition 有同样的问题。
-
遇到了一个可能有帮助的有趣问题。我在我的 jspx 的多个地方使用这个 facelet。在一部分中,它是隐藏的,除非用户在单选按钮上进行选择,然后才会显示。在这种情况下, selectOneMenu 会按预期显示。这是渲染问题吗?
标签: jsf rendering fragment icefaces selectonemenu