简体   繁体   English

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

[英]How to use session attribute value with the where clause in Business component view object query.?

In the sessionScoped managed bean(registered managed bean in the bounded task flow and also in the adfc-config.xml file) in ADF fusion web application I had set the attribute in the session as 在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);

the session attribute is working fine in the bean and the value is being displayed in the jsff page of the bounded task flow and also on the jsf page which contains the bounded task flow as region session属性在bean中工作正常,值显示在有界任务流的jsff页面中,也显示在包含有界任务流作为区域的jsf页面上

im getting the session attribute value on the page using the expression 我使用表达式获取页面上的会话属性值

"#{sessionScope.compID}" 

inside the output text value property, but not able to get the value in the model project which contains the business components. 在输出文本值属性中,但无法获取包含业务组件的模型项目中的值。 I want to use the compID session attribute value in the query 我想在查询中使用compID会话属性值

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

by setting the value in the bind variable value property and passing the newly creted bid variable in the where clause but its not working 通过设置绑定变量值属性中的值并在where子句中传递新创建的bid变量但它不起作用

so i how to use this dynamic session attribute value in the where clause of the query of the business component view object? 那么我如何在业务组件视图对象的查询的where子句中使用此动态会话属性值?

You need a service method on your VO or AM that accepts a parameter - you call this method in your JSF page and pass the session scope as the parameter. 您需要在VO或AM上接受参数的服务方法 - 您在JSF页面中调用此方法并将会话范围作为参数传递。 An example: https://blogs.oracle.com/shay/entry/passing_parameters_to_an_adf_p or https://blogs.oracle.com/shay/entry/am_service_method_-_simple_dem 示例: https//blogs.oracle.com/shay/entry/passing_parameters_to_an_adf_phttps://blogs.oracle.com/shay/entry/am_service_method_-_simple_dem

my...final solution using code lines from both the answer.... 我的...最终解决方案使用答案中的代码行....

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");
}

expression used on view xml 用于视图xml的表达式

adf.userSession.userData.Company

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM