Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Update Input Fields within Iterator with PPR in ADF10g

2760560Sep 25 2014 — edited Sep 25 2014

I am experiencing a problem with the af:Iterator component in ADF10g.

I have a page in which I need to display nested lists. So I've got a list of objects, with each object in the list being capable of displaying another list of objects. This makes the use of a table less than appealing (I don't much care for tables within tables). So I tried using iterator components instead, which worked just fine until I started trying to delete objects from the lists being iterated over...

What I've got is essentially this:

<af:commandButton text="Add Co-PI"

                     binding="#{backing\_investigatorInfo.commandButtonAddCoPi}"

                     id="commandButtonAddCoPi"

                     action="#{backing\_investigatorInfo.cmdAddCoPi\_action}"

                     immediate="true"

                     partialSubmit="true"/>

<af:iterator binding="#{backing_investigatorInfo.iteratorCoPi}"

         id="iteratorCoPi"

         value="#{backing\_investigatorInfo.coPiList}"

         var="coPiRow" varStatus="coPiRowStatus">

 \<af:panelBox binding="#{backing\_investigatorInfo.panelBox2}"

              id="panelBox2" width="70%"

              text="Co-PI/Co-Pd #{coPiRowStatus.index+1}"

              background="light">

     \<af:selectInputText binding="#{backing\_investigatorInfo.selectInputPi}"

                         id="selectInputPi"

                         action="dialog:piSearch"

                         windowHeight="400"

                         windowWidth="500"

                         autoSubmit="true"

                         searchDesc="Search for a PI"

                         actionListener="#{backing\_investigatorInfo.piSearchAction}"

                         returnListener="#{backing\_investigatorInfo.piReturn}"

                         value="#{coPiRow.piName}"

                         partialTriggers="commandButtonAddCoPi iteratorCoPi:cmdDeleteCoPi">

        \<af:setActionListener from="#{coPiRow.piName}"

                              to="#{processScope.personName}"/>

      \</af:selectInputText>

      \<af:commandButton text="Delete Co-PI"

                        binding="#{backing\_investigatorInfo.cmdDeleteCoPi}"

                        id="cmdDeleteCoPi"

                        action="#{backing\_investigatorInfo.cmdDeleteCoPi\_action}"

                        immediate="true"

                        partialSubmit="true"/>

       \<af:outputText binding="#{backing\_investigatorInfo.outputText2024}"

                      id="outputText2024"

                      value="#{coPiRow.departmentName}"

                      partialTriggers="selectInputPi"/>

       \<af:selectOneRadio binding="#{backing\_investigatorInfo.selectRadioCourseRelease}"

                          id="selectRadioCourseRelease"

                          layout="horizontal"

                          autoSubmit="true"

                          valueChangeListener="#{backing\_investigatorInfo.cmdToggleCourseRelease\_action}"

                          value="#{coPiRow.courseReleaseFlag}">

       \</af:selectOneRadio>

       \<af:commandButton text="Add Course Release Semester"

                         binding="#{backing\_investigatorInfo.commandButtonAddCourseRelease}"

                         id="commandButtonAddCourseRelease"

                         action="#{backing\_investigatorInfo.cmdAddCourseReleaseSemester\_action}"

                         rendered="#{coPiRow.courseReleaseFlag=='Y'?true:false}"

                         partialSubmit="true"

                         immediate="true"/>

 \</af:panelBox>

</af:iterator>

Full code can be found below. So the important elements here:

  • I have a button that adds objects to my list in the backing bean.
  • I have an iterator that displays the list from the backing bean.
  • Within my iterator I have a selectInputText, an outputText, and a selectOneRadio component that are linked to values stored by the objects being iterated over.
  • With my iterator I have a Delete button that deletes an object from the list being iterated over.
  • This is all done with PPR.

Here is the code from my backing bean:

private List<PI> coPiList = new ArrayList<PI>();

public void cmdAddCoPi_action() {

 coPiList.add(new PI());

}

public void cmdDeleteCoPi_action() {

 int coPiIndex = iteratorCoPi.getRowIndex();

 coPiList.remove(coPiIndex);

}

Some super simple code dealing with simple Java List objects. Works great for displaying my list of objects! Displaying my nested lists (within listed objects) also works flawlessly (removed from the code above).

My problem lies in the deletion and re-display of my list. For example, say I have 3 objects in my list. When I delete the first object, cmdDeleteCoPI_action() is called, and the iterator object is refreshed with PPR (its container has the delete button as a partial trigger). Two items remain in the list and only 2 items are displayed. However, the data is not fetched from the backing bean again as one would expect with PPR. It appears as if the output text is refreshed with its correct value, but both input elements (the select input and the radio buttons) remain as they were, with the values of the deleted object rather than the values of the second object which got cycled down to first in the list.

