Primefaces:contextMenu不会抛出Dialog

时间:2015-10-01 07:56:36

标签: jsf primefaces

我希望itemMenu中的contextMenu启动Dialog。 但是当我点击itemMenuDialog没有出现。 我有contextMenu

<p:contextMenu for="processes">
    <p:menuitem  styleClass="homeIE" update="form" value="Start Process"   icon="ui-icon-play"     actionListener="PF('startDialog').show;" rendered="#{homeBean.selectedLogicalServer.os eq 'Windows'}"/>
    <p:menuitem  styleClass="homeIE" update="form" value="Stop Process"    icon="ui-icon-stop"     actionListener="PF('stopDialog').show;"/>
    <p:menuitem  styleClass="homeIE" update="form" value="Restart Process" icon="ui-icon-seek-end" actionListener="PF('restartDialog').show;" rendered="#{homeBean.selectedLogicalServer.os eq 'Windows'}"/>
</p:contextMenu>

我有dataTable

<p:dataTable id="processes" var="process" value="#{homeBean.processesList}" filteredValue="#{homeBean.filteredProcesses}"
             rowKey="#{process.pid}" selection="#{homeBean.selectedProcesses}" 
             paginator="true" rows="15" paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
             rowsPerPageTemplate="15,20,25,30" selectionMode="single">
    <f:facet name="header">
        <h:outputText value="Processes" />
    </f:facet>
    <p:column name="owner" filterBy="#{process.owner}" filterMatchMode="contains" sortBy="owner" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'DESCRIPTION' : 'OWNER'}">
        <h:outputText value="#{process.owner}" />
    </p:column>
    <p:column name="pid" filterBy="#{process.pid}" filterMatchMode="exact" sortBy="pid" headerText="PID">
        <h:outputText value="#{process.pid}" />
    </p:column>
    <p:column name="ppid" filterBy="#{process.ppid}" filterMatchMode="exact" sortBy="ppid" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'TYPE' : 'PPID'}">
        <h:outputText value="#{process.ppid}" />
    </p:column>
    <p:column name="c" filterBy="#{process.c}" filterMatchMode="exact" sortBy="c" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'STATE' : 'C'}">
        <h:outputText value="#{process.c}" />                                                
    </p:column>
    <p:column name="stime" filterBy="#{process.stime}" filterMatchMode="contains" sortBy="stime" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'WIN32 EXIT CODE' : 'STIME'}" rendered="#{homeBean.selectedLogicalServer.os eq 'Windows'}">
        <h:outputText value="#{process.stime}" />
    </p:column>
    <p:column name="tty" filterBy="#{process.tty}" filterMatchMode="contains" sortBy="tty" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'SERVICE EXIT CODE' : 'TTY'}" rendered="#{homeBean.selectedLogicalServer.os eq 'Windows'}">
        <h:outputText value="#{process.tty}" />
    </p:column>
    <p:column name="time" filterBy="#{process.time}" filterMatchMode="contains" sortBy="time" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'CONTROL POINT' : 'TIME'}" rendered="#{homeBean.selectedLogicalServer.os eq 'Windows'}">
        <h:outputText value="#{process.time}" />
    </p:column>
    <p:column name="cmd" filterBy="#{process.cmd}" filterMatchMode="contains" sortBy="cmd" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'NAME' : 'CMD'}">
        <h:outputText value="#{process.cmd}" />
    </p:column>
</p:dataTable>

我有这些dialogs

<p:dialog header="Start Process" widgetVar="startDialog" minHeight="40" styleClass="dialogPosition">
    <h:outputText    value="You are going to start the process, Are you sure?"/>
</p:dialog>
<p:dialog header="Stop Process" widgetVar="stopDialog" minHeight="40" styleClass="dialogPosition">
    <h:outputText    value="You are going to stop the process, Are you sure?"/>
</p:dialog>
<p:dialog header="Restart Process" widgetVar="restartDialog" minHeight="40" styleClass="dialogPosition">
    <h:outputText    value="You are going to restart the process, Are you sure?"/>
</p:dialog>

所有代码都在此标记内:

<h:form id="form" onkeypress="return event.keyCode != 13">
    <p:contextMenu for="process">
    ...
    </p:contextMenu>
    <p:dataTable id="processes">
    ...
    </p:dataTable>
    <dialog>
    ...
    </dialog>
    <dialog>
    ...
    </dialog>
    <dialog>
    ...
    </dialog>
</h:form>

在日志中:

Grave: javax.el.ELException: Cannot convert LogicalServerProcess [owner=root, pid=11500, ppid=11499, c=0, stime=11:27, tty=pts/1, time=00:00:00, cmd=ps -ef ] desde tipo class corp.gs.produban.atf.ccs.bean.LogicalServerProcess to interface java.util.List

1 个答案:

答案 0 :(得分:3)

actionListener应该在服务器端上调用某些操作方法。部分PF('startDialog').show;只是一些用于在客户端上显示对话框的JavaScript

您只需使用onclick(或以on...开头的其他JavaScript事件处理程序之一)而不是actionListener

除此之外,您的代码中还存在另一个问题,但由于Bean的代码的基本部分缺失,因此无法准确说出它是什么。我假设您的bean中的selectedProcesses类型为List<LogicalServerProcess>,但您选择了single选择模式,因此它必须是LogicalServerProcess类型。