myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giri Prasad <>
Subject Jsf Hibernate problem in SelectOneList event
Date Wed, 30 Jan 2013 13:05:46 GMT
Hello All,

 I have a very simple jsf page and a backing bean for this jsf, which is implemented in hibernate
using Netbeans.

 <Select> button does properly populate the list box. <Details> button does display
the debug message in glassfish log, when no entry in list box is chosen.

 After I press <Select>, choose a entry from the list, pressing <Detail> button,
is not executing the backing bean function 'studDet()'. On this situation, the screen just
refreshes, the list goes empty, and the backing bean function is not executed.

 The same backing bean function ['studDet()']  is executed when nothing is selected from
the list. Apparently the logic when implemented via jpa seems to work just perfectly correctly.

Can any one provide your insights, as why this problem is occuring. Thanks in advance.


    Document   : StudentPage.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri=""%>
<%@taglib prefix="h" uri=""%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title>Student Page</title>
<h:outputLabel value="Teacher Name    "/>
<h:inputText id="Student" value="#{studBean.teacherName}" size="20" maxlength="50">
                <h:selectOneListbox id="studentList" value="#{studBean.selectedItem}"
                                     size="5" >
                    <f:selectItems value="#{studBean.studentList}" />
<h:commandButton id="Select" action="#{studBean.studSel}" value="Select" />
<h:commandButton id="Details" action="#{studBean.studDet}" value="Details" />
// Backing bean
public class StudBean implements Serializable  {
    private String teacherName;
    private List studentList;
    // Getter and setter methods omitted
    public String studSel() {
        studentlist = new ArrayList();
        List cList = getStudentDetailForTeacher();
            return null;
        for (int i = 0; i < cList.size(); i++) {
            SelectItem studentid = new SelectItem(cList.get(i).toString());
        return null;
    public List<String[]> getStudentDetailForTeacher() {
        this.session = HibernateUtil.getSessionFactory().getCurrentSession();
        List<String[]> studentlist = null;
        String strQuery = "select "
                + "from TeacherStudent c WHERE = :teachid1";
        org.hibernate.Transaction tx = session.beginTransaction();
        Query cQuery = session.createQuery(strQuery);
        cQuery.setParameter("teachid1", teacherName);
        studentlist = (List<String[]>) cQuery.list();
        return studentlist;
    public void studentCodeChanged(ValueChangeEvent e){
        studentId = e.getNewValue().toString();
                System.out.println("studentId = "+studentId);
    public Boolean studDet() {
        System.out.println("studentId id = "+studentId);    
        return null;
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message