The issue is better understood when viewed:

pi1.PNG

When the "Delete Co-Pi" button is clicked on the first object in the list, the iterator updates, but not the input elements within:

pi2.PNG

As you can see, the output text elements got refreshed as expected. However, both input elements failed to refresh. Why is this? What can be done to fix it? I've been looking at this problem on and off for the past week, and have tried a lot of things, all of which have failed. One attempt was trying to get the iterator component to update programatically from the backing bean. Couldn't get that to work. Although this was before I saw that the output text value is getting updated as expected. So even if I could manually update/refresh the iterator object, I'm not sure if it would work. It seems that maybe somehow I need to tell the input elements to forget what they know and re-grab their values from the backing bean.

Additionally, when I click the "Add Co-PI" button (which also uses PPR), old data will be displayed rather than creating a blank object. Of course, the object added the list in the backing bean is empty. However, the page seems to remember data that was displayed previously in the iterator. So for instance, if I delete the first object, and then re-add a new object, the third object's details will be shown in the newly created object. This is because this newly created object is the third in the list, and the 3rd row of the iterator remembers what it was holding before.

Of course, I could just submit the page rather than using PPR, but that would have other consequences. Not to mention it would be inconsistent with the rest of the page. Many similar problems I've looked at have been with ADF 11g, and the iterator component seems to work a little differently there.

Any help is appreciated.

Full jspx below:

<afh:rowLayout binding="#{backing_investigatorInfo.rowLayout12}"

                               id="rowLayout12">

<afh:cellFormat binding="#{backing_investigatorInfo.cellFormat28}"

               id="cellFormat28" columnSpan="1">

   \<af:commandButton text="Add Co-PI"

                     binding="#{backing\_investigatorInfo.commandButtonAddCoPi}"

                     id="commandButtonAddCoPi"

                     action="#{backing\_investigatorInfo.cmdAddCoPi\_action}"

                     immediate="true"/>

</afh:cellFormat>

</afh:rowLayout>

