Radio Buttons Auto-Submit on change throws IndexOutOfBoundsException

Hi

On my page I have 2 radio buttons with Auto-submit on change activated for the 2 radio buttons, if any of the 2 radio button is check its sets some values picked from the database to some static text components,the logic is working fine but after clicking any of the radio button alternatively for some time it throws an IndexOutOfBoundsException, here is the error page below:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Index: 0, Size: 0

javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)

com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)

root cause

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

java.util.ArrayList.RangeCheck(ArrayList.java:547)

java.util.ArrayList.remove(ArrayList.java:387)

javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:253)

javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:307)

com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase .java:79)

com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)

com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)

com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

[1592 byte] By [JohnnyFlipa] at [2007-11-27 7:10:37]
# 1
Hi There,How are you handling the radio button clicks? Are you using any arrays?Please post your code? What part of the code is causing this error?ThanksK
kish@suna at 2007-7-12 19:02:10 > top of Java-index,Development Tools,Java Tools...
# 2

public String new_badge_processValueChange(ValueChangeEvent event) {

// TODO: Replace with your code

try{

if(new_badge.isChecked()){

String staff_val =(String)getStaff_id().getText();

if((staff_val== null ||staff_val.equals(""))){

error("You must specify Staff ID");

return null;

}

badge_type ="New";

dept_id ="CA0C000";

CachedRowSet staffRowSet = new CachedRowSetXImpl();

try{

System.out.println("I'm here 1");

staffRowSet.setDataSourceName("java:comp/env/jdbc/idbadge");

staffRowSet.setTableName("VWSTAFF_");

staffRowSet.setCommand("SELECT * FROM VWSTAFF_ WHERE STAFF_ID ='"+staff_val+"'");

staffRowSet.execute();

staffRowSet.last();

System.out.println("execute()");

int currentRow =staffRowSet.getRow();

System.out.println("currentRow "+currentRow);

if(currentRow ==0){

error("Staff does not exist");

return null;

}else if(currentRow ==1){

System.out.println("STAFF_ID "+(String)getStaff_id().getText());

getRequestBean1().setAutocomplete(sfm.auto_query_list((String)getStaff_id().get Text()));

getRequestBean1().setAutocom(dm.managers_query_list(dept_id,badge_type,(String) getStaff_id().getText()));

String val1=(String)getRequestBean1().getAutocomplete().getPersonel_id();

System.out.println("val one "+val1);

System.out.println("\n ============================start=========================");

personal_id =(String)getRequestBean1().getAutocomplete().getPersonel_id();

System.out.println("\n ============================start=========================");

System.out.println("\n personal_id as a variable "+personal_id);

System.out.println("\n Surname frm session "+ getRequestBean1().getAutocomplete().getSname());

System.out.println("\n first name frm session "+ getRequestBean1().getAutocomplete().getFname());

System.out.println("\n personal_id frm session "+ getRequestBean1().getAutocomplete().getPersonel_id());

System.out.println("\n igg frm session "+ getRequestBean1().getAutocomplete().getIgg());

System.out.println("\n dateofbirth frm session "+ getRequestBean1().getAutocomplete().getDateofbir());

System.out.println("\n dept name frm session "+ getRequestBean1().getAutocomplete().getDept());

System.out.println("\n dept id frm session "+ getRequestBean1().getAutocomplete().getDept_id());

System.out.println("\n exten frm session "+ getRequestBean1().getAutocomplete().getExten());

System.out.println("\n location frm session "+ getRequestBean1().getAutocomplete().getLocation());

System.out.println("STaFF_ID "+(String)getStaff_id().getText());

}

} catch(Exception x){

System.out.println();

}

}

}catch(IndexOutOfBoundsException xc){

error("Try again !");

System.out.println("New Radio Button "+xc);

}

return null;

}

public String replacement_processValueChange(ValueChangeEvent vce) {

// TODO: Replace with your code

try{

if(replacement.isChecked()){

String staff_val =(String)getStaff_id().getText();

if((staff_val== null ||staff_val.equals(""))){

error("You must specify Staff ID");

return null;

}

badge_type ="Replacement";

dept_id =(String)getStaff_id().getText();

CachedRowSet staffRowSet = new CachedRowSetXImpl();

try{

System.out.println("I'm here 1");

staffRowSet.setDataSourceName("java:comp/env/jdbc/idbadge");

staffRowSet.setTableName("VWSTAFF_");

staffRowSet.setCommand("SELECT * FROM VWSTAFF_ WHERE STAFF_ID ='"+staff_val+"'");

staffRowSet.execute();

staffRowSet.last();

System.out.println("execute()");

int currentRow =staffRowSet.getRow();

System.out.println("currentRow "+currentRow);

if(currentRow ==0){

error("Staff does not exist");

return null;

}else if(currentRow ==1){

System.out.println("STAFF_ID "+(String)getStaff_id().getText());

getRequestBean1().setAutocomplete(sfm.auto_query_list((String)getStaff_id().get Text()));

getRequestBean1().setAutocom(dm.managers_query_list(dept_id,badge_type,(String) getStaff_id().getText()));

String val1=(String)getRequestBean1().getAutocomplete().getPersonel_id();

System.out.println("val one "+val1);

System.out.println("\n ============================start=========================");

personal_id =(String)getRequestBean1().getAutocomplete().getPersonel_id();

System.out.println("\n ============================start=========================");

System.out.println("\n personal_id as a variable "+personal_id);

System.out.println("\n Surname frm session "+ getRequestBean1().getAutocomplete().getSname());

System.out.println("\n first name frm session "+ getRequestBean1().getAutocomplete().getFname());

System.out.println("\n personal_id frm session "+ getRequestBean1().getAutocomplete().getPersonel_id());

System.out.println("\n igg frm session "+ getRequestBean1().getAutocomplete().getIgg());

System.out.println("\n dateofbirth frm session "+ getRequestBean1().getAutocomplete().getDateofbir());

System.out.println("\n dept name frm session "+ getRequestBean1().getAutocomplete().getDept());

System.out.println("\n dept id frm session "+ getRequestBean1().getAutocomplete().getDept_id());

System.out.println("\n exten frm session "+ getRequestBean1().getAutocomplete().getExten());

System.out.println("\n location frm session "+ getRequestBean1().getAutocomplete().getLocation());

System.out.println("STaFF_ID "+(String)getStaff_id().getText());

}

} catch(Exception x){

System.out.println();

}

}

}catch(IndexOutOfBoundsException io){

error("Try again !");

System.out.println("Replacement radio button "+io);

}

return null;

}

JohnnyFlipa at 2007-7-12 19:02:10 > top of Java-index,Development Tools,Java Tools...