2010-04-26 69 views
2

我正在對WebCenter提供的portlet進行一些研究,但是我在它們之間傳輸參數時遇到了一些問題。我的想法是創建2個portlet:一個部門portlet,我可以選擇一個departmentId作爲參數發送給第二個portlet,員工,因此我將擁有一個來自指定部門的相應員工的表。這2個portlet是基於一些頁面流構建的。部門portlet工作正常,但對於員工portlet,我遇到了一些問題。Oracle WebCenter中的WSRP Portlets:在portlet中轉換任務流(ADF)

對應於員工的JSP頁面片段具有基於ViewObject的表格,該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混合在一起.jsp工作在一個.jspx頁面,如果我創建事件映射

現在我正試圖將此任務流轉換爲一個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的初學者,我看不出問題所在。任何人都可以給我一些想法嗎?

+0

我相信這個視頻可以爲您提供良好的開端http://www.youtube.com/watch?v=NI2Zy6gRfF4 – 2012-02-26 12:34:56

回答

0

當您使用員工portlet時,它會在頁面def中創建頁面參數。您必須將數據傳遞給該參數

相關問題