Primefaces p:对话框无法从p:commandLink onComplete工作

时间:2014-03-28 05:00:29

标签: jsf jsf-2 primefaces

早些时候,当我在其上定义的.show()上执行widgetVar时,我的p:对话框已被正确调用。但最近在更新后它停止工作,我在浏览器中收到此错误:

网页错误详情:

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8)
Timestamp: Fri, 28 Mar 2014 04:04:49 UTC


Message: Object doesn't support this property or method
Line: 12
Char: 4302
Code: 0
URI: http://localhost:8282/OMNIVue/javax.faces.resource/primefaces.js.jsf?ln=primefaces


Message: Object doesn't support this property or method
Line: 16
Char: 1
Code: 0
URI: http://localhost:8282/OMNIVue/orders/orderSearch.jsf


Message: Could not complete the operation due to error 80020101.
Line: 81
Char: 17
Code: 0
URI: http://localhost:8282/OMNIVue/javax.faces.resource/jsf.js.jsf?ln=javax.faces&stage=Development


Message: 'confirmation' is undefined
Line: 83
Char: 1
Code: 0
URI: http://localhost:8282/OMNIVue/orders/orderSearch.jsf


Message: 'confirmation' is undefined
Line: 83
Char: 1
Code: 0
URI: http://localhost:8282/OMNIVue/orders/orderSearch.jsf

我有一个这样的主页,我已经定义了dialog box

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:t="http://myfaces.apache.org/tomahawk"
    xmlns:mdw="http://www.qwest.com/mdw/jsf"
    xmlns:mwt="http://www.centurylink.com/mwt/jsf"
    xmlns:q="http://www.qwest.com/mdw/jsf"
    xmlns:p="http://primefaces.org/ui"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions">

<ui:composition>
 <script language="javascript" type="text/javascript">
    function solutionButtonClickHandler(){
        #{rich:component('addSolutionDlg')}.show(); 
        document.getElementById('addSolutionId').setAttribute('disabled', 'disabled');
    }

    function removeSearchParam(checkbox){
        var parentDiv = checkbox.parentNode;
        parentDiv.style.display = "none";
    }
    function displayErrorDialog(status){
        if(status == 'taskSelectedError'){
        #{rich:component('addSolutionTaskErrorDlg')}.show();
        }
    }
    function disableButtons(){
        if(document.getElementById('addSolution') != null)
            document.getElementById('addSolution').setAttribute('disabled', 'disabled');
        if(document.getElementById('escalateWorkItemTask') != null)
            document.getElementById('escalateWorkItemTask').setAttribute('disabled', 'disabled');
    }

    function removeEscalation(escalationId, taskInstanceId, taskId){
        if(document.getElementById('escalationid') != null)
            document.getElementById('escalationid').value = escalationId;
        if(document.getElementById('taskinstanceid') != null)
            document.getElementById('taskinstanceid').value = taskInstanceId;
        if(document.getElementById('taskid') != null)
            document.getElementById('taskid').value = taskId;
    }

    function redirectToActivityCenter(taskId){
        if(document.getElementById('taskid') != null)
            document.getElementById('taskid').value = taskId;
    }


  </script>
