dcsimg
Getting a selected checkbox belonging to a checkboxgroup which are created dynamically depending on ResultSet records.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Siddharth_Arora
Posted On:   Thursday, December 27, 2001 11:58 PM

My java application connects to a database, retrieves a ResultSet and displays the records with a checkbox for each record, belonging to a checkbox group, for a user to select a particular option. For eg. - while(rs.next()) { add new Checkbox(rs.getString(1),CheckboxGroup,false); } add(new Button("Submit")); public void actionPerformed(ActionEvent ae) { System.out.println(CheckboxGroup.getSelectedCheckbox().getLabel()); } This throws a NullPointerException probably because the reference to the checkboxes is not defined. But how do i define the reference to each checkbox added as they are dynamically being added depending upon the    More>>

My java application connects to a database, retrieves a ResultSet and displays the records with a checkbox for each record, belonging to a checkbox group, for a user to select a particular option.


For eg. -

			
while(rs.next())
{
add new Checkbox(rs.getString(1),CheckboxGroup,false);
}
add(new Button("Submit"));
public void actionPerformed(ActionEvent ae)
{
System.out.println(CheckboxGroup.getSelectedCheckbox().getLabel());
}


This throws a NullPointerException probably because the reference to the checkboxes is not defined. But how do i define the reference to each checkbox added as they are dynamically being added depending upon the number of records in the ResultSet.
Please Help !!    <<Less
About | Sitemap | Contact