• 0
shokry3

مشكله فى p:selectOneMenu فى ال JSF

سؤال

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

 

انا عندى مشكله فى استخدام ال p:selectOneMenu

وهى ان ال value الموجوده فى ال selectOneMenu

لا تظهر فى ال inputtext موجود فى p:dialog

والذى يظهر عندما اضغط على p:commandputton

 

هذه هى ال managebean

/* * To change this template, choose Tools | Templates * and open the template in the editor. */package beans;import dao.AdminDAO;import dao.UserRegister;import java.util.ArrayList;import javax.faces.bean.ManagedBean;import javax.faces.bean.ViewScoped;import javax.faces.context.FacesContext;import javax.faces.event.ValueChangeEvent;import javax.faces.model.SelectItem;/** * * @author shokry */@[email protected]()public class FacultyMB {    University university;    Faculty faculty;    public AdminDAO adminDAO;    public University getUniversity() {        if (university == null) {            university = new University();        }        return university;    }    public void setUniversity(University university) {        this.university = university;    }    public Faculty getFaculty() {        if (faculty == null) {            faculty = new Faculty();        }        return faculty;    }    public void setFaculty(Faculty faculty) {        this.faculty = faculty;    }    public ArrayList<SelectItem> getUniversities() {        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 ArrayList<SelectItem> getUniFaculties() {        ArrayList<Faculty> lst = UserRegister.getUniFaculties(university.getUniversityId());        ArrayList<SelectItem> items = new ArrayList<SelectItem>();        for (Faculty t : lst) {            items.add(new SelectItem(t.getFacultyId(), t.getName()));        }        return items;    }    public void addUniversity() {        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() {        System.out.println("university is :  " + university.getUniversityId() + " universityid is : " + university.getUniversityId());        adminDAO = new AdminDAO();        adminDAO.addFaculty(faculty.getName(), 3);    }    public void deleteFaculty() {        adminDAO = new AdminDAO();        adminDAO.deleteFaculty(faculty.getFacultyId());    }    public void editFaculty() {        adminDAO = new AdminDAO();        adminDAO.editFaculty(faculty.getFacultyId(), faculty.getName());    }    public void getinfo() {        System.out.println("university is :  " + university.getName() + " universityid is : " + university.getUniversityId());    }    public void universityChange(ValueChangeEvent e) {        university = (University) e.getNewValue();        FacesContext.getCurrentInstance().renderResponse();    }}

والكود الآتى هو مابه المشكله حيث ان

Faculty.university و Faculty.university.name و Faculty.university.universityId دائما ب null ولا استطيع ان استخمها او اراها داخل اى dialog

مع العلم ان   name,  universityId هى ال properties  للكلاس university

 

<h:form id="univerityForm">                        <h:panelGrid columns="2" cellspacing="6" cellpadding="6">                            <h:outputText value="Select University  " style="size: 3; font-weight: bold;"/>                            <p:selectOneMenu id="university" value="#{facultyMB.university}">                                <f:selectItems value="#{facultyMB.universities}"  var="university" itemLabel="#{facultyMB.university.name}" />                                <f:ajax listener="#{facultyMB.universityChange}"/>                            </p:selectOneMenu>                        </h:panelGrid>                    </h:form>                    <h:panelGrid columns="2" cellspacing="6" cellpadding="6">                        <p:commandButton value="add" icon="ui-icon-plus"                                         onclick="uniCreateDialogWidget.show();"                                         style="font-size: .6em; font-style: italic; width: 40px; hight: .3px">                        </p:commandButton>                        <p:commandButton value="edit" icon="ui-icon-plus"                                         onclick="uniEditDialogWidget.show();"                                         style="font-size: .6em; font-style: italic; width: 40px; hight: .3px">                            <f:setPropertyActionListener target="#{facultyMB.university}" value="#{university}" />                        </p:commandButton>                    </h:panelGrid>

وهذا هو dialog page

وهنا ال vlaue

facultyMB.university.name

لا ترجع بشئ ودائما تاتى معى ب null

 

<!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="uniEditDialogWidget" id="uniEditDialogId"                  height="150" width="500" modal="true" closable="true"                  draggable="false" resizable="false">            <h:form id="uniEditDialogForm" prependId="false">                <h:panelGrid columns="2">                    <h:outputText value="University Name" />                    <h:inputText value="#{facultyMB.university.name}" required="true"                                 label="University Name">                        <f:validateLength minimum="4" />                    </h:inputText>                    <p:commandButton value="edit" icon="ui-icon-plus"                                     action="#{facultyMB.editUniversity()}"                                                                          oncomplete="closeDialogIfSucess(xhr, status, args, uniEditDialogWidget, 'uniEditDialogId')" />                    <p:commandButton value="delete"                                      action="#{facultyMB.deleteUniversity()}"                                                                          oncomplete="closeDialogIfSucess(xhr, status, args, uniEditDialogWidget, 'uniEditDialogId')" />                    <p:commandButton value="cancel" icon="ui-icon-cancel"                                     onclick="uniEditDialogWidget.hide();" type="button" />                </h:panelGrid>            </h:form>        </p:dialog>    </h:body></html>

 

ارجو المساعده

 

وشكرا للجروب الجميل

0

شارك هذا الرد


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

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

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

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

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



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

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

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