【问题标题】:P:dataTable sorting does not work in ui:decorateP:dataTable 排序在 ui:decorate 中不起作用
【发布时间】:2017-10-17 22:07:06
【问题描述】:

p:datatable 在独立环境下工作正常,但不适用于这种情况: (我正在使用Primefaces 6.1mojarra 2.2.9

index.xhtml代码:

<h:body>
    <ui:decorate template="/main.xhtml">
        <ui:define name="wrapper">
            <c:if test="#{not empty param['action']}">
               <ui:include src="/templates/param['action'].xhtml" />
            </c:if>
        </ui:define>
    </ui:decorate>
</h:body>

param['action'] 的值为wrapper.xhtml 代码:

<body>
    <ui:composition>
            <h:form>
                <p:dataTable var="menu" value="#{customerBean.listMenu}"
                    rowKey="#{menu.menuId}" selectionMode="single">
                    <f:facet name="header">
                         TEST
                    </f:facet>
                    <p:column headerText="Id" sortBy="#{menu.menuId}">
                        <h:outputText value="#{menu.menuId}" />
                    </p:column>
                    <p:column headerText="Action" sortBy="#{menu.name}">
                        <h:outputText value="#{menu.name}" />
                    </p:column>
                </p:dataTable>
            </h:form>
    </ui:composition>
</body>

java代码:

@ManagedBean(name="customerBean")
@RequestScoped
public class CustomerBean {
    @ManagedProperty("#{listMenu}")
    private List<Test> listMenu;

    @PostConstruct
    public void init(){
        listMenu = new ArrayList<Test>();
        listMenu.add(new Test("123","Test","A1"));
        listMenu.add(new Test("124","Test2","A12"));
        listMenu.add(new Test("125","Test3","A13"));
    }

    public List<Test> getListMenu() {
        if(listMenu == null){
            init();
        }
        return listMenu;
    }

    public void setListMenu(List<Test> listMenu) {
        this.listMenu = listMenu;
    } 
}

当我删除 &lt;c:if test="#{not empty param['action']}"&gt; 并硬编码 /templates/wrapper.xhtml 时,它可以正常工作。

有没有遗漏的步骤?

任何建议都将不胜感激,感谢您的阅读。

【问题讨论】:

    标签: jsf primefaces


    【解决方案1】:

    我不知道为什么,但是当我将 &lt;c:if test="#{not empty param['action']}"&gt; 替换为 p:panel 时,它工作正常!

    【讨论】:

      猜你喜欢
      • 2013-11-20
      • 2013-07-19
      • 1970-01-01
      • 2013-08-09
      • 2016-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多