12 Replies Latest reply: Nov 9, 2012 10:04 AM by Jai Om-Oracle RSS

    Common child VO instance for multiple parent VOs

    Jai Om-Oracle
      Hello,

      I am using Jdev 11.1.1.6.

      One use case that I thought is common and straight forward has puzzled me. I am not sure if I got it right.
      Let me explain the use case here:
      There are 2 entities EM and EC, where EM is master and EC is child [using association]
      There are 2 views VM1 and VM2 based on entity EM [Both views have different set of columns and show different set of data based on their WHERE clause]
      There is one common child view VC based on entity EC

      There is a viewlink created between VM1 and VC --> Vm1VcVL [based on entity association]
      Similarly another created between VM2 and VC --> Vm2VcVL [based on entity association]

      I exposed VM1 and VM2 on application module
      I exposed instance of VC under VM1 using viewlink Vm1VcVL
      then I exposed same instance of VC under VM2 using it's own viewlink i.e. Vm2VcVL

      Idea behind using same instance same is to create only one bounded taskflow on UI side for VC to be re-used under both parent bounded taskflows and showing respective child records based on parent record.

      When I tested this above AM configuration using ADF BC Tester, it shows same set of VC [child] record for both viewlinks. It filters the record as per first master viewlink [Vm1VcVL] only.

      What did I miss here?
      Is it supposed to work like this? If yes, what is the right way of achieving above mentioned use-case.

      Thanks,
      Jai
        • 1. Re: Common child VO instance for multiple parent VOs
          user404
          DO VM1 and VM2 show the correct (diffirent) data?
          • 2. Re: Common child VO instance for multiple parent VOs
            Jai Om-Oracle
            Yes, VM1 and VM2 shows correct data in itself but child shows same set of data [essentially for VM1 master record] for both viewlinks.
            • 3. Re: Common child VO instance for multiple parent VOs
              kdario
              Instead of using shared detail VO instance, you can try to use separate detail instances and then to dynamically switch binding, something like this: http://andrejusb.blogspot.com/2010/04/dynamic-iterator-binding-to-reuse-view.html

              Dario
              • 4. Re: Common child VO instance for multiple parent VOs
                Jai Om-Oracle
                Hello,

                Thanks for sharing the link.

                However, it is not working in my scenario due to the fact that I have these Master and Child in different regions [fragment based BTF]. VM1, VM2 and VC are all fragment based BTF.
                Main page is a fragment based BTF containing both masters [VM1 and Vm2] and child [VC].

                It goes like this in Main.jsff:
                <panelTab>
                <showDetail VM1 --> BTF>
                <showDetail VM2 --> BTF>
                </panelTab>
                <panelTab>
                <showDetail VC - BTF>
                </panelTab>

                Based on the solution shared in given link is to capture change Tab action and return the dynamic view binding. Not sure how to do this, since Main.jsff/VM1/VM2 pageFlowScope is not accessible to VC pageFlowScope.
                How do I share the info between master region and child region?

                Thanks,
                Jai
                • 5. Re: Common child VO instance for multiple parent VOs
                  kdario
                  >
                  How do I share the info between master region and child region?
                  >
                  You probably can use BTF input parameter.
                  http://docs.oracle.com/cd/E14571_01/web.1111/b31974/taskflows_parameters.htm
                  http://docs.oracle.com/cd/E23943_01/web.1111/b31974/taskflows_regions.htm#CHDBIEDA

                  Dario
                  • 6. Re: Common child VO instance for multiple parent VOs
                    Jai Om-Oracle
                    Hello Dario,

                    Thanks for your response. I really appreciate your input.

                    The problem that I am facing is how to push the value for taskflow input parameter. Let me clarify, what I mean
                    As I mentioned earlier, Main.jsff has components layout as:

                    <panelTab>
                    <showDetail VM1 --> BTF>
                    <showDetail VM2 --> BTF>
                    </panelTab>
                    <panelTab>
                    <showDetail VC - BTF>
                    </panelTab>

                    I have put the code in Main.jsff under showDetailVM1 and VM2 as:
                    <af:setPropertyListener from="#{'VC1'}"
                    to="#{pageFlowScope.viewName}"
                    type="disclosure"/>
                    and
                    <af:setPropertyListener from="#{'VC2'}"
                    to="#{pageFlowScope.viewName}"
                    type="disclosure"/>

                    In MainPageDef.xml, I have code like this,

                    <taskFlow id="tflow_tf11"
                    taskFlowId="/WEB-INF/tflow_tf1.xml#tflow_tf1"
                    activation="deferred"
                    xmlns="http://xmlns.oracle.com/adf/controller/binding">
                    <parameters>
                    <parameter id="viewName"
                    value="#{pageFlowScope.viewName}"/>
                    </parameters>
                    </taskFlow>

                    The problem is #{pageFlowScope.viewName} evaluates to null in MainPageDef.xml, so the viewName is not passed.

                    What am I doing wrong here?

                    And I don't want to just make it work but rather do it proper and recommended way as this is going to be common scenario in many screens.

                    Thanks,
                    Jai
                    • 7. Re: Common child VO instance for multiple parent VOs
                      kdario
                      Is this works when you directly assign #{'VC1'} and #{'VC2'} to BTF parameter?

                      Dario
                      • 8. Re: Common child VO instance for multiple parent VOs
                        Jai Om-Oracle
                        Yes, it works with hard coded value. No issues there.

                        Thanks,
                        Jai
                        • 9. Re: Common child VO instance for multiple parent VOs
                          kdario
                          Try to change region's activation, something like this:
                          <taskFlow id="tflow_tf11"
                                taskFlowId="/WEB-INF/tflow_tf1.xml#tflow_tf1"
                                activation="conditional"
                                active="#{pageFlowScope.viewName =='VC1'}"
                                xmlns="http://xmlns.oracle.com/adf/controller/binding">
                                <parameters>
                                   <parameter id="viewName"
                                   value="#{pageFlowScope.viewName}"/>
                                 </parameters>
                          </taskFlow>
                          You can try to change region activation(17.6) or refresh(17.5) conditions:
                          http://docs.oracle.com/cd/E23943_01/web.1111/b31974/taskflows_regions.htm#CHDEIFBB

                          Dario

                          Edited by: kdario on Nov 7, 2012 2:03 PM
                          • 10. Re: Common child VO instance for multiple parent VOs
                            Jai Om-Oracle
                            Hello Dario,

                            Thanks for your suggestion. I am little confused, how does it help with passing dynamic value.
                            Remember, child [VC] is just one taskflow, created using VC1 but intended to be used by VC1 and VC2. VC1 and VC2 are 2 instance names for same VO [VC]
                            So if I put active="#{pageFlowScope.viewName =='VC1'}", it is going to be activated only for vewName=VC1 but the issue is how to set the value of pageFlowScope.viewName.

                            I mentioned in my last post that setting the variable's value [pageFlowScope.viewName] in Main.jsff is not accessible in it's PageDef [MainPageDef.xml] and evaluates to null.
                            So how do I set the value for pageFlowScope.viewName?

                            Thanks,
                            Jai
                            • 11. Re: Common child VO instance for multiple parent VOs
                              kdario
                              If I understand this correctly(from your picture :) ), you have af:setPropertyListener and regions in the same page(in the same task flow)?
                              So, they use the same pageFlowScope(region binding parameters use the same pageFlowScope as setPropertyListener - not content inside region).
                              When you click on tab, setPropertyListener will set pageFlowScope.viewName variable which is bound to BTF input parameter.

                              But, BTF is already activated(I suppose) so you must refresh it.
                              You can try to set refresh="if needed" (instead activation property)
                              (from doc: "ifNeeded: refresh the ADF Region if the value of a task flow binding parameter changes. Do not set a value for the RefreshCondition property in step 4 if you select this value.")

                              Update:
                              I just tested this in JDev 11.1.2.3 (one panelTabbed with two tabs and setPropertyListeners and one region which contains output text field bound to input parameter)
                              With default refresh settings, region will not refresh(will not display anything in outputText component), with refresh="ifNeeded" this works as expected.

                              Dario

                              Edited by: kdario on Nov 7, 2012 2:38 PM

                              Edited by: kdario on Nov 7, 2012 3:01 PM
                              • 12. Re: Common child VO instance for multiple parent VOs
                                Jai Om-Oracle
                                Hello Dario,

                                Thank you so much for your help. I really appreciate it.

                                It worked!!! I just have to put the refresh="if needed".

                                Thanks,
                                Jai