7 Replies Latest reply: Feb 1, 2013 9:24 AM by Miguel Angel RSS

    Pass parameter betwen modules

    Miguel Angel
      I have a main application with a "login.jsf" and "home.jsf". It also has modules(bounded task flows) created as adf libraries. I am working with my own UIShell and want to pass a parameter from the main application to one of my modules to query some results.

      For example i have a "UserBean " class with the attribute "codInternal" and my security bounded task flow need this parameter to make a query.

      How can i do this?. I am working with JDeveloper 11.1.2.3

      Thanks.
        • 1. Re: Pass parameter betwen modules
          Timo Hahn
          Why don't you use input parameters on the called task flow?

          Timo
          • 2. Re: Pass parameter betwen modules
            Miguel Angel
            I call my task flow (adf library) with java code:

            public class AdministradorModulos {

            private String taskFlowId;
            private String codInternal;

            public TaskFlowId getDynamicTaskFlowId() {
            return TaskFlowId.parse(taskFlowId);
            }

            public String goToModuloSeguridad() {
            taskFlowId = "/WEB-INF/seguridad-task-flow.xml#seguridad-task-flow";
            return null;
            }
            }

            This is my page:

            <af:document title="inicio.jsf" id="d1">
            <af:form id="f1">
            <af:panelSplitter id="ps1">
            <f:facet name="first">
            <af:panelGroupLayout id="pgl1">
            <af:commandButton text=" ir a seguridad" id="cb1"
            action="#{pageFlowScope.admModulo.goToModuloSeguridad}"/>
            </af:panelGroupLayout>
            </f:facet>
            <f:facet name="second">
            <af:region value="#{bindings.dynamicRegion1.regionModel}" id="r1"
            partialTriggers="::cb1"/>
            </f:facet>
            </af:panelSplitter>
            </af:form>
            </af:document>


            How to pass the "codInternal" parameter with java code?

            Edited by: Miguel Angel on 29/01/2013 04:45 PM
            • 3. Re: Pass parameter betwen modules
              987240
              You can set the value in a pageFlowScope variable using EL expression. Evaluate using a utility method.
              In the called taskflow as a region, retrieve the value of this pageFlowScope variable as an input parameter.
              See here:
              http://docs.oracle.com/cd/E14571_01/web.1111/b31974/taskflows_parameters.htm
              http://www.baigzeeshan.com/2011/12/oracle-adf-storing-temporary-values-in.html

              -Nirav
              • 4. Re: Pass parameter betwen modules
                Miguel Angel
                I have done this:

                public String goToModuloSeguridad() {
                taskFlowId = "/WEB-INF/seguridad-task-flow.xml#seguridad-task-flow";

                FacesContext context = FacesContext.getCurrentInstance();
                Application application = context.getApplication();
                TaskFlowDefinition definition = MetadataService.getInstance().getTaskFlowDefinition(tfi);
                Map<String, TaskFlowInputParameter> parameters = definition.getInputParameters();

                for (TaskFlowInputParameter parameter : parameters.values()) {
                String name = parameter.getName();
                String expression = parameter.getValueExpression();

                ValueExpression expressionValue = null;
                ExpressionFactory elFactory = application.getExpressionFactory();
                ELContext elContext = context.getELContext();
                expressionValue = elFactory.createValueExpression(elContext, expression, Object.class);
                expressionValue.setValue(elContext,"codInternal");

                Object value = application.evaluateExpressionGet(context, expression, Object.class);
                System.out.println(value);
                }
                return null;
                }

                I have defined mi input parameter in the called task flow:

                <task-flow-definition id="seguridad-task-flow">
                <default-activity>seguridad</default-activity>
                <input-parameter-definition id="__1">
                <name>codigo</name>
                <value>#{pageFlowScope.cod}</value>
                <class>java.lang.String</class>
                </input-parameter-definition>
                <view id="seguridad">
                <page>/seguridad.jsff</page>
                </view>
                <use-page-fragments/>
                </task-flow-definition>

                In my page of the called task flow I have:

                <af:outputText value="Code is : #{pageFlowScope.cod}" id="ot2"/>


                But the value of the outpuText is not updated.
                • 5. Re: Pass parameter betwen modules
                  Frank Nimphius-Oracle
                  Hi,

                  really the easiest way to pass parameters to a task flow (and this works especially well with dynamic regions) is to use a HashMap reference in the task flow binding.

                  - create a managed bean in viewScope on the parent page
                  - create a HashMap property along with getter/setters
                  - in the dynamic task flow binding configure "parametersMap" to point to #{viewScope.yourBean.map} (assuming you have a setMap/getMap method in the bean)

                  Now from the calling application, you change the content o fthe map (best is to call setMap on the managed bean and pass a Hashmap with the input name/value pairs before switching the task flow. This is less code you write and also less error prone.

                  Frank
                  • 6. Re: Pass parameter betwen modules
                    Miguel Angel
                    Ok but how do I retrieve the value on my bean or my page of the called task flow?. As I understand I have to create a hash property in a managed bean in the main application. But How do i get the value in my security task flow(adf library)?.

                    Edited by: Miguel Angel on 31/01/2013 07:00 PM
                    • 7. Re: Pass parameter betwen modules
                      Miguel Angel
                      I have created my hashMap in the managed bean and in the task flow:

                      Task Flow:

                      <taskFlow id="dynamicRegion1" taskFlowId="${viewScope.admModulo.dynamicTaskFlowId}" activation="deferred"
                      xmlns="http://xmlns.oracle.com/adf/controller/binding"
                      parametersMap="#{viewScope.admModulo.params}"></taskFlow>


                      Managed Bean:

                      private HashMap params = new HashMap();

                      public void setParams(HashMap params) {
                      this.params = params;
                      }

                      public HashMap getParams() {
                      return params;
                      }

                      public String goToModuloSeguridad() {
                      taskFlowId = "/WEB-INF/seguridad-task-flow.xml#seguridad-task-flow";
                      params.put("codInternal", "0000030");
                      return null;
                      }

                      In the security task Flow i defined my parameter:

                      <input-parameter-definition id="__1">
                      <name>codInternal</name>
                      <value>#{pageFlowScope.codInternal}</value>
                      <class>java.lang.String</class>
                      </input-parameter-definition>

                      In the jsf page fragment of my security task flow I have:

                      <af:outputText value="Code is : #{pageFlowScope.codInternal}" id="ot2"/>


                      But I can't see the value. The region binding has a partialTrigger of the command button.

                      Edited by: Miguel Angel on 01/02/2013 10:24 AM