-
1. Re: valueChangeListener not working
jhuska May 29, 2013 8:08 AM (in response to aadi03)Hello Ganesh,
two things:
1. Are you sure that your complete facelet you are using has h:head and h:body tags where it is all nested ? Like it is done in the template for the demo in showcase here:
2. Are you sure that your backing bean is correct ?
Nevertheless I would like to recommend you to start with the richfaces archetypes to gain some experience. Look at developer guide how to do it:
-
2. Re: valueChangeListener not working
iabughosh May 29, 2013 10:27 AM (in response to aadi03)hello ganesh,
you need to modify a4j:ajax event to this :
<a4j:ajax event="change" render="second" execute="@this" />
regards.
-
3. Re: valueChangeListener not working
aadi03 May 29, 2013 2:18 PM (in response to iabughosh)Hi all,
Thank's for your reply Ibrahim & Juraj,
Ibrahim i try your suggestion before but it can't work for me,
What i notice is that event is not fired while changing value in selectItems.
List of jar which i am using
1. cssparser-0.9.5.jar
2. guava-10.0.1.jar
3. javax.faces-2.1.5.jar
4. jaxb-api.jar
5. richfaces-components-api-4.3.2.Final.jar
6. richfaces-components-ui-4.3.2.Final.jar
7. richfaces-core-api-4.3.2.Final.jar
8. richfaces-core-impl-4.3.2.Final.jar
9. sac-1.3.jar
Bleow is my bean class.
package com.dw;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import java.io.Serializable;
/**
* @author Ilya Shaikovsky
*/
@ManagedBean(name = "selectsBean")
@RequestScoped
public class SelectsBean{
private static final String[] FRUITS = { "", "Banana", "Cranberry", "Blueberry", "Orange" };
private static final String[] VEGETABLES = { "", "Potatoes", "Broccoli", "Garlic", "Carrot" };
private String currentItem = "";
private String currentType = "";
private List<SelectItem> firstList = new ArrayList<SelectItem>();
private List<SelectItem> secondList = new ArrayList<SelectItem>();
public SelectsBean() {
SelectItem item = new SelectItem("", "");
firstList.add(item);
item = new SelectItem("fruits", "Fruits");
firstList.add(item);
item = new SelectItem("vegetables", "Vegetables");
firstList.add(item);
for (int i = 0; i < FRUITS.length; i++) {
item = new SelectItem(FRUITS[i]);
}
}
public List<SelectItem> getFirstList() {
return firstList;
}
public List<SelectItem> getSecondList() {
return secondList;
}
public static String[] getFRUITS() {
return FRUITS;
}
public static String[] getVEGETABLES() {
return VEGETABLES;
}
public void valueChanged(ValueChangeEvent event) {
secondList.clear();
if (null != event.getNewValue()) {
String[] currentItems;
if (((String) event.getNewValue()).equals("fruits")) {
currentItems = FRUITS;
} else {
currentItems = VEGETABLES;
}
for (int i = 0; i < currentItems.length; i++) {
SelectItem item = new SelectItem(currentItems[i]);
secondList.add(item);
}
}
}
public String getCurrentType() {
return currentType;
}
public void setCurrentType(String currentType) {
this.currentType = currentType;
}
public String getCurrentItem() {
return currentItem;
}
public void setCurrentItem(String currentItem) {
this.currentItem = currentItem;
}
}
-
4. Re: valueChangeListener not working
aadi03 May 30, 2013 2:47 PM (in response to aadi03)Hi All,
Thank's it's working now.