• 0
shokry3

JSF - Primefaces p:commandButton with action not called

سؤال

السلام عليكم ورحمة الله وبركاته

 

كنت بجرب examble بسيط بال jsf وكان يعمل من قبل بدون اى مشاكل

 

المشكلة التى تقابلنى هى ان action داخل p:commandButton لا تعمل ومبتدخلش على الميثود

 

ودى ال page اللى فيها الكلام ده ال action لا يعمل فى  p:commandButton value="add"

<!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:p="http://primefaces.org/ui">    <h:body>        <p:dialog widgetVar="uniCreateDialogWidget" id="uniCreateDialogId"                  height="100" width="300" modal="true" appendToBody="true"                   resizable="false" header="Add New University">            <h:form id="uniCreateDialogForm">                <p:messages  autoUpdate="true" />                <h:panelGrid columns="2" id="dialogPanal">                    <h:outputText value="University Name:*" />                    <p:inputText value="#{facultyMB.university.name}" required="true"                                 label="University Name">                        <f:validateLength minimum="2" />                    </p:inputText>                </h:panelGrid>                <p:commandButton value="add" icon="ui-icon-plus"                                 action="#{facultyMB.addUniversity()}"                                 update=":univerityForm"                                 oncomplete="uniCreateDialogWidget.hide();" >                </p:commandButton>                <p:commandButton value="cancel" icon="ui-icon-cancel" actionListener="#{facultyMB.resetUniversity()}"                                 onclick="uniCreateDialogWidget.hide();"/>            </h:form>        </p:dialog>    </h:body></html>

ودى ال bean class

package beans;import converter.FacConverter;import dao.AdminDAO;import dao.UserRegister;import java.io.Serializable;import java.util.ArrayList;import java.util.List;import javax.annotation.PostConstruct;import javax.faces.bean.ManagedBean;import javax.faces.bean.SessionScoped;import javax.faces.context.FacesContext;import javax.faces.event.ValueChangeEvent;import javax.faces.model.SelectItem;/** * * @author shokry */@[email protected] class FacultyMB implements Serializable {    //variables..................................................    private static final long serialVersionUID = 1L;    University university;    Faculty faculty;    public AdminDAO adminDAO;    public ArrayList<SelectItem> universities;    public List<Faculty> uniFaculties;    public int universityId;    public String facultyName;    //getters and setters...........................................    public University getUniversity() {        return university;    }    public void setUniversity(University university) {        this.university = university;    }    public Faculty getFaculty() {        return faculty;    }    public void setFaculty(Faculty faculty) {        this.faculty = faculty;    }    public ArrayList<SelectItem> getUniversities() {        return universities;    }    public void setUniversities(ArrayList<SelectItem> universities) {        this.universities = universities;    }    public List<Faculty> getUniFaculties() {        return uniFaculties;    }    public void setUniFaculties(List<Faculty> uniFaculties) {        this.uniFaculties = uniFaculties;    }    public int getUniversityId() {        return universityId;    }    public void setUniversityId(int universityId) {        this.universityId = universityId;    }    public String getFacultyName() {        return facultyName;    }    public void setFacultyName(String facultyName) {        this.facultyName = facultyName;    }    //Get All Lists Methods...............................................    public List<SelectItem> getAllUniversities() {        ArrayList<University> lst = UserRegister.getUniversities();        ArrayList<SelectItem> items = new ArrayList<SelectItem>();        for (University t : lst) {            items.add(new SelectItem(t.getUniversityId(), t.getName()));        }        return items;    }    public List<Faculty> getAllFaculties() {        if (universityId == 0) {            List<Faculty> lst = UserRegister.getUniFaculties(3);            List<Faculty> items = new ArrayList<Faculty>();            for (Faculty t : lst) {                items.add(new Faculty(t.getFacultyId(), t.getName(), t.getUniversityId()));            }            return items;        } else {            return uniFaculties;        }    }    public void findAllUniFaculties() {        List<Faculty> lst = UserRegister.getUniFaculties(universityId);        List<Faculty> items = new ArrayList<Faculty>();        for (Faculty t : lst) {            items.add(new Faculty(t.getFacultyId(), t.getName(), t.getUniversityId()));        }        setUniFaculties(items);    }    public List<Faculty> getFacultiesAll() {        List<Faculty> lst = UserRegister.getFaculties();        List<Faculty> items = new ArrayList<Faculty>();        for (Faculty t : lst) {            items.add(new Faculty(t.getFacultyId(), t.getName(), t.getUniversityId()));        }        return items;    }    //DAO Methods..............................................................    public void addUniversity() {        System.out.println("addUniversity() hererererererereer --> university is :  " + university.getName());        adminDAO = new AdminDAO();        adminDAO.addUniversity(university.getName());            }    public void editUniversity() {        System.out.println("university is :  "                + university.getName() + "");        adminDAO = new AdminDAO();        adminDAO.editUniversity(university.getUniversityId(), university.getName());    }    public void deleteUniversity() {        adminDAO = new AdminDAO();        adminDAO.deleteUniversity(university.getUniversityId());    }    public void addFaculty() {        adminDAO = new AdminDAO();        adminDAO.addFaculty(facultyName, universityId);        findAllUniFaculties();    }    public void deleteFaculty() {        adminDAO = new AdminDAO();        adminDAO.deleteFaculty(faculty.getFacultyId());    }    public void editFaculty() {        adminDAO = new AdminDAO();        adminDAO.editFaculty(faculty.getFacultyId(), faculty.getName());    }    public void universityChange(ValueChangeEvent e) {        university = (University) e.getNewValue();        FacesContext.getCurrentInstance().renderResponse();    }    public University getuUniversityById(int universityId) {        adminDAO = new AdminDAO();        university = adminDAO.getuUniversity(universityId);        return university;    }    public Faculty getFacultyById(int facultyId) {        adminDAO = new AdminDAO();        faculty = adminDAO.getfFaculty(facultyId);        return faculty;    }    //init methods................................................    @PostConstruct    public void init() {        uniFaculties = FacConverter.facultyDB;    }    //reset objects    public void resetUniversity() {        System.out.println("resetUniversity() hererere --->");        university = new University();    }    public void resetFaculty() {        faculty = new Faculty();        facultyName = "";    }}

فاريد المساعدة فانا مش عارف المشكلة منين!!!!

 

شكرا

0

شارك هذا الرد


رابط المشاركة
شارك الرد من خلال المواقع ادناه

0 إجابة على هذا السؤال .

لاتوجد إجابات على هذا السؤال حتى الآن .

من فضلك سجل دخول لتتمكن من التعليق

ستتمكن من اضافه تعليقات بعد التسجيل



سجل دخولك الان

  • يستعرض القسم حالياً   0 members

    لا يوجد أعضاء مسجلين يشاهدون هذه الصفحة .