本文整理汇总了Java中javax.faces.component.html.HtmlSelectOneMenu.setOnchange方法的典型用法代码示例。如果您正苦于以下问题:Java HtmlSelectOneMenu.setOnchange方法的具体用法?Java HtmlSelectOneMenu.setOnchange怎么用?Java HtmlSelectOneMenu.setOnchange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.component.html.HtmlSelectOneMenu
的用法示例。
在下文中一共展示了HtmlSelectOneMenu.setOnchange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeSelectOneMenu
import javax.faces.component.html.HtmlSelectOneMenu; //导入方法依赖的package包/类
/**
* Makes a Faces HtmlSelectOneMenu component for a parameter.
* <p/>
* The menu items are based upon the defined codes for the parameter.
* @param context the UI context
* @param section the parent section
* @param parameter the associated parameter
* @param onchange Javascript associated with the "onchange" event
* @return the UI component
*/
protected HtmlSelectOneMenu makeSelectOneMenu(UiContext context,
Section section,
Parameter parameter,
String onchange) {
// initialize the component
MessageBroker msgBroker = context.extractMessageBroker();
HtmlSelectOneMenu component = new HtmlSelectOneMenu();
component.setId(getFacesId());
component.setDisabled(!getEditable());
component.setOnchange(getOnChange());
component.setOnclick(getOnClick());
setComponentValue(context,component,parameter);
onchange = Val.chkStr(onchange);
if (onchange.length() > 0) {
component.setOnchange(onchange);
}
// add each code as a SelectItem
ArrayList<SelectItem> codeItems = new ArrayList<SelectItem>();
Codes codes = parameter.getContent().getCodes();
for (Code code: codes.values()) {
String sResKey = code.getResourceKey();
String sLabel = code.getKey();
if (sResKey.length() > 0) {
sLabel = msgBroker.retrieveMessage(sResKey);
}
codeItems.add(new SelectItem(code.getKey(),sLabel));
}
UISelectItems uiItems = new UISelectItems();
uiItems.setValue(codeItems);
component.getChildren().add(uiItems);
return component;
}