JSF中得到selectOneMenu的使用
来源:互联网 发布:tpshop源码 编辑:程序博客网 时间:2024/05/16 08:43
首先我在网页中
<h:form rendered="true">
选择要设置的文件名称:
<h:selectOneMenu id="wj" required="true" binding="#{WjlcBean.wjMenu}">
<f:selectItems value="#{WjBean.notSetWj}" />
</h:selectOneMenu>
<h:panelGrid>
<h:panelGroup>
<h:commandButton value="设置文件流程" action="#{WjlcBean.addAction}" />
</h:panelGroup>
</h:panelGrid>
</h:form>
选择要设置的文件名称:
<h:selectOneMenu id="wj" required="true" binding="#{WjlcBean.wjMenu}">
<f:selectItems value="#{WjBean.notSetWj}" />
</h:selectOneMenu>
<h:panelGrid>
<h:panelGroup>
<h:commandButton value="设置文件流程" action="#{WjlcBean.addAction}" />
</h:panelGroup>
</h:panelGrid>
</h:form>
给这个selectItems赋值时是这样的(WjlcBean.notSetWj),一个Java方法:
public ArrayList getNotSetWj() throws WorkflowWjException...{
List notSetWj=this.getWorkflowWjService().browserNotset();//这个从数据库中得到数据的list
//用迭代器遍历这个List
Iterator iWj=notSetWj.iterator();
ArrayList aList=new ArrayList();
while(iWj.hasNext())...{
WorkflowWj wjL=(WorkflowWj)iWj.next();
//这个就是selectItem的值,第一个是ID(不显示),第二个是value(显示的)
SelectItem itemNotSetWj=new SelectItem(wjL.getWjid(),wjL.getMc());
aList.add(itemNotSetWj);
}
return aList;
}
List notSetWj=this.getWorkflowWjService().browserNotset();//这个从数据库中得到数据的list
//用迭代器遍历这个List
Iterator iWj=notSetWj.iterator();
ArrayList aList=new ArrayList();
while(iWj.hasNext())...{
WorkflowWj wjL=(WorkflowWj)iWj.next();
//这个就是selectItem的值,第一个是ID(不显示),第二个是value(显示的)
SelectItem itemNotSetWj=new SelectItem(wjL.getWjid(),wjL.getMc());
aList.add(itemNotSetWj);
}
return aList;
}
这时这个SelectOneMemu就有值了,但是怎么再得到它的值,费了好半天劲才弄出来,这要用到两个类UISelectItems和SelectItem,代码如下:
//得到选择的文件名称
Iterator itawj = this.wjMenu.getChildren().iterator();
while (itawj.hasNext()) ...{
UISelectItems sitwj = (UISelectItems) itawj.next();
//又一次迭代,注意这里是getValue,还有返回是一个ArrayList
Iterator itawjItem = ((ArrayList) (sitwj.getValue())).iterator();
while (itawjItem.hasNext()) ...{
SelectItem ustwj = (SelectItem) itawjItem.next();
if ((ustwj.getValue().toString()).equals(this.wjMenu.getValue()
.toString())) ...{
//设置文件名称
newLcwjdy.setWjmc(ustwj.getLabel());
}
}
}
Iterator itawj = this.wjMenu.getChildren().iterator();
while (itawj.hasNext()) ...{
UISelectItems sitwj = (UISelectItems) itawj.next();
//又一次迭代,注意这里是getValue,还有返回是一个ArrayList
Iterator itawjItem = ((ArrayList) (sitwj.getValue())).iterator();
while (itawjItem.hasNext()) ...{
SelectItem ustwj = (SelectItem) itawjItem.next();
if ((ustwj.getValue().toString()).equals(this.wjMenu.getValue()
.toString())) ...{
//设置文件名称
newLcwjdy.setWjmc(ustwj.getLabel());
}
}
}
这次多亏了同事的帮忙!!!!
- JSF中得到selectOneMenu的使用
- JSF中得到selectOneMenu的使用
- JSF的SelectOneMenu绑定数据库的数据
- JSF中selectonemenu中前后台交互的问题和javascript访问h:form中控件的问题
- 利用JS实现JSF页面h:selectOneMenu的联动
- 利用JS实现JSF页面h:selectOneMenu的联动
- 设置jsf的选择框h:selectOneMenu为不可编辑状态
- 如何利用js得到h:selectOneMenu所选中的label值或value值
- JSF中facelets的使用以及JSF国际化问题
- JSF框架中使用的设计模式
- JSF中使用Tiles
- JSF中使用CSS
- JSF中使用jquery
- JSF中使用UEditor
- primefaces的selectonemenu的奇怪的规定
- JSF转换器的使用
- JSF el中使用enum
- 在JSF中使用enum
- 那一年的北风--序言3
- 看成败,人生豪迈
- 生辰
- 苏醒
- 关于故去的和得到的
- JSF中得到selectOneMenu的使用
- 基于JAVA的OpenOffice1.1开发环境配置指南
- javax.faces.el.PropertyNotFoundException
- Windows Workflow Foundation (wwf) 学习笔记(一)
- Windows Workflow Foundation (wwf) 学习笔记(二)
- 破解网页右键菜单被禁止的方法
- ubuntu scim输入中文的问题
- Timer,TimerTask简单讲解
- 今天我想测试一下,这个