oracle adf -如何在业务组件视图对象查询中使用会话属性值和where子句



在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中工作良好,值显示在有界任务流的JSF页面中,也显示在包含有界任务流作为区域的JSF页面上

我使用表达式

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

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

中使用compID会话属性值
Select.........where COMP_ID ='compID';

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

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

你可以尝试做下面博客中提到的

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

您需要在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

my…最终解决方案使用来自答案....

的代码行
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");
}

在视图xml上使用的表达式

adf.userSession.userData.Company
![used expression in the bind variable value][1]

最新更新