Example:
selectOneMenu.xhtml
]]>
SelectOneMenuTestBean.java
@ViewScoped
@ManagedBean
public class SelectOneMenuTestBean implements Serializable {
private static final long serialVersionUID = 1435576438526841243L;
private String mode = "dropdown";
private Integer width = 300;
private Integer menuWidth = 300;
private Integer handleWidth = 26;
private Integer maxHeight = null;
private Boolean disabled = false;
private String value = null;
private Integer iconsHeight = 50;
private Integer iconsWidth = 50;
private List items = new ArrayList();
public SelectOneMenuTestBean() {
initItems();
}
private void initItems() {
SelectItem itemBG = new SelectItem();
itemBG.setLabel("Bulgaria");
itemBG.setValue("bg");
itemBG.setDescription(FacesContext.getCurrentInstance()
.getExternalContext().getRequestContextPath()
+ "/img/bg_flag.png");
items.add(itemBG);
SelectItem itemCH = new SelectItem();
itemCH.setLabel("Switzerland");
itemCH.setValue("ch");
itemCH.setDescription(FacesContext.getCurrentInstance()
.getExternalContext().getRequestContextPath()
+ "/img/ch_flag.png");
items.add(itemCH);
SelectItem itemDE = new SelectItem();
itemDE.setLabel("Germany");
itemDE.setValue("de");
itemDE.setDescription(FacesContext.getCurrentInstance()
.getExternalContext().getRequestContextPath()
+ "/img/de_flag.png");
items.add(itemDE);
SelectItem itemFR = new SelectItem();
itemFR.setLabel("France");
itemFR.setValue("fr");
itemFR.setDescription(FacesContext.getCurrentInstance()
.getExternalContext().getRequestContextPath()
+ "/img/fr_flag.png");
items.add(itemFR);
}
public Integer getIconsHeight() {
return iconsHeight;
}
public void setIconsHeight(Integer iconsHeight) {
this.iconsHeight = iconsHeight;
}
public Integer getIconsWidth() {
return iconsWidth;
}
public void setIconsWidth(Integer iconsWidth) {
this.iconsWidth = iconsWidth;
}
public List getItems() {
return items;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getMode() {
return mode;
}
public void setMode(String mode) {
this.mode = mode;
}
public Integer getWidth() {
return width;
}
public void setWidth(Integer width) {
this.width = width;
}
public Integer getMenuWidth() {
return menuWidth;
}
public void setMenuWidth(Integer menuWidth) {
this.menuWidth = menuWidth;
}
public Integer getHandleWidth() {
return handleWidth;
}
public void setHandleWidth(Integer handleWidth) {
this.handleWidth = handleWidth;
}
public Integer getMaxHeight() {
return maxHeight;
}
public void setMaxHeight(Integer maxHeight) {
this.maxHeight = maxHeight;
}
public Boolean getDisabled() {
return disabled;
}
public void setDisabled(Boolean disabled) {
this.disabled = disabled;
}
public String formAction() {
System.out.println("form submit!");
return "";
}
}