commandLink仅适用于h和p版本

时间:2016-04-05 06:01:57

标签: jsf glassfish-4 commandlink

我遇到这个非常奇怪的问题,如果我在同一个视图中有两个链接,我的commandLink才有效。

工作正常,两个链接:

<ui:composition template="../../template.xhtml" xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://xmlns.jcp.org/jsf/html"
            xmlns:p="http://primefaces.org/ui"
            xmlns:f="http://xmlns.jcp.org/jsf/core"
            xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <ui:define name="content">
        <h:form>
            <p:dataTable var="v" value="#{myBean.myList}">
                <p:column headerText="Name">
                    <h:commandLink value="Go to next page" action="#{myBean.doThing(v)}" />
                    <p:commandLink value="Go to next page" action="#{myBean.doThing(v)}" />
                </p:column>
            </p:dataTable>
            <p:commandButton value="Submit" ajax="false" actionListener="#{myBean.submit}" />
        </h:form>
    </ui:define>
</ui:composition>

但是,如果删除任一链接,它甚至都无法访问方法doThing()并重新加载空页。

我的豆子:

@ManagedBean(name="myBean")
@RequestScoped
public class MyBean {
    private List<Object> myList = new ArrayList<>();
    public MyBean() {
    }

    public String doThing(Object obj) {
        // This never prints if I remove one of the links
        System.out.println("You're doing the thing!");
        return "nextView?faces-redirect=true"
    }

    // Getters, setters etc.
}

我正在使用JSF 2.0和GlassFish 4.0。

我该如何解决这个问题?为什么会这样?

我在另一个视图中的commandLink中有一个p:dataTable,它运行正常。

编辑:

为视图的组合部分添加了完整的XML。部分位于模板内:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head>
        <!-- css imports, titles etc -->
    </h:head>
    <h:body>
        <ui:insert name="menu">
            <ui:include src="./default/content.xhtml" />
        </ui:insert>
    </h:body>
</html>

0 个答案:

没有答案
相关问题