<afh:rowLayout binding="#{backing_investigatorInfo.rowLayout13}"

                               id="rowLayout13" width="100%"

                               partialTriggers="cmdDeleteCoPi">

                  \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat29}"

                                  id="cellFormat29"

                                  partialTriggers="commandButtonAddCoPi iteratorCoPi:cmdDeleteCoPi"

                                  width="100%" columnSpan="3">

                    \<af:iterator binding="#{backing\_investigatorInfo.iteratorCoPi}"

                                 id="iteratorCoPi"

                                 value="#{backing\_investigatorInfo.coPiList}"

                                 var="coPiRow" varStatus="coPiRowStatus">

                      \<afh:rowLayout binding="#{backing\_investigatorInfo.rowLayout10}"

                                     id="rowLayout10" width="100%">

                        \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat23}"

                                        id="cellFormat23" width="100%">

                          \<af:panelBox binding="#{backing\_investigatorInfo.panelBox2}"

                                       id="panelBox2" width="70%"

                                       text="Co-PI/Co-Pd #{coPiRowStatus.index+1}"

                                       background="light">

                            \<afh:tableLayout binding="#{backing\_investigatorInfo.tableLayout3}"

                                             id="tableLayout3" width="100%"

                                             cellPadding="1">

                              \<afh:rowLayout binding="#{backing\_investigatorInfo.rowLayout11}"

                                             id="rowLayout11">

                                \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat24}"

                                                id="cellFormat24"

                                                columnSpan="1"

                                                halign="right" width="20%"

                                                height="25">

                                  \<af:outputText value="Co-PI/Co-PD:"

                                                 binding="#{backing\_investigatorInfo.outputText20191}"

                                                 id="outputText20191"

                                                 inlineStyle="font-weight:bold; color:rgb(56,59,63);"/>

                                \</afh:cellFormat>

                                \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat25}"

                                                id="cellFormat25"

                                                columnSpan="1" width="45%"

                                                height="25"

                                                partialTriggers="commandButtonAddCoPi iteratorCoPi:cmdDeleteCoPi">

                                  \<af:selectInputText binding="#{backing\_investigatorInfo.selectInputPi}"

                                                      id="selectInputPi"

                                                      action="dialog:piSearch"

                                                      windowHeight="400"

                                                      windowWidth="500"

                                                      autoSubmit="true"

                                                      searchDesc="Search for a PI"

                                                      actionListener="#{backing\_investigatorInfo.piSearchAction}"

                                                      returnListener="#{backing\_investigatorInfo.piReturn}"

                                                      value="#{coPiRow.piName}"

                                                      partialTriggers="commandButtonAddCoPi iteratorCoPi:cmdDeleteCoPi">

                                    \<af:setActionListener from="#{coPiRow.piName}"

                                                          to="#{processScope.personName}"/>

                                  \</af:selectInputText>

                                \</afh:cellFormat>

                                \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat45}"

                                                id="cellFormat45"

                                                width="35%" halign="right">

                                  \<af:commandButton text="Delete Co-PI"

                                                    binding="#{backing\_investigatorInfo.cmdDeleteCoPi}"

                                                    id="cmdDeleteCoPi"

                                                    action="#{backing\_investigatorInfo.cmdDeleteCoPi\_action}"

                                                    immediate="true"

                                                    partialSubmit="true"/>

                                \</afh:cellFormat>

                              \</afh:rowLayout>

                              \<afh:rowLayout binding="#{backing\_investigatorInfo.rowLayout30}"

                                             id="rowLayout30">

                                \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat26}"

                                                id="cellFormat26"

                                                columnSpan="1"

                                                halign="right" height="25">

                                  \<af:outputText value="Department:"

                                                 binding="#{backing\_investigatorInfo.outputText2020}"

                                                 id="outputText2020"

                                                 inlineStyle="font-weight:bold; color:rgb(56,59,63);"

                                                 truncateAt="0"/>

                                \</afh:cellFormat>

                                \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat27}"

                                                id="cellFormat27"

                                                columnSpan="2" height="25">

                                  \<af:outputText

                                                 binding="#{backing\_investigatorInfo.outputText2024}"

                                                 id="outputText2024"

                                                 value="#{coPiRow.departmentName}"

                                                 partialTriggers="selectInputPi"/>

                                \</afh:cellFormat>

                              \</afh:rowLayout>

                              \<afh:rowLayout binding="#{backing\_investigatorInfo.rowLayout20}"

                                             id="rowLayout20">

                                \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat181}"

                                                id="cellFormat181" columnSpan="1"

                                                halign="right" width="20%"

                                                height="25">

                                  \<af:outputText value="Course Release:"

                                                 binding="#{backing\_investigatorInfo.outputText20151}"

                                                 id="outputText20151"

                                                 inlineStyle="font-weight:bold; color:rgb(56,59,63);"/>

                                \</afh:cellFormat>

                                \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat81}"

                                                id="cellFormat81" columnSpan="1"

                                                width="45%" height="25">

                                  \<af:selectOneRadio binding="#{backing\_investigatorInfo.selectRadioCourseRelease}"

                                                     id="selectRadioCourseRelease"

                                                     layout="horizontal"

                                                     autoSubmit="true"

                                                     valueChangeListener="#{backing\_investigatorInfo.cmdToggleCourseRelease\_action}"

                                                     value="#{coPiRow.courseReleaseFlag}">

                                    \<af:selectItem label="Yes" value="Y"

                                                   binding="#{backing\_investigatorInfo.selectItem11}"

                                                   id="selectItem11"/>

                                    \<af:selectItem label="No" value="N"

                                                   binding="#{backing\_investigatorInfo.selectItem21}"

                                                   id="selectItem21"/>

                                  \</af:selectOneRadio>

                                \</afh:cellFormat>

                                \<afh:cellFormat binding="#{backing\_investigatorInfo.cellFormat33}"

                                                id="cellFormat33"

                                                partialTriggers="selectRadioCourseRelease"

                                                columnSpan="1"

                                                halign="right" height="25"

                                                width="35%">

                                  \<af:commandButton text="Add Course Release Semester"

                                                    binding="#{backing\_investigatorInfo.commandButtonAddCourseRelease}"

                                                    id="commandButtonAddCourseRelease"

                                                    action="#{backing\_investigatorInfo.cmdAddCourseReleaseSemester\_action}"

                                                    rendered="#{coPiRow.courseReleaseFlag=='Y'?true:false}"

                                                    partialSubmit="true"

                                                    immediate="true"/>

                                \</afh:cellFormat>

                              \</afh:rowLayout>

                            \</afh:tableLayout>

                          \</af:panelBox>

                        \</afh:cellFormat>

                      \</afh:rowLayout>

                    \</af:iterator>

                  \</afh:cellFormat>

                \</afh:rowLayout>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2014
Added on Sep 25 2014
0 comments
251 views