This can be handled with the following example
If my screen shows following fields on the screen
1. drop down of student's roll numbers
2. Text box for student's name
3. Text box for student's class
4. Text box for student's address
Information is stored in database in 'STUDENTS' table.
On selection of student's roll number, to populate the other fields my code will look like
<h:outputtext id="rollNumberLbl" value="Roll Number">
<h:selectonemenu id="rollNumComboBx" styleclass="normalTxtBox" value="#{studentBean.rollNo}" valuechangelistener="#{studentBean.getStudentByRollNumber}">
<f:selectitems id="rollNumList" itemvalue="#{rollNum.rollNo}" value="#{studentBean.rollNumbersList}" var="rollNum">
<a4j:support ajaxsingle="true" event="onchange" rerender="studNameTxt,studClassTxt,studAddrTxt">
</a4j:support>
<h:outputtext id="nameLbl" value="Student Name : ">
<h:inputtext id="studNameTxt" value="#{studentBean.studentName}">
<h:outputtext id="classLbl" value="Student Class : ">
<h:inputtext id="studClassTxt" value="#{studentBean.studentClass}">
<h:outputtext id="addrLbl" value="Student Address : ">
<h:inputtext id="studAddrTxt" value="#{studentBean.studentAddress}">
</h:inputtext></h:outputtext></h:inputtext></h:outputtext></h:inputtext></h:outputtext></f:selectitems></h:selectonemenu></h:outputtext>
No comments:
Post a Comment