我正在对WebCenter提供的portlets进行一些研究,但在它们之间传递参数时遇到了一些问题。我的想法是创建两个departmentId :一个部门portlet,我可以在其中选择一个portlet,该portlet将作为参数发送给第二个portlet employees,因此我将拥有一个表,其中包含指定部门的相应员工。这两个portlet是基于一些页面流构建的。部门portlet工作得很好,但是对于employees portlet,我遇到了一些问题。
对应于employees的JSP页面片段有一个基于ViewObject的表,该表后面有一个基于绑定变量的查询。我已经创建了一个EmployeesBean,其中的方法接受接收到的参数并使用这个绑定变量执行查询。代码如下:
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.application.Application;
import javax.faces.context.FacesContext;
import oracle.adf.view.rich.context.AdfFacesContext;
import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
public class EmployeesBean {
private static final String DEPARTMENT_NUMBER_KEY = "DEPTNO";
private static final int DEPARTMENT_NUMBER_NULL_VALUE = -1;
public EmployeesBean() {
super();
}
public void getEmployees(String deptno) {
System.out.println("enters in getEmployees()");
int filterDeptno = findDepartmentValue(deptno);
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, "#{data.AppModuleDataControl.dataProvider}",
Object.class);
ApplicationModule am = (ApplicationModule)valueExp.getValue(elContext);
ViewObject emplVO;
emplVO = am.findViewObject("EmployeesVO1");
emplVO.setNamedWhereClauseParam("deptno", filterDeptno);
emplVO.executeQuery();
Row r = emplVO.first();
System.out.println(r.getAttribute("FirstName"));
}
public void setDepartmentNumber(String deptno) {
selectDepartment(deptno);
}
public void selectDepartment(String deptno) {
System.out.println("aici e problema");
AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
System.out.println(deptno);
afContext.getPageFlowScope().put(DEPARTMENT_NUMBER_KEY, deptno);
}
public int findDepartmentValue(String defaultValue) {
AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
String deptno =
(defaultValue == null ? (String)afContext.getPageFlowScope().get(DEPARTMENT_NUMBER_KEY) :
defaultValue);
return (deptno == null ? DEPARTMENT_NUMBER_NULL_VALUE :
Integer.valueOf(deptno));
}
}我还拖动了employees.jsff getEmployees()方法,因此如果我转到页面定义,就会有一个绑定,它将确定每次出现事件时要执行的getEmployees方法。如果我创建事件映射,所有这些都与departments.jsff混合在一个.jspx页面中工作
现在,我正在尝试将此任务流转换为portlet。在为页面流创建portlet条目之后,我需要创建一个导航参数,并且我在employees.xml中执行以下操作:
<input-parameter-definition>
<description>Main context parameter</description>
<display-name>Department Number</display-name>
<name>deptno</name>
<value>#{pageFlowScope.contextProvider.departmentNumber}</value>
<class>java.lang.String</class>
</input-parameter-definition>
<managed-bean>
<managed-bean-name>contextProvider</managed-bean-name>
<managed-bean-class>view.EmployeesBean</managed-bean-class>
<managed-bean-scope>pageFlow</managed-bean-scope>
</managed-bean>一切正常,但是当我试图将其用作WebCenter应用程序中的portlet时,当我选择一个部门时,departmentId将被传输到employees portlet,selectDepartment将被调用,但getEmployees()从未被调用(事件不被传播),因此表中没有返回任何数据。我是portlet的初学者,我看不出有什么问题。有人能给我一些建议吗?
发布于 2013-03-10 03:57:45
当您使用employee portlet时,它会在页面定义中创建页面参数。您必须将数据传递给该参数
https://stackoverflow.com/questions/2713756
复制相似问题