This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jun 12, 2013, 8:36 AM
178 Posts

Setting default value for combo box control

  • Category: Managed Beans in NSF
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: combobox
  • Replies: 1

I am using a managed bean to read/write to a notes document.

I have a managed bean connected to a combobox e.g.:

<xp:comboBox id="cbDefViewRows"
value="#{config.numViewRows}" >
<xp:selectItem itemLabel="5" itemValue="5" />
<xp:selectItem itemLabel="15" itemValue="15" />
<xp:selectItem itemLabel="25" itemValue="25" />
<xp:selectItem itemLabel="50" itemValue="50" />
<xp:selectItem itemLabel="75" itemValue="75" />
<xp:selectItem itemLabel="100" itemValue="100" />
</xp:comboBox>

I want to set the default or selected value e.g.:

<xp:comboBox id="cbDefViewRows"
value="#{config.numViewRows}"
defaultValue="#{javascript:return @Integer(config.numViewRows)}">
<xp:selectItem itemLabel="5" itemValue="5" />
<xp:selectItem itemLabel="15" itemValue="15" />
<xp:selectItem itemLabel="25" itemValue="25" />
<xp:selectItem itemLabel="50" itemValue="50" />
<xp:selectItem itemLabel="75" itemValue="75" />
<xp:selectItem itemLabel="100" itemValue="100" />
</xp:comboBox>

But despite the effort I get the first value highlighted/selected.

I have checked the value via placing a computed text control on the page and check the value for numViewRows which confirms the value corresponds an itemValue (75 in this case).

I also checked to convert the number into text value e.g.:

defaultValue="#{javascript:return @Text(@Integer(config.numViewRows))}"

but this does not work either.

Anyone knows the clue how to set the defaultValue proper to the value stored in the managed bean??

 

Jun 14, 2013, 3:36 PM
17 Posts
getter and setter, with string

Hi Patrick

Funny, i never used number values in a combo but it seems that it doesn't really work.. if you use string, its no problem (not even a default value needed if you set it in the java managed bean):

XPage:

 

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:comboBox id="cbDefViewRows" value="#{config.numViewRows}">
<xp:selectItem itemLabel="5" itemValue="5" />
<xp:selectItem itemLabel="15" itemValue="15" />
<xp:selectItem itemLabel="25" itemValue="25" />
<xp:selectItem itemLabel="50" itemValue="50" />
<xp:selectItem itemLabel="75" itemValue="75" />
<xp:selectItem itemLabel="100" itemValue="100" />
</xp:comboBox>
</xp:view>
 

Java Class:

 

package com.test;
 
public class Config {
 
private String numViewRows = "75";
 
public String getNumViewRows() {
return numViewRows;
}
 
public void setNumViewRows(String numViewRows) {
this.numViewRows = numViewRows;
}
 
 
}
 

Also when i used a converter in the xpage (integer only) it didn't work.. mbe its best to just convert it in your java class and handle the values as strings (ugly i know..).

have a nice weekend

 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal