You need to assign ValueBinding objects, not strings.
You'd typically do something like this [example borrowed and modified
from another posting]:
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
reportingPeriodsSelectItemsControl.setValueBinding("itemLabel",
app.createValueBinding("#{rptPeriod.reportingDateMonthly}"));
On 4/20/07, Leyzerzon, Simeon <[EMAIL PROTECTED]> wrote:
Hi,
I need to create the following construct dynamically in the backing bean:
==============================================================================================
<h:outputText value="Reporting Period" />
<h:selectOneMenu
value="#{searchHandler.reportingPeriod.rawDate}"
binding="#{searchHandler.reportingPeriodSelectOneMenuControl}">
<t:selectItems value="#{searchHandler.reportingPeriods}"
var="rptPeriod"
itemLabel="#{rptPeriod.reportingDateMonthly}"
itemValue="#{rptPeriod.rawDate}"
binding="#{searchHandler.reportingPeriodsSelectItemsControl}"
/>
</h:selectOneMenu>
==============================================================================================
So I'm doing the following in my setter:
==============================================================================================
public void setReportingPeriodSelectOneMenuControl(
HtmlSelectOneMenu
reportingPeriodSelectOneMenuControl) {
if (reportingPeriods == null){
logger.debug("reportingPeriods == null: " +
(reportingPeriods==null) + "building reportingPeriods
list...");
reportingPeriods =
this.getSearchService().getReportingPeriods();
}
//building <t:selectItems>
if (reportingPeriodsSelectItemsControl == null){
reportingPeriodsSelectItemsControl =
(UISelectItems) FacesContext
.getCurrentInstance().getApplication().createComponent(
UISelectItems.COMPONENT_TYPE);
}
reportingPeriodsSelectItemsControl.setValue(reportingPeriods);
reportingPeriodsSelectItemsControl.setVar("rptPeriod");
String label = null;
if (DAILY.equals(this.getPeriod())) {
label = "#{rptPeriod.reportingDateDaily}";
}else if (MONTHLY.equals(this.getPeriod())) {
label = "#{rptPeriod.reportingDateMonthly}";
}
reportingPeriodsSelectItemsControl.setItemLabel(label);
reportingPeriodsSelectItemsControl.setItemValue("#{rptPeriod.rawDate}");
reportingPeriodSelectOneMenuControl.getChildren().add(reportingPeriodsSelectItemsControl);
this.reportingPeriodSelectOneMenuControl =
reportingPeriodSelectOneMenuControl;
logger.debug("setReportingPeriodSelectOneMenuControl()"
+ reportingPeriodSelectOneMenuControl);
}
================================================================================================
Unfortunately, what I am getting in the page is the combo populated with a
bunch of strings: #{rptPeriod.reportingDateMonthly}
What am I missing here to link this variable 'rtpPeriod' to the value
binding expression. Or should there be a different syntax?
Thanks for you help.
Simeon
==============================================================================
Please access the attached hyperlink for an important electronic
communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================