<rich:panel id="detailPanel" styleClass="floatL iconbdrNone bgcTransparent w790P "
            rendered="#{filterManager.orderFilter.showSearchPanel}">  
    <!-- <br style="background-color:white;" />      -->
  <h:form id="selectedParamForm" prependId="false"> 
   <h:inputHidden id="orderRefreshSubmit" forceId="true" value="false" />       
            <rich:collapsiblePanel styleClass="marLmin1 iconbdrNone W788P"  id="selectedSearchParams" 
                                   header="Selected Search Parameters" 
                                   switchType="client"
                                   expanded="#{orderSearchMenuBean.expandSearchParameters}" 
                                   rendered="#{filterManager.orderFilter.showSearchPanel}">
                <!-- <table style="margin-left: 10px; padding-top: 10px; padding-bottom: 25px;"> -->
                <table class="wrapperW100P" >
                    <ui:repeat var="searchParams" 
                               value="#{filterManager.orderFilter.selectedSearchParameters}" 
                               varStatus="serachParamsStatus">
                        <tr>
                            <ui:repeat var="searchParam" 
                                       value="#{searchParams}" 
                                       varStatus="status">
                                <td>
                                    <div style="margin-right:39px;">

                                        <h:selectBooleanCheckbox styleClass="floatL"
                                            value="#{filterManager.orderFilter.searchParamCheckbox}"
                                            label="#{searchParam.label}"  
                                            valueChangeListener="#{ordersListActionController.refreshOrders}" 
                                            onclick=" removeSearchParam(this); document.getElementById('orderRefreshSubmit').value='true'; ">
                                            <a4j:ajax event="change" execute="@this"  
                                                render="orderFilterPanel orderDetailPanel orderMessage " />

                                            <h:inputHidden value="#{searchParam.label}" />
                                        </h:selectBooleanCheckbox>

                                        <h:outputLabel value="#{searchParam.label}" styleClass="font floatL marT2"/>
                                        <!-- <br style="background-color:white;" /> -->
                                        <h:outputLabel value="#{searchParam.value}" styleClass="font floatL clearL marL20"/>
                                    </div>
                                </td>
                            </ui:repeat>
                        </tr>
                        <tr>
                            <td colspan="4">
                                <h:graphicImage value="../images/param_line.png"  styleClass="wrapperW100P height1P"/>
                            </td>
                        </tr>
                    </ui:repeat>
                </table>
            </rich:collapsiblePanel>

            <a4j:outputPanel ajaxRendered="true">
                <a4j:status onstart="#{rich:component('refreshOrders')}.show()"
                            onstop="#{rich:component('refreshOrders')}.hide()">
                </a4j:status>
           </a4j:outputPanel>

            <rich:popupPanel id="refreshOrders" autosized="true" domElementAttachment="parent">
                <h:panelGrid style="text-align:center !important;">

                    <h:graphicImage styleClass="floatL marL81" value="../images/loading.gif"/>
                    <h:outputText value="Please wait while the search refreshes" styleClass="font floatL clearL"></h:outputText>
                    <h:commandLink value="Cancel" onclick="#{rich:component('refreshOrders')}.hide()"
                    styleClass="green_addMoreLink floatL clearL marL81"/>
                </h:panelGrid>
            </rich:popupPanel>
    </h:form>
    <br style="background-color:white;" />
 <h:form id="ordSearchList" prependId="false">

                <mwt:expandableRowList id="ordersLst" listId="#{filterManager.orderFilter.dynamicListId}"
                listEntity="#{listManager.getMyOrders(filterManager.orderFilter.dynamicListId)}"
                label="Records"/>

            <p:dialog modal="true" widgetVar="confirmation" style="background:white !important;" closable="true" 
            header="Cancel Device Build Order" styleClass="stylePDialogHeader" width="500" id="confGirish" appendToBody="true">
                <h:panelGroup styleClass="wrapperW100P">
                    <h:outputText
                        value="Canceling device build order will cancel all new devices and Ethernet bearers associated to this request, and release all reserved ports. Do you wish to continue ? "
                        styleClass="font floatL" />
                    <h:panelGroup styleClass="floatR">
                    <a4j:commandButton value="Yes"
                        styleClass="cmdButton marL5 marR5 clearL"
                        action="#{orderListScopeActionCtrl.cancelDeviceBuildOrder}"
                        oncomplete="if(#{orderListScopeActionCtrl.displayPortAssignmentErrorDialog}){confirmation.hide();portassignment.show(); return false;}else if(#{orderListScopeActionCtrl.displayCancelSuccessDialog}){confirmation.hide();successDialog.show();return false;}else {confirmation.hide();errorCancelDialog.show();return false;}">
                    </a4j:commandButton>
                    <!-- Yes button onclick="if(#{orderListScopeActionCtrl.orderToCancelHasNIDDeviceStatus}){portassignment.show(); return false;}" -->
                    <h:commandButton value="No"
                        onclick="confirmation.hide();return false;"
                        styleClass="cmdButton marL5 clearL">
                    </h:commandButton>
                    </h:panelGroup>
                </h:panelGroup>             
            </p:dialog>

            <p:dialog header="Cancel Device Build Order" modal="true" widgetVar="successDialog" closable="true"
            style="background:white !important;" styleClass="stylePDialogHeader1" width="500">
                <h:panelGroup>
                    <h:outputText
                        value="Cancellation Process is initiated in DSP successfully."
                        styleClass="font floatL" />
