Magazine
 
JSF Application
 

{
return showAllSelected;
}
String songvalue=”songSelect”;
/*Value change listener method*/
public void
processValueChange1(ValueChangeEvent
vce){
songvalue = (String) vce.getNewValue();
setSongDetail((String)detail.get(songvalue));
/*Render the response*/
FacesContext.getCurrentInstance().renderResponse();
}
String selectchoice=”No Choice”;
/*Value change listener method*/
public void
processValueChange2(ValueChangeEvent
event){
subCategoryList.setRendered(true);
selectchoice= (String)
event.getNewValue();
if(selectchoice.equals(“ch1”)){
this.subCategories = new ArrayList();
SelectItem suboption = new
SelectItem(“subch1”, “Core Java”);
subCategories.add(suboption);
suboption = new SelectItem(“subch2”,
“Java Script”);
subCategories.add(suboption);
suboption = new SelectItem(“subch3”,
“Ajax”);
subCategories.add(suboption);
this.subCategories = subCategories;
}
if(selectchoice.equals(“ch2”)){
this.subCategories = new ArrayList();
SelectItem suboption2 = new
SelectItem(“subch4”, “Servlet”);
subCategories.add(suboption2);
suboption2 = new SelectItem(“subch5”,
“JSP”);
subCategories.add(suboption2);
suboption2 = new SelectItem(“subch6”,
“JSF”);
subCategories.add(suboption2);
}

 

FacesContext context =
FacesContext.getCurrentInstance();
context.renderResponse();
}
/*Action listener method*/
public void
processActionShow(ActionEvent event){
String bookvalue =
(String)subCategoryList.getSubmittedValue();
String bookname =
getBookName(bookvalue);
if(songvalue.equals(“songSelect”)){
showAllSelected.setValue(“No song
selected. “+bookname+” book selected.”);
}
else{
String songname =
getSongName(songvalue);
showAllSelected.setValue(songname+”
selected. “+bookname+” book selected.”);
}
}
public String getBookName(String
bookvalue){
String bookname = “No”;
if(subCategories == null){
}
else{
ListIterator listItr =
subCategories.listIterator();
while(listItr.hasNext()) {
SelectItem si =
(SelectItem)listItr.next();
String value = (String)(si).getValue();
if(value.equals(bookvalue)) {
bookname = (si).getLabel();
}
}
}
return bookname;
}
public String getSongName(String
songvalue){
String songname=””;
for(int i=0;i<songList.size();i++){
if(((String)(((SelectItem)(songList.get(i))).
getValue())).equals(songvalue)){

Feb 2008 | Java Jazz Up | 57
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 ,

Download PDF