ADF中如何将两个独立的LOV实现级联
来源:互联网 发布:点击访问fc2最新域名 编辑:程序博客网 时间:2024/06/15 19:25
在网上看到很多基于一个VO中的两个Atttribute的LOV实现级联的例子,本文描述如何将两个独立的LOV实现级联,以Oracle实例数据库HR中的DEPARTMENTS和LOCATIONS两个表为例,根据DEPARTMENT中的列location_id过滤department列表的值。
1.建立ADF项目DepartmentView的Query如下
- SELECT Departments.DEPARTMENT_ID,
- Departments.DEPARTMENT_NAME,
- Departments.MANAGER_ID,
- Departments.LOCATION_ID
- FROM DEPARTMENTS Departments
- WHERE (Departments.LOCATION_ID = :locationId or :locationId is null)
locationId的值设置为adf.context.requestScope.
locationIdvlaueType选择Expression
2.建Backing Bean
- package view;
- import javax.faces.component.UIComponent;
- import javax.faces.event.ValueChangeEvent;
- import oracle.adf.model.binding.DCIteratorBinding;
- import oracle.adf.share.ADFContext;
- import oracle.jbo.Row;
- import oracle.jbo.server.ViewRowImpl;
- import oracle.jbo.uicli.binding.JUCtrlListBinding;
- import oracle.jbo.uicli.binding.JUIteratorBinding;
- public class CascadeLOVBean {
- /**
- * 要获取触发LOV的属性
- */
- private String attributeName;
- /**
- * 要传的参数名
- */
- private String parameterName;
- /**
- * 触发LOV的List Binding
- */
- private JUCtrlListBinding listBinding;
- /**
- * 被触发LOV的Iterator Binding
- */
- private DCIteratorBinding iteratorBinding;
- public CascadeLOVBean() {
- super();
- }
- //获取下触发下拉列表的值,并将值放入Request Scope,VO中使用Groovy表达式取得
- public void valueChangeListener(ValueChangeEvent valueChangeEvent) {
- if (valueChangeEvent.getNewValue() != valueChangeEvent.getOldValue()) {
- Integer newValue = (Integer)valueChangeEvent.getNewValue();
- ViewRowImpl row = (ViewRowImpl)listBinding.getValueFromList(newValue);
- Object paramValue = row.getAttribute(attributeName);
- ADFContext.getCurrent().getRequestScope().put(parameterName, paramValue);
- iteratorBinding.executeQuery();
- }
- }
- public void setListBinding(JUCtrlListBinding listBinding) {
- this.listBinding = listBinding;
- }
- public JUCtrlListBinding getListBinding() {
- return listBinding;
- }
- public void setIteratorBinding(DCIteratorBinding iteratorBinding) {
- this.iteratorBinding = iteratorBinding;
- }
- public DCIteratorBinding getIteratorBinding() {
- return iteratorBinding;
- }
- public void setAttributeName(String attributeName) {
- this.attributeName = attributeName;
- }
- public String getAttributeName() {
- return attributeName;
- }
- public void setParameterName(String parameterName) {
- this.parameterName = parameterName;
- }
- public String getParameterName() {
- return parameterName;
- }
- }
3.配置Backing Bean,给CascadeLOVBean中的属性赋值
- <?xml version="1.0" encoding="UTF-8" ?>
- <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
- <managed-bean id="__2">
- <managed-bean-name id="__3">CascadeLOVBean</managed-bean-name>
- <managed-bean-class id="__1">view.CascadeLOVBean</managed-bean-class>
- <managed-bean-scope id="__4">request</managed-bean-scope>
- <managed-property id="__7">
- <property-name id="__5">listBinding</property-name>
- <value id="__6">#{bindings.LocationList}</value>
- </managed-property>
- <managed-property id="__9">
- <property-name id="__10">iteratorBinding</property-name>
- <value id="__8">#{bindings.DepartmentsView1Iterator}</value>
- </managed-property>
- <managed-property id="__12">
- <property-name id="__11">attributeName</property-name>
- <value id="__13">LocationId</value>
- </managed-property>
- <managed-property id="__16">
- <property-name id="__14">parameterName</property-name>
- <value id="__15">locationId</value>
- </managed-property>
- </managed-bean>
- </adfc-config>
4. 页面,给location list绑定CascadeLOVBean的valueChangeListener方法,将Department List的partialTriggers指向Location List
- <af:panelFormLayout id="pfl1">
- <af:selectOneChoice label="Location"
- value="#{bindings.LocationList.inputValue}"
- id="soc1"
- valueChangeListener="#{CascadeLOVBean.valueChangeListener}"
- autoSubmit="true">
- <f:selectItems value="#{bindings.LocationList.items}" id="si1"/>
- </af:selectOneChoice>
- <af:selectOneChoice label="Department"
- value="#{bindings.DepartmentList.inputValue}"
- id="soc2" partialTriggers="soc1">
- <f:selectItems value="#{bindings.DepartmentList.items}"
- id="si2"/>
- </af:selectOneChoice>
- <af:commandButton actionListener="#{bindings.ExecuteWithParams.execute}"
- text="Search"
- disabled="#{!bindings.ExecuteWithParams.enabled}"
- id="cb1"/>
- </af:panelFormLayout>
程序包请到以下连接下载
http://download.csdn.net/detail/ygj26/4077019
或
http://www.jdeveloper.com.cn/forum.php?mod=viewthread&tid=7
转自:http://blog.csdn.net/ygj26/article/details/7277447
0 0
- ADF中如何将两个独立的LOV实现级联
- ADF11g-007:ADF中如何将两个独立的LOV实现级联
- Oracle ADF之 LOV 级联下拉菜单
- MFC中如何将两个独立的程序合并为一个程序(障眼法)
- 关于ADF inputListOfValues(LOV)的列宽度
- 如何Android项目变成两个独立的项目,将build.gradle文件中applicationId中名字更换
- 复合LOV的实现
- OAF中实现动态LOV
- adf oracle selectOneChoice 加 LOV 后手动设置Lov的值
- erp中常用的LOV
- OAF中LOV的重置
- Silverlight中如何将style独立
- ADF UI: Creating Autosuggest LOV
- 如何在Java中实现将两个数相互交换的方法
- af:query中实现关联LOV
- EBS Form开发中LOV实现实例
- 如何在.net中实现级联删除?
- 使用Javascript实现Dropdownlist级联操作中遇到的两个错误
- Android中内容观察者的使用---- ContentObserver类详解
- 简易Web服务器
- 2015年蓝桥杯省赛B组第10题--生命之树
- Swap Nodes in Pairs--LeetCode
- DataPump使用说明
- ADF中如何将两个独立的LOV实现级联
- Ubuntu 12.04 LTS 中文输入法的安装
- Android学习心得① - GridView设置分割线的一种简单方法
- undefined reference to涉及的链接问题
- Android中的Intent(一)
- 深度学习资料链接
- Ubuntu 环境安装整理
- bashrc
- 使用JDBC来调用存储过程