<!--                <h:commandButton value="OK"
                        onclick="successDialog.hide();return false;"
                        styleClass="cmdButton floatR marL5 clearL">
                    </h:commandButton> -->
                    <!-- action="#{orderListScopeActionCtrl.refreshPageAfterUpdate}" -->
                    <a4j:commandButton value="OK"
                        styleClass="cmdButton floatR marL5 clearL"
                        action="#{orderListScopeActionCtrl.updateOrderStatusAndRefresh}"
                        oncomplete="successDialog.hide();return false;">
                    </a4j:commandButton>
                </h:panelGroup>
            </p:dialog>

            <p:dialog header="Confirm Cancel Device Build Order" modal="true" widgetVar="portassignment" closable="true"
            style="background:white !important;" styleClass="stylePDialogHeader1" width="500">
                <h:panelGroup>
                    <h:outputText
                        value="There are UNI/ENNIs assigned to ports on NID device. Please remove UNI/ENNIs and try again."
                        styleClass="font floatL" />
                    <h:commandButton value="OK"
                        onclick="portassignment.hide();return false;"
                        styleClass="cmdButton floatR marL5 clearL">
                    </h:commandButton>
                </h:panelGroup>
            </p:dialog>

            <p:dialog header="Cancel Device Build Order" modal="true" widgetVar="errorCancelDialog" closable="true"
            style="background:white !important;" styleClass="stylePDialogHeader1" width="500">
                <h:panelGroup>
                    <h:outputText
                        value="Some error occured during Cancellation Process in DSP. Please try later."
                        styleClass="font floatL" />
                    <h:commandButton value="OK"
                        onclick="errorCancelDialog.hide();return false;"
                        styleClass="cmdButton floatR marL5 clearL">
                    </h:commandButton>
                </h:panelGroup>
            </p:dialog>

            <ui:include src="escalationDlg.xhtml" />
            <ui:include src="addSolutionDlg.xhtml" />
            <h:inputHidden id="escalationid" value="#{ordersListActionController.escalationId}"></h:inputHidden>
            <h:inputHidden id="taskid" value="#{ordersListActionController.taskId}"></h:inputHidden>
            <h:inputHidden id="taskinstanceid" value="#{ordersListActionController.taskInstanceId}"></h:inputHidden>
    </h:form>
</rich:panel>
</ui:composition>   
</html>

我从复合组件xmthml调用这些对话框,这是通过p:commandLink:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:t="http://myfaces.apache.org/tomahawk"
    xmlns:p="http://primefaces.org/ui" 
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:mdw="http://www.qwest.com/mdw/jsf"
    xmlns:mwt="http://www.centurylink.com/mwt/jsf"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head></h:head>
