p:datagrid的p:celleditor中的p:commandLink不起作用

问题描述 投票:0回答:3

p:datagrid的celleditor中的p:commandLink或p:commandButton无法正常工作,当我点击commandLink时,它会将我重定向到同一页面。在celleditor内部,commandLink无法找到它的听众,但是当我把它带到celleditor外面时,它完美地工作。

<h:form id="form">

    <p:growl id="msgs" showDetail="true"/>
                    <p:dataTable id="project" var="car" value="#{editdeleteview.proj_rec}" rowKey="#{car.id}" selection="#{editdeleteview.selected_rec}" selectionMode="single"  editable="true" style="margin-bottom:20px">
                <f:facet name="header">
                    All Projects
                </f:facet>

                <p:ajax event="rowEdit" listener="#{editdeleteview.onRowEdit}" update=":form:msgs"/>
                <p:ajax event="rowEditCancel" listener="#{editdeleteview.onRowCancel}"  update=":form:msgs"/>

                <p:column headerText="ID">

                        <h:outputLabel value="#{car.id}" />


                </p:column> 
                <p:column headerText="Title">
                <p:commandLink ajax="false" action="#{editdeleteview.openObjects(car)}"   ><h:outputText value="#{car.title}" /></p:commandLink>
                    <p:cellEditor>
                        <f:facet name="output"><p:commandLink ajax="false" action="#{editdeleteview.openObjects(car)}"   ><h:outputText value="#{car.title}" /></p:commandLink></f:facet>
                        <f:facet name="input"><p:inputText  value="#{car.title}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>                   
                <p:column headerText="Description">
                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{car.description}" /></f:facet>
                        <f:facet name="input"><p:inputText  value="#{car.description}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Insertion Time">
                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{car.insertionTimestamp}" /></f:facet>
                        <f:facet name="input"><p:inputText  value="#{car.insertionTimestamp}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Close Time">
                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{car.closeTimestamp}" /></f:facet>
                        <f:facet name="input"><p:inputText  value="#{car.closeTimestamp}" style="width:100%"/></f:facet>
                    </p:cellEditor>
                </p:column>  



                <p:column headerText="Edit" style="width:50px">
                    <p:rowEditor />
                </p:column>
                <p:column headerText="Delete">
                    <p:commandButton id="downloadLink1" value="Delete" ajax="false" class="btn btn-danger" icon="ui-icon-trash" action="#{editdeleteview.delete(car)}">  

                    </p:commandButton>
                </p:column>                   
            </p:dataTable>               

    </h:form>

列标题下的celleditor外的p:commandLink工作正常,但在celleditor内部,commandLink不起作用,bean中的监听器是

public String openObjects(Project p)
{


    HttpSession session = SessionUtils.getSession();
    session.setAttribute("project_id", p.getId());
    session.setAttribute("project_title", p.getTitle());
    //session.setAttribute("project_title", "Hamdan");
    System.out.println("EditView: "+session.getAttribute("project_title").toString());
    return "Objects.xhtml";

}

我也试过这个qazxsw poi,但这对我没有用。任何帮助将受到高度赞赏。

jsf primefaces datagrid
3个回答

0
投票

尝试在命令链接组件上设置<f:facet name="output"> <p:commandLink action="#{editdeleteview.openObjects(car)}" process="@this" immediate="true"> <h:outputText value="#{car.title}" /> <f:setPropertyActionListener target="#{editdeleteview.selected_rec}" value="#{car}" /> </p:commandLink> </f:facet> 。看看@BalusC的这个解释:

immediate="true"


0
投票

我正在使用primefaces 6.3-SNAPSHOT,这个问题仍然存在,这就是我解决它的方法:

JSF:

Trying to understand immediate="true" skipping inputs when it shouldn't

JAVASCRIPT:

<p:commandLink ajax="false" action="#{editdeleteview.openObjects(car)}"   >     
    <p:cellEditor>
        <f:facet name="output">
            <h:outputText value="#{car.title}" />
        </f:facet>
        <f:facet name="input">
            <p:inputText onclick="stopEventPropagation(event)" value="#{car.title}" style="width:100%"/>
        </f:facet>
    </p:cellEditor>
</p:commandLink>
© www.soinside.com 2019 - 2024. All rights reserved.