Forum Stats

  • 3,852,332 Users
  • 2,264,093 Discussions
  • 7,905,031 Comments

Discussions

Update ViewAttribute Properties at runtime - Multiple regions of same Task Flow Issue

santiago_nc
santiago_nc Member Posts: 91
edited Jul 14, 2014 6:24AM in JDeveloper and ADF

I have create a very short program to try explain my current issue.

1) The taskflow has as first method a client method exposed from the Application Module. This is its code:

    public void setDepartmentNameLabel(String label) {       
        ViewObjectImpl vo = this.getDepartments();
        ViewDefImpl viewDef = (ViewDefImpl) vo.getDef();
        String atribName = "DepartmentName";
        int indexAttr = viewDef.getAttributeIndexOf(atribName);
        if (indexAttr != -1) {
            AttributeDefImpl attr = (AttributeDefImpl)viewDef.getAttributeDef(indexAttr);
            if (attr != null) {//Set Label Name
                attr.setProperty(AttributeHints.ATTRIBUTE_LABEL, label);
            }
        }       
    }

2) TaskFlow has a "label" parameter which is passing to previuos method

#{pageFlowScope.label}

3) View Object departments is rendered as Adf Form in a pageFragment which is exposed in the taskFlow after the client method.

4) It has created multiple regions from this TaskFlow in a page, each one with different values for task flow label parameter.

When I run this application, the same label is shared for all regions. I have tried whit Shared and Isolated modes for TaskFlow.

I suposse that in isolated mode, each region would have their own instances for ApplicationModules and ViewObjects.

PS: This is only a test sample. In real application It is modifing all UI Hints for ViewObject and It is updating its query too, then I Know that I could change the label in a managed bean but this is not the requirement.

Jdeveloper 12c (12.1.2.0) ADF12c.

If it is necessary, I could attatch application in a zip file.

Fragment departemenst.jsff Code:

<?xml version='1.0' encoding='UTF-8'?>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
                xmlns:f="http://java.sun.com/jsf/core">
    <af:panelHeader text="Department" id="ph1">
        <f:facet name="context"/>
        <f:facet name="menuBar"/>
        <f:facet name="toolbar"/>
        <f:facet name="legend"/>
        <f:facet name="info"/>
        <af:panelFormLayout id="pfl1">
            <af:inputText value="#{bindings.DepartmentId.inputValue}" label="#{bindings.DepartmentId.hints.label}"
                          required="#{bindings.DepartmentId.hints.mandatory}"
                          columns="#{bindings.DepartmentId.hints.displayWidth}"
                          maximumLength="#{bindings.DepartmentId.hints.precision}"
                          shortDesc="#{bindings.DepartmentId.hints.tooltip}" id="it1">
                <f:validator binding="#{bindings.DepartmentId.validator}"/>
                <af:convertNumber groupingUsed="false" pattern="#{bindings.DepartmentId.format}"/>
            </af:inputText>
            <af:inputText value="#{bindings.DepartmentName.inputValue}" label="#{bindings.DepartmentName.hints.label}"
                          required="#{bindings.DepartmentName.hints.mandatory}"
                          columns="#{bindings.DepartmentName.hints.displayWidth}"
                          maximumLength="#{bindings.DepartmentName.hints.precision}"
                          shortDesc="#{bindings.DepartmentName.hints.tooltip}" id="it2">
                <f:validator binding="#{bindings.DepartmentName.validator}"/>
            </af:inputText>
            <af:inputText value="#{bindings.LocationId.inputValue}" label="#{bindings.LocationId.hints.label}"
                          required="#{bindings.LocationId.hints.mandatory}"
                          columns="#{bindings.LocationId.hints.displayWidth}"
                          maximumLength="#{bindings.LocationId.hints.precision}"
                          shortDesc="#{bindings.LocationId.hints.tooltip}" id="it3">
                <f:validator binding="#{bindings.LocationId.validator}"/>
                <af:convertNumber groupingUsed="false" pattern="#{bindings.LocationId.format}"/>
            </af:inputText>
            <af:inputText value="#{bindings.ManagerId.inputValue}" label="#{bindings.ManagerId.hints.label}"
                          required="#{bindings.ManagerId.hints.mandatory}"
                          columns="#{bindings.ManagerId.hints.displayWidth}"
                          maximumLength="#{bindings.ManagerId.hints.precision}"
                          shortDesc="#{bindings.ManagerId.hints.tooltip}" id="it4">
                <f:validator binding="#{bindings.ManagerId.validator}"/>
                <af:convertNumber groupingUsed="false" pattern="#{bindings.ManagerId.format}"/>
            </af:inputText>
            <f:facet name="footer">
                <af:panelGroupLayout layout="horizontal" id="pgl1">
                    <af:button actionListener="#{bindings.First.execute}" text="First"
                               disabled="#{!bindings.First.enabled}" partialSubmit="true" id="b1"/>
                    <af:button actionListener="#{bindings.Previous.execute}" text="Previous"
                               disabled="#{!bindings.Previous.enabled}" partialSubmit="true" id="b2"/>
                    <af:button actionListener="#{bindings.Next.execute}" text="Next"
                               disabled="#{!bindings.Next.enabled}" partialSubmit="true" id="b3"/>
                    <af:button actionListener="#{bindings.Last.execute}" text="Last"
                               disabled="#{!bindings.Last.enabled}" partialSubmit="true" id="b4"/>
                    <af:spacer width="10" height="10" id="s1"/>
                    <af:button actionListener="#{bindings.CreateInsert.execute}" text="CreateInsert"
                               disabled="#{!bindings.CreateInsert.enabled}" id="b5"/>
                    <af:button actionListener="#{bindings.Delete.execute}" text="Delete"
                               disabled="#{!bindings.Delete.enabled}" id="b6" immediate="true"/>
                    <af:spacer width="10" height="10" id="s2"/>
                    <af:button actionListener="#{bindings.Commit.execute}" text="Commit"
                               disabled="#{!bindings.Commit.enabled}" id="b7"/>
                    <af:button actionListener="#{bindings.Rollback.execute}" text="Rollback"
                               disabled="#{!bindings.Rollback.enabled}" immediate="true" id="b8">
                        <af:resetActionListener/>
                    </af:button>
                </af:panelGroupLayout>
            </f:facet>
        </af:panelFormLayout>
    </af:panelHeader>
