0

我是这个 StackOverflow 社区的新手。我遇到一个问题,即rowEdit每当我单击铅笔时,PrimeFaces 数据表 Ajax 事件都不会调用。我知道这个社区有很多问题,我尝试了每一种可能的解决方案,但都在脉络中。

这是我的xhtml代码:

<h:body style="background:#333333;">
    <div
        style="background-color: #e5e5e5; padding: 50px; text-align: center;">


        <h:graphicImage value="resources/images/afid.png" width="160"
            height="160" />

        <h:graphicImage value="resources/images/afid2.png" width="160"
            height="160" />

        <h1>Armed Forces Institute of Dentistry (AFID), Rawalpindi.</h1>

        <hr />
    </div>

    <h:form>
        <h3 style="color: #ffd700; text-align: center">
            <u> Search Bills By MR No. </u>
        </h3>


        <p:outputLabel value="MR No.:" />
        <p:inputText value="#{viewBills.mrNo}" placeholder="Search" />
        <p:commandButton value="Search" actionListener="#{viewBills.search}"
            update="table-wrapper" class="armedForces" style="margin-left: 30px;" />

        <p:growl id="msgs" showDetail="true" />
        <h:panelGroup id="table-wrapper">
            <p:dataTable id="patients" rendered="#{viewBills.visible}"
                editable="true" value="#{viewBills.getPatientBills}" var="patient"
                style="margin-bottom:20px">

                <p:ajax event="rowEdit" Listener="#{viewBills.updateEdited}" />
                <p:ajax event="rowEditCancel" Listener="#{viewBills.onRowCancel}" />

                <p:column headerText="Name">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.patName}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText id="modelInput" value="#{patient.patName}"
                                style="width:100%" />
                        </f:facet>
                    </p:cellEditor>

                </p:column>
                <p:column headerText="Department">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.department}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.department}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Amount">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.amount}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.amount}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Implant">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.implant}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.implant}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Ceramic Lab">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.ceramicLab}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.ceramicLab}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Comments">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.comments}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.comments}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Practical Charges">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.practicalCharges}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.practicalCharges}"
                                style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Material Charges">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.materialCharges}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.materialCharges}"
                                style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Fixed Ortho">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.fixedOrtho}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.fixedOrtho}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="MF Kit">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.mfKit}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.mfKit}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Army No">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.armyNo}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.armyNo}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Unit">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.unit}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.unit}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Armed Forces">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{patient.armedForces}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{patient.armedForces}" style="width:100%" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="Options" style="width:50px">
                    <p:rowEditor />
                </p:column>
            </p:dataTable>
        </h:panelGroup>

        <p:dialog header="View Bills" widgetVar="dlg2" modal="true"
            height="100">
            <h:outputText value="Patient Record Not Found!" />
        </p:dialog>
    </h:form>
</h:body>

这是我的豆子:

/**
 * 
 */
package com.afid.mb;

import java.io.IOException;
import java.util.ArrayList;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.view.ViewScoped;

import org.primefaces.event.RowEditEvent;

import com.afid.db.DatabaseHandler;
import com.afid.model.Patient;

/**
 * @author yawar
 *
 */

@ManagedBean(name = "viewBills")
@ViewScoped
public class ManageViewBIllsBean {

    public String mrNo;

    public boolean visible = false;

    public ArrayList<Patient> getPatientBills = new ArrayList<>();

    public ArrayList<Patient> getAllPatientBills = new ArrayList<>();

    public void search(ActionEvent event) {
        getPatientBills = DatabaseHandler.searchBillByMrNo(mrNo);
        if (!getPatientBills.isEmpty()) {
            setVisible(true);
        } else {

        }

    }

    public ArrayList<Patient> searchAllBills() {
        return DatabaseHandler.searchAllBills();
    }

    public void executeViewAllBills() throws IOException {

        ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();

        ec.redirect(ec.getRequestContextPath() + "/viewAllBills.xhtml");

    }

    public void executeViewBillsByMRNo() throws IOException {

        ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();

        ec.redirect(ec.getRequestContextPath() + "/viewBillsByMRNo.xhtml");

    }
    public void updateEdited(RowEditEvent event) {
        System.out.println(" i am in edit");
        FacesMessage msg = new FacesMessage("Car Edited", ((Patient) event.getObject()).getPatName());
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }

    public void onRowCancel(RowEditEvent event) {
        FacesMessage msg = new FacesMessage("Edit Cancelled", ((Patient) event.getObject()).getPatName());
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }

    public String getMrNo() {
        return mrNo;
    }

    public void setMrNo(String mrNo) {
        this.mrNo = mrNo;
    }

    public ArrayList<Patient> getGetPatientBills() {
        return getPatientBills;
    }


    public ArrayList<Patient> getGetAllPatientBills() {
        return getAllPatientBills;
    }

    public boolean isVisible() {
        return visible;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

}

任何类型的帮助将不胜感激

4

1 回答 1

1

rowEdit确实不会在您单击铅笔/开始编辑时触发。当您单击复选标记/完成编辑时,它将被触发。

您可以在陈列柜中看到这种情况。

于 2019-02-11T15:39:31.950 回答