rich:pickList标签的使用
2015-07-01 13:36
260 查看
使用标签之前要引入:xmlns:rich="http://richfaces.org/rich"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:i="http://www.fhdata.com/jsf"
xmlns:rich="http://richfaces.org/rich">
<h:head>
<title>选择显示的列</title>
<script type="text/javascript">
//<![CDATA[
function saveEnd() {
window.close();
return false;
}
//]]>
</script>
</h:head>
<h:body>
<h:form id="SelectColumnForm">
<rich:pickList converter="#{staffConverter}" id="selectedItem" value="#{productBean.selectedTradeSystemIndex}" targetCaption="已选项"
sourceCaption="待选项" listWidth="200px" listHeight="320px" orderable="true" addAllText=">>>" addText=">"
removeAllText="<<<" removeText="<" downText="Down" upText="Up" upTopText="First" downBottomText="Last">
<f:selectItems value="#{productBean.selectedIndex}" />
<f:selectItems value="#{productBean.unSelectedIndex}" />
</rich:pickList>
<t:div id="operateBtn" style="position:fixed;right:0;bottom:0">
<h:panelGrid columns="2" style="float:right;" cellspacing="5px">
<a4j:commandButton id="okBtn" styleClass="btn" value="确定" action="#{productBean.changeIndex}" oncomplete="return saveEnd();"/>
<h:commandButton id="cancelBtn" styleClass="btn" value="取消" onclick="window.close();return false;"/>
</h:panelGrid>
</t:div>
</h:form>
</h:body>
</html>
对应的bean:
public class productBean{
private List<String> selectedIndex;
public List<String> getSelectedIndex() throws SQLException {
List<String> selectedIndexs = new ArrayList<String>();
selectedIndexs .add("cc");
selectedIndexs .add("dd");
return selectedIndexs ;
}
public List<String> getUnSelectedIndex() throws SQLException {
List<String> unSelectedIndexs = new ArrayList<String>();
unSelectedIndexs .add("aa");
unSelectedIndexs .add("bb");
return unSelectedIndexs ;
}
public void setSelectedIndex(List<String> selectedIndex) {
this.selectedIndex= selectedIndex;
}
public void changeIndex() {
//根据得到的selectedIndex的值进行处理
}
}
xhtml页面写的rich:pickList标签,value对应的是右侧区域显示的内容,具体的内容来自于它下面对应的第一个f:selectItem标签里面的内容,左侧的区域来自于第二个f:selectItem标签,页面加载后,左侧区域显示cc,dd,右侧区域显示aa,bb
点击页面上的保存按钮,此时,会调用setSelectedIndex方法,将页面上选中的右侧区域的值赋值给 this.selectedIndex,此时就可以得到选中区域的值
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:i="http://www.fhdata.com/jsf"
xmlns:rich="http://richfaces.org/rich">
<h:head>
<title>选择显示的列</title>
<script type="text/javascript">
//<![CDATA[
function saveEnd() {
window.close();
return false;
}
//]]>
</script>
</h:head>
<h:body>
<h:form id="SelectColumnForm">
<rich:pickList converter="#{staffConverter}" id="selectedItem" value="#{productBean.selectedTradeSystemIndex}" targetCaption="已选项"
sourceCaption="待选项" listWidth="200px" listHeight="320px" orderable="true" addAllText=">>>" addText=">"
removeAllText="<<<" removeText="<" downText="Down" upText="Up" upTopText="First" downBottomText="Last">
<f:selectItems value="#{productBean.selectedIndex}" />
<f:selectItems value="#{productBean.unSelectedIndex}" />
</rich:pickList>
<t:div id="operateBtn" style="position:fixed;right:0;bottom:0">
<h:panelGrid columns="2" style="float:right;" cellspacing="5px">
<a4j:commandButton id="okBtn" styleClass="btn" value="确定" action="#{productBean.changeIndex}" oncomplete="return saveEnd();"/>
<h:commandButton id="cancelBtn" styleClass="btn" value="取消" onclick="window.close();return false;"/>
</h:panelGrid>
</t:div>
</h:form>
</h:body>
</html>
对应的bean:
public class productBean{
private List<String> selectedIndex;
public List<String> getSelectedIndex() throws SQLException {
List<String> selectedIndexs = new ArrayList<String>();
selectedIndexs .add("cc");
selectedIndexs .add("dd");
return selectedIndexs ;
}
public List<String> getUnSelectedIndex() throws SQLException {
List<String> unSelectedIndexs = new ArrayList<String>();
unSelectedIndexs .add("aa");
unSelectedIndexs .add("bb");
return unSelectedIndexs ;
}
public void setSelectedIndex(List<String> selectedIndex) {
this.selectedIndex= selectedIndex;
}
public void changeIndex() {
//根据得到的selectedIndex的值进行处理
}
}
xhtml页面写的rich:pickList标签,value对应的是右侧区域显示的内容,具体的内容来自于它下面对应的第一个f:selectItem标签里面的内容,左侧的区域来自于第二个f:selectItem标签,页面加载后,左侧区域显示cc,dd,右侧区域显示aa,bb
点击页面上的保存按钮,此时,会调用setSelectedIndex方法,将页面上选中的右侧区域的值赋值给 this.selectedIndex,此时就可以得到选中区域的值
相关文章推荐
- ios json数据解析
- Assert()
- Windows Server 2012部署Enterprise Solution 5.4
- DSR on Openstack POC
- Shortest Palindrome leetcode-java
- 扎克伯格:我们为何要研究人工智能和虚拟现实
- Shell脚本之数组
- 8天学通MongoDB——第四天 索引操作
- db2日志报错 Bad Queue Handle
- MySQL 自增列插入0值的方法
- RMAN-06059: expected archived log not found, loss of archived log compromises recoverability
- DNS服务器
- Qt获取当前时间
- iOS 某些特殊名词的意思
- UILabel,文字添加下划线,中划线
- 在ScrollView中嵌入GridView
- 扎克伯格:我们为什么要研究人工智能与虚拟现实?
- Android 4.1.2系统添加重启功能
- 持续更新中 --- iOS移动开发中的优质资源
- Objective-C第六版第11章---Categroies and delegate