<ui:composition>
        <script type="text/javascript" src="#{request.contextPath}/script/listSupport.js"/>

        <rich:panel styleClass="ordsearchDetail  iconbdrNone floatL " headerClass="headerBGWhite" >
        <f:facet name="header">
        <h:outputText value="Search Results" ></h:outputText>

        </f:facet>
        <div class="clearB"></div>
        <h:panelGroup styleClass="marT5">
                    <h:graphicImage value="../images/divider_line.png"></h:graphicImage></h:panelGroup>
                <h:panelGroup id="#{listId}_dataTablePanelGrid"
            rendered="#{rendered == null ? true : rendered}" columns="1"
            width="100%" cellpadding="0" cellspacing="0">

            <p:dataTable value="#{listEntity.items}" 
                id="#{listId}"
                var="listItem"
                rowIndexVar="rowIdxVar"
                style="#{webUtil.ie ? 'border-collapse:collapse;' : ''};"
                styleClass="mdw_ORD_upperLine bdrC3C3C3" 
                rows="#{listEntity.displayRows}" 
                cellspacing="0"
                width="750px"
                emptyMessage="Item(s) requested cannot be found" 
                lazy="true"
                first="#{listEntity.firstRow}" 
                paginator="true" 
                paginatorPosition="top"
                currentPageReportTemplate="#{label == null ? listEntity.name : label} ({startRecord} - {endRecord} of {totalRecords})"
                paginatorTemplate="{CurrentPageReport} {FirstPageLink}  {PreviousPageLink}  {NextPageLink}  {LastPageLink}">



                <p:columns value="#{listEntity.headerList}" var="colHeader"
                    columnIndexVar="colIdx" sortBy="#{listItem[colHeader.attribute]}" headerText="#{colHeader.label}" rendered="#{not empty listEntity.headerList}">
                    <f:facet name="header">

                        <h:selectBooleanCheckbox
                            rendered="#{listEntity.hasItems &amp;&amp; colHeader.checkbox &amp;&amp; colHeader.linkAction != 'removeWorkItemEscalation'}"
                            onclick="#{userRole == null?'':'selectAllOrders(this.form, this.checked);enableDisableAddWorkItem(this.form, this.checked);enableDisableAddSolution(this.form, this.checked);enableDisableEscalate(this.form, this.checked);'}"/>


                        <h:outputText id="#{listId}_header"
                            rendered="#{!colHeader.checkbox}" value="#{colHeader.label}"
                            immediate="true">
                        </h:outputText>

                    </f:facet>



                <p:commandLink actionListener="#{listEntity.performLinkAction(colHeader)}" 
                        rendered="#{colHeader.commandLink &amp;&amp; colHeader.linkAction != 'removeWorkItemEscalation' &amp;&amp; colHeader.linkAction == 'orderCancellation' &amp;&amp; listItem.cancelOrder}"
                        disabled="#{listItem.disabledOrder}" update="@form" process="@form" oncomplete="confirmation.show();"
                        title="Cancel Device Build Order" styleClass="#{listEntity.getStyleClass(colHeader)} mdw_listLinks">
                        <h:graphicImage value="#{colHeader.valueImage}" styleClass="marLR10 iconbdrNone"></h:graphicImage>
                        <f:setPropertyActionListener 
                        target="#{orderListScopeActionCtrl.orderToCancelHasNIDDeviceStatus}" value="#{listItem.cancelOrderNICDeviceStatus}"/>
                        <f:setPropertyActionListener 
                        target="#{orderListScopeActionCtrl.orderDeviceClli}" value="#{listItem.clliCode}"/>
                        <f:setPropertyActionListener 
                        target="#{orderListScopeActionCtrl.orderDeviceName}" value="#{listItem.deviceName}"/>   
                </p:commandLink>



        </rich:panel>
</ui:composition>
</html>

2 个答案:

答案 0 :(得分:7)

尝试

oncomplete="PF('confirmation').show()"

答案 1 :(得分:-2)

我使用以下方法解决了这个问题:

将我的p:dialog转换为rich:popupPanel并将其用于显示和隐藏弹出窗口:

{rich:component('addSolutionTaskErrorDlg')}.show() / .hide().

调用commandLink时,使用此错误从浏览器中消失。

我尝试使用p:widgetVar('id').show() / .hide(),但这不起作用。