2

最初のダイアログから 2 番目のダイアログを開こうとすると問題が発生します。最初のダイアログは正常に開きますが、2 番目のダイアログはまったく開かないようです。ダイアログの内側と外側でフォームタグを試してみましたが、どちらもダイアログを開いていないようです。最初から [開く] ダイアログ ボタンをクリックしても、何も起こらないようです。PrimeFaces 3.5 を使用しています。

ダイアログのコードは次のとおりです

<p:dialog id="dialog" header="New Submission" widgetVar="dlg" resizable="false" modal="true" closable="true">  
        <h:form id="createDialogForm">
        <h:panelGrid columns="2" cellpadding="5">  
            <h:outputLabel for="projectDropDown" value="Project:" />  
            <h:selectOneMenu id="projectDropDown" value="#{newSubmissionBean.submission.project}"  required="true">
                <f:selectItem itemLabel="Choose project" noSelectionOption="true" />
                <f:selectItems value="#{newSubmissionBean.projectEntities}" var="project" itemLabel="#{project.name}" itemValue="#{project}" />
            </h:selectOneMenu>


            <f:facet name="footer">  
                <p:commandButton id="createButton" value="Create" update=":newSubmissionForm :createDialogForm"   
                    actionListener="#{newSubmissionBean.createSubmission}" 
                    oncomplete="handleRequest(xhr, status, args)"
                    />

                <p:commandButton id="chooseBatchButton" value="OPen dialog" update=":batchChooserForm"   
                    actionListener="#{newSubmissionBean.fetchAvailability}" />  
            </f:facet>  
        </h:panelGrid>  
          </h:form>
        </p:dialog>  






        <p:dialog id="batchDialog" header="Batch Chooser" widgetVar="bdlg" resizable="false" modal="true" closable="true">
        <h:form id="batchChooserForm"> 
            <p:fieldset legend="#{messages['label.legend.sample.available']}">  
                <p:dataTable id="availableSamples" var="sample" value="#{newSubmissionBean.availableSamples}">  
                    <p:column style="width:20px">  
                        <h:outputText id="dragIcon"  
                            styleClass="ui-icon ui-icon-arrow-4" />  
                        <p:draggable for="dragIcon" revert="true" />  
                    </p:column>  

                    <p:column headerText="#{messages['label.sample.batch']}">  
                        <h:outputText value="#{sample.sampleId}" />  
                    </p:column>  



                </p:dataTable>  
            </p:fieldset>  

            <p:fieldset id="selectedSamples" legend="#{messages['label.legend.sample.selected']}" style="margin-top:20px">  
                <p:outputPanel id="dropArea">  
                    <h:outputText value="#{messages['label.drop.text']}"  
                            rendered="#{empty newSubmissionBean.selectedSamples}"  
                            style="font-size:24px;" />  

                    <p:dataTable var="sample" value="#{newSubmissionBean.selectedSamples}"   
                            rendered="#{not empty newSubmissionBean.selectedSamples}">  

                        <p:column headerText="#{messages['label.sample.batch']}">  
                            <h:outputText value="#{sample.sampleId}" />  
                        </p:column>  


                        <!-- p:column style="width:32px">  
                            <p:commandButton update=":carForm:display"  
                                    oncomplete="carDialog.show()"  
                                    icon="ui-icon-search">  
                                <f:setPropertyActionListener value="#{car}"  
                                    target="#{tableBean.selectedCar}" />  
                            </p:commandButton>  
                        </p:column-->  
                    </p:dataTable>  
                </p:outputPanel>  
            </p:fieldset> 

            <p:commandButton id="confirmBatch" value="Confirm Selection" update=":newSubmissionForm :createDialogForm"   
                    actionListener="#{newSubmissionBean.confirmSelection}" 
                    oncomplete="handleRequest(xhr, status, args)"/> 

            <p:droppable for="selectedSamples" tolerance="touch" activeStyleClass="ui-state-highlight" datasource="availableSamples" onDrop="handleDrop">  
                <p:ajax listener="#{newSubmissionBean.onSampleDrop}" update="dropArea availableSamples" />  
            </p:droppable> 
            </h:form>
        </p:dialog>

完了時のJavaScript関数は

    <script type="text/javascript">  
    function handleRequest(xhr, status, args) {  
        if(args.validationFailed) {  
            dlg.show();

        }   
        else {  
            dlg.hide(); 

        }  
    }  
</script> 

そして、2 番目のダイアログを開こうとするアクション リスナーのコード。このメソッドは、ブレークポイントが指定されているため呼び出されます。

public void fetchAvailability(ActionEvent actionEvent) {

    RequestContext.getCurrentInstance().execute("batchDialog.show()");
}

誰が私が間違ったことをアドバイスできますか? 前もって感謝します

4

2 に答える 2

0

JavaScript でダイアログの ID を使用しています。widgetVar を次のように使用する必要があります。

public void fetchAvailability(ActionEvent actionEvent) {
    RequestContext.getCurrentInstance().execute("bdlg.show()");
}

今後のデバッグのために、Web ブラウザ コンソールで JavaScript を実行してみてください。この場合、「batchDialog is not defined」などと表示され、ヒントが得られます。

于 2013-05-30T14:25:36.547 に答える
0

誰かが同じことをした場合に備えて、問題が何であるかを理解しました。Primefaces ショーケースのサンプル コードでは、handledrop JavaScript 関数が定義されていないため、オブジェクト未定義エラーがスローされます。そこで、コードに以下を追加すると、ポップアップが表示されます。

function handleDrop(event, ui) {
        var selectedSample = ui.draggable;          
        selectedSample.fadeOut('fast');
    }

ありがとう

于 2013-05-31T09:36:26.073 に答える