Jsf Hibernate problem in SelectOneList event

From: Giri Prasad <>
Date: Tue, 29 Jan 2013 23:22:59 +0800 (SGT)

Hello All,

 I have a very simple jsf page and a backing bean for this jsf, which is implemented using hibernate in 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
<%_at_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;