如何在Business组件视图对象查询中使用where子句使用会话属性值。

时间:2013-03-06 10:56:12

标签: oracle-adf

在ADF融合Web应用程序中的sessionScoped托管bean(有界任务流中的注册托管bean以及adfc-config.xml文件中)中,我已将会话中的属性设置为

FacesContext fctx = FacesContext.getCurrentInstance();
ExternalContext ectx = fctx.getExternalContext();
HttpSession userSession = (HttpSession) ectx.getSession(false);
userSession.setAttribute("compID", defaultCompany);

会话属性在bean中正常工作,并且该值正在有界任务流的jsff页面中显示,并且还在包含有界任务流的jsf页面上显示为区域

使用表达式

获取页面上的会话属性值
"#{sessionScope.compID}" 

在输出文本值属性中,但无法获取包含业务组件的模型项目中的值。我想在查询中使用compID会话属性值

Select.........where COMP_ID ='compID';

通过设置绑定变量值属性中的值并在where子句中传递新创建的bid变量但它不起作用

所以我如何在业务组件视图对象的查询的where子句中使用此动态会话属性值?

3 个答案:

答案 0 :(得分:4)

您可以尝试执行以下博客中提到的内容

http://andrejusb.blogspot.com/2012/01/how-to-access-session-scope-in-adf-bc.html

答案 1 :(得分:3)

您的VO或AM上需要一个接受参数的服务方法 - 您在JSF页面中调用此方法并将会话范围作为参数传递。 一个例子: https://blogs.oracle.com/shay/entry/passing_parameters_to_an_adf_p 要么 https://blogs.oracle.com/shay/entry/am_service_method_-_simple_dem

答案 2 :(得分:1)

我的...最终解决方案使用答案中的代码行......

protected void prepareSession(Session session) {
Map sessionScope = ADFContext.getCurrent().getSessionScope();
String company = (String)sessionScope.get("compId");
System.out.println("Default Comapny in BC is: " + company);
super.prepareSession(session);
this.getSession().getUserData().put("Company", company);
System.out.println("After setting value in userData map of BC");
}
用于view xml的

表达式

adf.userSession.userData.Company

![used expression in the bind variable value][1]