p:在p:dashboard内重复迭代面板

时间:2016-08-25 07:56:13

标签: jsf-2 primefaces

我使用PF 5.3.5和Mojarra 2.2.8。我正在将ice:panelPositioned组件迁移到Primefaces。

<p:dashboard id="dashboard" model="#{customAttributesSettings.model}" disabled="#{!customAttributesSettings.editable}" styleClass="positionPanelContainer positionPanelBox positionedPanelBoxR">
   <p:ajax event="reorder" listener="#{customAttributesSettings.changed}" update="@form" />
   <p:repeat var="column" value="#{customAttributesSettings.availableColumns}" offset="" size="" step="" varStatus="">
      <p:panel id="locked" header="Locked">
         <p:selectBooleanCheckbox partialSubmit="true" value="#{column.selected}" disabled="#{!customAttributesSettings.editable}" valueChangeListener="#{customAttributesSettings.selectionMade}" />
         <h:outputText value="#{column.name}" style="width: 200px;" disabled="#{!customAttributesSettings.editable}" styleClass="columnName#{column.selected ? '' : 'Dis'}" />
         <p:inputText partialSubmit="true" value="#{column.type.width}" disabled="#{!customAttributesSettings.editable}" />
      </p:panel>
   </p:repeat>
</p:dashboard>

我收到此错误

  

com.sun.faces.application.view.FaceletViewHandlingStrategy.handleRenderException   错误渲染视图[/secure/settings/settings.xhtml]   java.lang.ClassCastException:org.primefaces.component.repeat.UIRepeat   无法转换为org.primefaces.component.panel.Panel at   org.primefaces.component.dashboard.DashboardRenderer.findWidget(DashboardRenderer.java:96)

讨论了p:repeat组件的必需属性。 https://github.com/primefaces/primefaces/issues/1627

它不适用于JSF经典ui:repeat组件。 我该怎么办呢?提前谢谢。

1 个答案:

答案 0 :(得分:1)

p:dashboard(遗憾的是)不知道如何处理ui:repeat作为孩子。您应该使用c:forEach代替ui:repeatc:forEach在视图构建时运行并创建面板,因此在渲染时,p:dashboard只能看到面板。请参阅使用c:foreach ...请参阅JSTL in JSF2 Facelets... makes sense?