在JSF中:对话框不更新dataList

时间:2014-03-03 13:54:29

标签: jsf

在dataList中我显示记录并给出编辑和删除选项, 删除时我需要检查我的要求取决于我需要删除记录, 但删除DataList后没有更新。

你能解决我的问题......

   <?xml version="1.0" encoding="UTF-8"?>
    <!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:p="http://primefaces.org/ui">

    <h:head>
    </h:head>
    <h:body>
        <ui:composition template="PageTemplate.html">
            <ui:define name="content">
                <h:form id="form"
                    style="width: 70% !important; margin: 100px 0px 0px 205px;">
                    <!-- <p:growl id="growl" showDetail="true" autoUpdate="true" sticky="false"/> -->
    <!--                <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" /> -->
                    <p:tabView id="TabView" style="height:450px;"
                        activeIndex="#{appraisalComponent.tabindex}">

                        <p:ajax event="tabChange"
                            listener="#{appraisalComponent.getSectionAllList}" update="@form" />

                        <p:tab id="tab1" title="Create Section">
                            <p:outputPanel id="createSectionIds">
                                <p:dataTable id="sectionList" paginator="true" rows="5"
                                    value="#{appraisalComponent.sectionListEdit}" var="sections"
                                    editable="true">
                                    <p:ajax event="rowEdit"
                                        listener="#{appraisalComponent.updateSection(sections)}"
                                        update=":form:TabView:sectionList" />
                                    <p:ajax event="rowEditCancel" update=":form:TabView:sectionList" />
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Section Name" />
                                        </f:facet>
                                        <p:cellEditor>
                                            <f:facet name="output">
                                                <h:outputText value="#{sections.secName}" />
                                            </f:facet>
                                            <f:facet name="input">
                                                <h:inputText value="#{sections.secName}" />
                                            </f:facet>
                                        </p:cellEditor>
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Operation" />
                                        </f:facet>
                                        <p:rowEditor />
                                        <p:spacer width="20" height="0" />
                                        <p:commandButton includeViewParams="true"
                                            style="margin:-18px 0px 0px 20px;" title="Remove"
                                            update=":form:TabView:createSectionIds"
                                            process=":form:TabView:createSectionIds" icon="ui-icon-trash"
                                            oncomplete="${appraisalComponent.sectionHaveQS(sections)} ? PF('confirmDialogDelete').show() : PF('confirmDialog').show()">
                                            <f:setPropertyActionListener value="#{sections}"
                                                target="#{appraisalComponent.selectedSec}" />
                                        </p:commandButton>
                                        <p:dialog header="Delete confirmation" appendToBody="true"
                                            widgetVar="confirmDialogDelete" resizable="false" id="secDlg"
                                            showEffect="fade" hideEffect="explode" modal="true">  
                                 Are you sure, you want to delete Employee:<h:outputText
                                                value="#{appraisalComponent.selectedSec.secName}" />
                                            <br></br>
                                            <p:commandButton value="Yes Sure"
                                                onclick="confirmDialogDelete.hide()"
                                                action="#{appraisalComponent.deleteSection(appraisalComponent.selectedSec)}"
                                                update=":form:TabView:createSectionIds"
                                                process=":form:TabView:createSectionIds"
                                                style=" margin-left: 34px;">
                                                <p:collector value="#{appraisalComponent.selectedSec}"
                                                    removeFrom="#{appraisalComponent.sectionListEdit}" />
                                            </p:commandButton>
                                            <p:commandButton value="Not Yet"
                                                onclick="confirmDialogDelete.hide()" type="button" />
                                        </p:dialog>

                                        <!-- <p:commandButton value="Remove" includeViewParams="true"
                                            update=":form:TabView:createSectionIds"
                                            process=":form:TabView:createSectionIds"
                                            oncomplete="${appraisalComponent.sectionHaveQS(sections)} ? PF('confirmDialogDelete').show() : PF('confirmDialog').show()">
                                            <f:setPropertyActionListener value="#{sections}"
                                                target="#{appraisalComponent.selectedSec}" />
                                        </p:commandButton>
                                        <p:dialog header="Delete confirmation" appendTo="@(body)"
                                            widgetVar="confirmDialogDelete" resizable="false"
                                            showEffect="fade" hideEffect="explode" modal="true">  
                                            Are you sure, you want to delete Section:<h:outputText
                                                value="#{appraisalComponent.selectedSec.secName}" />
                                            <br></br>
                                            <p:commandButton value="Yes Sure"
                                                onclick="confirmDialogDelete.hide()"
                                                action="#{appraisalComponent.deleteSection(appraisalComponent.selectedSec)}"
                                                update=":form:TabView:createSectionIds"
                                                process=":form:TabView:createSectionIds"
                                                style=" margin-left: 34px;">
                                                <p:collector value="#{appraisalComponent.selectedSec}"
                                                    removeFrom="#{appraisalComponent.sectionListEdit}" />
                                            </p:commandButton>
                                            <p:commandButton value="Not Yet"
                                                onclick="confirmDialogDelete.hide()" />
                                        </p:dialog>
     -->
                                        <p:dialog header="Delete confirmation" appendTo="@(body)"
                                            widgetVar="confirmDialog" resizable="false" showEffect="fade"
                                            hideEffect="explode" modal="true">  
                                            You need to delete questions which are belongs to this section...!<h:outputText
                                                value="" />
                                            <br></br>
                                            <p:commandButton value="Ok" onclick="confirmDialog.hide()"
                                                type="button" />
                                        </p:dialog>
                                        <!-- <p:commandButton value="Remove"
                                            action="#{appraisalComponent.deleteSection(sections)}"
                                            update=":form:TabView:createSectionIds"
                                            process=":form:TabView:createSectionIds">
                                            <p:collector value="#{sections}"
                                                removeFrom="#{appraisalComponent.sectionListEdit}" />
                                        </p:commandButton> -->
                                    </p:column>
                                </p:dataTable>
                            </p:outputPanel>
                        </p:tab>

                        <p:tab id="tab2" title="Remarks List"
                            action="#{appraisalComponent.test}">
                            <p:outputPanel id="remarksIds">
                                <p:dataTable id="remarksList" paginator="true" rows="5"
                                    value="#{appraisalComponent.remarksListEdit}" var="remarks"
                                    editable="true">
                                    <p:ajax event="rowEdit"
                                        listener="#{appraisalComponent.updateRemarks(remarks)}"
                                        update=":form:TabView:remarksList" />
                                    <p:ajax event="rowEditCancel" update=":form:TabView:remarksList" />
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Remarks Name" />
                                        </f:facet>
                                        <p:cellEditor>
                                            <f:facet name="output">
                                                <h:outputText value="#{remarks.remName}" />
                                            </f:facet>
                                            <f:facet name="input">
                                                <h:inputText value="#{remarks.remName}" />
                                            </f:facet>
                                        </p:cellEditor>
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Remarks Value" />
                                        </f:facet>
                                        <p:cellEditor>
                                            <f:facet name="output">
                                                <h:outputText value="#{remarks.remValue}" />
                                            </f:facet>
                                            <f:facet name="input">
                                                <h:inputText value="#{remarks.remValue}" />
                                            </f:facet>
                                        </p:cellEditor>
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Operation" />
                                        </f:facet>
                                        <p:rowEditor />
                                        <p:commandButton value="Remove"
                                            action="#{appraisalComponent.deleteRemarks(remarks)}"
                                            update=":form:TabView:remarksIds"
                                            process=":form:TabView:remarksIds">
                                            <p:collector value="#{remarks}"
                                                removeFrom="#{appraisalComponent.remarksListEdit}" />
                                        </p:commandButton>
                                    </p:column>
                                </p:dataTable>
                            </p:outputPanel>
                        </p:tab>

                        <p:tab id="tab3" title="Priority List">
                            <p:outputPanel id="priorityIds">
                                <p:dataTable id="priorityList" paginator="true" rows="5"
                                    value="#{appraisalComponent.priorityListEdit}" var="priority"
                                    editable="true">
                                    <p:ajax event="rowEdit"
                                        listener="#{appraisalComponent.updatePriority(priority)}"
                                        update=":form:TabView:priorityList" />
                                    <p:ajax event="rowEditCancel"
                                        update=":form:TabView:priorityList" />
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Priority Name" />
                                        </f:facet>
                                        <p:cellEditor>
                                            <f:facet name="output">
                                                <h:outputText value="#{priority.prName}" />
                                            </f:facet>
                                            <f:facet name="input">
                                                <h:inputText value="#{priority.prName}" />
                                            </f:facet>
                                        </p:cellEditor>
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Operation" />
                                        </f:facet>
                                        <p:rowEditor />
                                        <p:commandButton value="Remove"
                                            action="#{appraisalComponent.deletePriority(priority)}"
                                            update=":form:TabView:priorityIds"
                                            process=":form:TabView:priorityIds">
                                            <p:collector value="#{priority}"
                                                removeFrom="#{appraisalComponent.priorityListEdit}" />
                                        </p:commandButton>
                                    </p:column>
                                </p:dataTable>
                            </p:outputPanel>
                        </p:tab>

                        <p:tab id="tab4" title="List Of Section">
                            <p:dataTable id="dataTable" var="sections"
                                value="#{appraisalComponent.sectionListToAddQues}"
                                paginator="true" rows="5">
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Section Name :" />
                                    </f:facet>
                                    <h:outputText value="#{sections.secName}" />
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Operation" />
                                    </f:facet>
                                    <p:commandLink value="Edit Questions"
                                        action="#{appraisalComponent.editQuestions}">
                                        <f:param name="sectionId" value="#{sections.secId}" />
                                    </p:commandLink>
                                </p:column>
                            </p:dataTable>
                            <br></br>
                        </p:tab>

                    </p:tabView>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
    </html>

1 个答案:

答案 0 :(得分:0)

我在top中给出的是正确的,但是java方法存在问题。

删除,我给了一个java方法“action =”#{appraisalComponent.deleteSection(appraisalComponent.selectedSec)}“”

在返回一个值的java中,如下所示

public String deleteSection (int secId) {
     String temp ;
    // some code

    return temp;
}

但我们应该只提供如下的无效方法

public void deleteSection (int secId) {

}

我改变了这个,现在我的代码工作正常。 不管怎样,谢谢。 :)