<rich:comboBox>: Backing bean value is lost after second ref
ma.aqcon Apr 3, 2008 5:50 AMHi all,
I want to use the new <rich:comboBox> for my application, but I'm facing some problems that the backing bean value is lost after the second refresh of an area ...
I have the following example page:
<h:form id="test">
<rich:panel id="orderHead">
<a4j:commandButton id="com" reRender="part" action="#{suggest.setProp2}" value="Refresh"/>
<rich:panel id="part">
<rich:comboBox value="#{suggest.property}">
<f:selectItems value="#{suggest.comboSelectItems}" />
</rich:comboBox>
<h:outputText id="propOut" value="#{suggest.property}" /><br/>
<h:outputText id="propOut2" value="#{suggest.property2}" /><br/>
</rich:panel>
</rich:panel>
</h:form>
With the following backing bean code:
import java.util.Date;
import javax.faces.model.SelectItem;
/**
* Test bean for rich:comboBox
*
*/
public class SuggestBean {
// Property bind to the combo box
private String property;
// Property to verify re-rendering
private String property2;
private SelectItem[] comboSelectItems = { new SelectItem("Test", "Test"), new SelectItem("Test2", "Test2"), new SelectItem("Test3", "Test3") };
/**
* Updates property2 with current date.
*/
public void updateProperty2() {
// Only to verify the re-rendering is done
setProperty2((new Date()).toString());
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
public String getProperty2() {
return property2;
}
public void setProperty2(String property2) {
this.property2 = property2;
}
public SelectItem[] getComboSelectItems() {
return comboSelectItems;
}
public void setComboSelectItems(SelectItem[] comboSelectItems) {
this.comboSelectItems = comboSelectItems;
}
}
The bean has two properties, one is bound as value to the combo box, the other property is updated with the current date if updateProperty2() method is called.
If I press the "refresh" button for the first time, everything is fine (poperty2 is updated with the current date, property 1 contains my comboBox selection). If I press the button again, the date is updated but the property value is removed (from comboBox and h:outputText!).
Am I doing something wrong or is it a but? Unfortunately there is no example in the demo application where a backing bean value is bind to a combo box!
Thanks & Regards
Michael