| Author |
Programatically manipulate a component
|
Terry Jeske
Greenhorn
Joined: Apr 06, 2004
Posts: 17
|
|
In my backing bean can I retrieve and manipulate the properties of a UI component? For example, I have a datatable who's default value is set to null. On the postback, I want a combobox's ValueChangeEvent handler to get an instance of the datatable, and change it's value property with a bean method that will populate the table (this may be the wrong way, but I am trying to work around JSF's lack of postback handling -arrrgh!). I thought that if I got the current facesContext, and then got the application, that I should be able to get an instance of a component. But it appears that I can only create components using this technique. I tried the following: FacesContext facesContext = FacesContext.getCurrentInstance(); facesContext.getApplication().??? Any ideas. Any better ways to handle postbacks?
|
 |
Varun Khanna
Ranch Hand
Joined: May 30, 2002
Posts: 1400
|
|
Are you looking for this? FacesContext.getCurrentInstance().getViewRoot().findComponent("form:componentId")); where in "form:componentId" - form is the name of your form componentId is the id of the component in that form.
|
- Varun
|
 |
Abhi Raj
Greenhorn
Joined: Sep 08, 2004
Posts: 7
|
|
Also you can create a component binding which binds the component to a backing bean. e.g. <h utputText binding="#{bean.text}" /h> Then, the bean contains an attribute : HtmlOutputText text You can directly manipulate properties of the component from this reference.
|
 |
 |
|
|
subject: Programatically manipulate a component
|
|
|