views:

279

answers:

1

I am doing some research on the portlets offered by WebCenter, but I have some problems related with transferring parameters between them. My idea was to create 2 portlets: a department portlet where I can chose a departmentId which is sent as a parameter to the second portlet, employees, so I will have a table with the corresponding employees from the specified department. These 2 portlets are constructed based on some page flows. The department portlet works fine, but with the employees portlet, I have some problems.

The JSP page fragment corresponding to the employees has a table based on a ViewObject which has behind him a query based on a bind variable. I have created an EmployeesBean, where I have the method that takes the received parameter and executes the query with this bind variable. Here is the code:

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

I have also dragged on the employees.jsff the getEmployees() method so if I go to page definition I have there a binding, which will determine the getEmployees method to be executed every time an event appears. All this mixed with the departments.jsff works in a .jspx page if I create the Event mapping

Now I am trying to transform this task flow into a portlet. After I create a portlet entry for the page flow, I need to create a navigational parameter, and I am doing this in the 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>

Everything works fine, but when I am trying to use this as a portlet in a WebCenter application, when I select a department the departmentId is transferred to the employees portlet, the selectDepartment is called, but the getEmployees() is never called(the event is not propagated), so no data is returned in my table. I'm a beginner in portlets and I can't see what the problem is. Can anyone give me some ideas?

A: 

I have the same issue. I doubt if the sample works! Please let me know if anybody got this working!

Kumar