Hi, On selection of a dropdown i,m calling onChange method in that setting Global variables with some data. The Global variables are binded to the InputText boxes in the form. But my problem is those setted values are not displaying in the form after Onchange dropdown but it is setting in bean variables(tested with System.out.print)
JSP : <ig:dropDownList binding="#{Page1.htmlDropDownList1}" dataSource="#{Page1.list}" id="htmlDropDownList1" smartRefreshIds="textField1"
Okay so here are a sample JSP and backing bean that do what you want, assuming that I've understood you properly.
I hope this solves your issue and thanks for your questions! :)
THE JSP
<f:view> <h:form id="DropDownExample"> <ig:dropDownList id="dd1" dataSource="#{dropDown.ddList}" binding="#{dropDown.dd1}" valueChangeListener="#{dropDown.onChange}" smartRefreshIds="inp1" > </ig:dropDownList> <h:inputText id="inp1" value="#{dropDown.inp1Value}"> </h:inputText> </h:form> </f:view>
THE BACKING BEAN
import java.util.ArrayList;import javax.faces.event.ValueChangeEvent;import javax.faces.model.SelectItem;import com.infragistics.faces.input.component.html.HtmlDropDownList;public class DropDownExample { private HtmlDropDownList dd1; private String inp1Value; private ArrayList ddList; private String holder; public ArrayList getDdList() { if(null == ddList) { ddList = new ArrayList(); ddList.add(new SelectItem("red", "Red")); ddList.add(new SelectItem("green", "Green")); ddList.add(new SelectItem("blue", "Blue")); } return ddList; } public void setDdList(ArrayList ddList) { this.ddList = ddList; } public void onChange(ValueChangeEvent e) { holder = (String)e.getNewValue(); } public HtmlDropDownList getDd1() { return dd1; } public void setDd1(HtmlDropDownList dd1) { this.dd1 = dd1; } public String getInp1Value() { if(holder != null) inp1Value = holder; return inp1Value; } public void setInp1Value(String inp1Value) { this.inp1Value = inp1Value; } }
HiThanks for your early reply.The solution you provided that doesn't suit to my problem.My problem is : I have to show Dropdown selected value on the Text box.For Example : In my dropdown i have "A" , "B" , "C"----> if i select A then A should display on the Text box--> on selecting B that should display on text box. pls provide me the better solution with one exampleWaiting for your early replyRgdsAslam
You should not use the setFld method to control the value of fld. In JSF the setters are used by the JSF framework to update values arriving from the browser.
Instead, use the getFld method. When JSF wants to get the value of fld, this is the method it'll use.
So, you might pattern your code like this:
public class Bean {
private boolean male;
public void onChange(ActionEvent e) {
if(e.newValue().equals("male")) male=true;
else male = false;
}
public String getFld() {
if(male) return "Hello Sir";
else return "Hello Miss";
Hello, Aslam!
Please, would you provide me some more information about the version of NetAdventage you're using and probably send us some more detailed samples, so that we can help you. You can also have a look at the example at http://java.samples.infragistics.com/ under WebInput - DropDownList, which as far as I understand is mostly close to the situation you described. Thanks!
--Bozhidar