</ui:composition>

Page Def fragment code:

<?xml version="1.0" encoding="UTF-8" ?>
<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="12.1.2.66.68" id="departmentsPageDef"
                Package="fragments">
  <parameters/>
  <executables>
    <variableIterator id="variables"/>
    <iterator Binds="Departments" RangeSize="25" DataControl="TestAppModuleDataControl" id="DepartmentsIterator"
              ChangeEventPolicy="ppr"/>
  </executables>
  <bindings>
    <attributeValues IterBinding="DepartmentsIterator" id="DepartmentId">
      <AttrNames>
        <Item Value="DepartmentId"/>
      </AttrNames>
    </attributeValues>
    <attributeValues IterBinding="DepartmentsIterator" id="DepartmentName">
      <AttrNames>
        <Item Value="DepartmentName"/>
      </AttrNames>
    </attributeValues>
    <attributeValues IterBinding="DepartmentsIterator" id="LocationId">
      <AttrNames>
        <Item Value="LocationId"/>
      </AttrNames>
    </attributeValues>
    <attributeValues IterBinding="DepartmentsIterator" id="ManagerId">
      <AttrNames>
        <Item Value="ManagerId"/>
      </AttrNames>
    </attributeValues>
    <action IterBinding="DepartmentsIterator" id="First" RequiresUpdateModel="true" Action="first"/>
    <action IterBinding="DepartmentsIterator" id="Previous" RequiresUpdateModel="true" Action="previous"/>
    <action IterBinding="DepartmentsIterator" id="Next" RequiresUpdateModel="true" Action="next"/>
    <action IterBinding="DepartmentsIterator" id="Last" RequiresUpdateModel="true" Action="last"/>
    <action IterBinding="DepartmentsIterator" id="CreateInsert" RequiresUpdateModel="true" Action="createInsertRow"/>
    <action IterBinding="DepartmentsIterator" id="Delete" RequiresUpdateModel="false" Action="removeCurrentRow"/>
    <action id="Commit" RequiresUpdateModel="true" Action="commitTransaction" DataControl="TestAppModuleDataControl"/>
    <action id="Rollback" RequiresUpdateModel="false" Action="rollbackTransaction"
            DataControl="TestAppModuleDataControl"/>
  </bindings>
</pageDefinition>

TaskFlow Code:

<?xml version="1.0" encoding="UTF-8" ?>
<adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
  <task-flow-definition id="TestTaskFlow">
    <default-activity>setDepartmentNameLabel</default-activity>
    <transaction>
      <requires-transaction/>
    </transaction>
    <data-control-scope>
      <isolated/>
    </data-control-scope>
    <input-parameter-definition id="__1">
      <name>label</name>
      <value>#{pageFlowScope.label}</value>
      <class>java.lang.String</class>
      <required/>
    </input-parameter-definition>
    <method-call id="setDepartmentNameLabel">
      <method>#{bindings.setDepartmentNameLabel.execute}</method>
      <outcome>
        <fixed-outcome>setDepartmentNameLabel</fixed-outcome>
      </outcome>
    </method-call>
    <view id="departments">
      <page>/fragments/departments.jsff</page>
    </view>
    <control-flow-rule id="__2">
      <from-activity-id>setDepartmentNameLabel</from-activity-id>
      <control-flow-case id="__3">
        <from-outcome>setDepartmentNameLabel</from-outcome>
        <to-activity-id>departments</to-activity-id>
      </control-flow-case>
    </control-flow-rule>
    <use-page-fragments/>
  </task-flow-definition>
</adfc-config>

TaskFlow method setDepartmentNameLbel code

<?xml version="1.0" encoding="UTF-8" ?>
<pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="12.1.2.66.68"
                id="TestTaskFlow_TestTaskFlow_setDepartmentNameLabelPageDef"
                Package="com.edisa.test.view_attribute.view.pageDefs" SkipValidation="true">
  <parameters/>
  <executables/>
  <bindings>
    <methodAction id="setDepartmentNameLabel" RequiresUpdateModel="true" Action="invokeMethod"
                  MethodName="setDepartmentNameLabel" IsViewObjectMethod="false" DataControl="TestAppModuleDataControl"
                  InstanceName="data.TestAppModuleDataControl.dataProvider">
      <NamedData NDName="label" NDValue="#{pageFlowScope.label}" NDType="java.lang.String"/>
    </methodAction>
  </bindings>
</pageDefinition>

Tagged:

Answers

This discussion has been closed.