12 Replies Latest reply: Jul 8, 2013 10:02 AM by MobileADFDev RSS

    Sample Code for nested iterator for Mobile ADF

    MobileADFDev
      I haven ArrayList inside an ArrayList. I want to add an itertor inside an iterator (Nested Iterator) and display the values from the second List. My data will look like this


      Column1.1 | Column1.2 | Column1.3........................Column1.n
      ----------------------------------------------------------------------------------------
      Column2.1 | Column2.2 | Column2.3........................Column2.n
      ---------------------------------------------------------------------------------------
      Column3.1 | Column3.2 | Column3.3........................Column3.n
      ---------------------------------------------------------------------------------------
      .
      .
      .
      .
      .
      .
      --------------------------------------------------------------------------------------
      Columnn.1 | Columnn.2 | Columnn.3........................Columnn.n
      --------------------------------------------------------------------------------------

      Can some one please provide a sample code to achieve this?

      Edited by: MobileADFDev on Jun 5, 2013 6:48 AM
        • 1. Re: Sample Code for nested iterator for Mobile ADF
          MobileADFDev
          Can someone please help?
          • 2. Re: Sample Code for nested iterator for Mobile ADF
            Frank Nimphius-Oracle
            Hi,

            Not sure you can get an ArrayList from an ArrayList in EL as you would pass the index of the object you want. So best is to have an ArrayList of Objects in which case the Object has a property set/getChildren returning a List of dependent children. With this in place, have you tried specifying a value for the <amx:iterator> "var" property and access this from a nested <amx:iterator> as a value (e.g. var="items") ....

            <amx:iterator value="#{items.child}">

            Or what have you tried so far?

            Frank
            • 3. Re: Sample Code for nested iterator for Mobile ADF
              MobileADFDev
              LWO OBJECTS

              public class TableColumnMasterList {
              private List masterTableColumns;
              public TableColumnMasterList() {
              if (masterTableColumns == null) {
              masterTableColumns = new ArrayList();
              }
              }
              public TableColumnList[] getTableValues() {
              TableColumnList e[] = null;
              e = (TableColumnList[])masterTableColumns.toArray(new TableColumnList[masterTableColumns.size()]);
              return e;
              }
              public int getTableRowCount() {
              return masterTableColumns.size();
              }
              public void addTableRow(TableColumnList result) {
              masterTableColumns.add(result);
              }
              }
              **************************************************************************************************************
              public class TableColumnList {
              private List nameValueLwo;
              public TableColumnList() {
              if (nameValueLwo == null) {
              nameValueLwo = new ArrayList();
              }
              }
              public NameValueLwo[] getNameValueLwo() {
              NameValueLwo e[] = null;
              e = (NameValueLwo[])nameValueLwo.toArray(new NameValueLwo[nameValueLwo.size()]);
              return e;
              }
              public int getTableColumnsCount() {
              return nameValueLwo.size();
              }
              public void addTableColumns(NameValueLwo result) {
              nameValueLwo.add(result);
              }
              }
              ***********************************************************************************************
              public class NameValueLwo {
              private String name = null;
              private String value= null;
              public NameValueLwo(String name, String value) {
              super();
              this.name = name;
              this.value = value;
              }
              public void setName(String name) {
              this.name = name;
              }
              public String getName() {
              return name;
              }
              public void setValue(String value) {
              this.value = value;
              }
              public String getValue() {
              return value;
              }
              }
              ***********************************************************************************************************************************
              PAGE DEFINITION
              <?xml version="1.0" encoding="UTF-8" ?>
              <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.2.62.76" id="IBCMReportPageDef"
              Package="com.sni.ilm.mobile.pageDefs">
              <parameters/>
              <executables>
              <variableIterator id="variables"/>
              <iterator Binds="root" RangeSize="25" DataControl="SearchBean"
              id="SearchBeanIterator"/>
              <accessorIterator MasterBinding="SearchBeanIterator" Binds="tableRows" RangeSize="25"
              DataControl="InboundContainerSearchBean" BeanClass="com.sni.ilm.lwo.TableColumnList"
              id="tableRowsIterator"/>
              </executables>
              <bindings>
              <tree IterBinding="tableRowsIterator" id="tableRows">
              <nodeDefinition DefName="com.sni.ilm.lwo.TableColumnList" Name="tableRows0">
              <AttrNames>
              <Item Value="tableColumnsCount"/>
              </AttrNames>
              <Accessors>
              <Item Value="NameValueLwo"/>
              </Accessors>
              </nodeDefinition>
              <nodeDefinition DefName="com.sni.ilm.lwo.NameValueLwo" Name="nameValueLwo0">
              <AttrNames>
              <Item Value="name"/>
              <Item Value="value"/>
              </AttrNames>
              </nodeDefinition>
              </tree>
              </bindings>
              </pageDefinition>
              ******************************************************************************************************************
              BEAN METHOD

              public void setTableRows(TableColumnMasterList tableColumnRows) {
              this.tableColumnRows = tableColumnRows;
              }
              public TableColumnList[] getTableRows() {
              return tableColumnRows.getTableValues();
              }
              ******************************************************************************************************************
              AMX PAGE

              <amx:tableLayout id="tableLayout1" borderWidth="1" cellPadding="10">
              <amx:iterator var="row2" value="#{bindings.tableRows.collectionModel}" id="i2">
              <amx:rowLayout id="rowLayout2">
              <amx:iterator var="columns" value="#{row2.nameValueLwo}" id="i3">
              <amx:cellFormat id="cellFormatA" halign="center">
              <amx:outputText id="otA" value="#{columns.value}"/>
              </amx:cellFormat>
              </amx:iterator>
              </amx:rowLayout>          
              </amx:iterator>
              </amx:tableLayout>
              ******************************************************************************************************************

              In the AMX page when i mouse over on "row2.nameValueLwo", i can see the error "Reference row2 not found".
              • 5. Re: Sample Code for nested iterator for Mobile ADF
                ArunBabu

                This is not the exact way but more of a workaround.

                 

                Try modifying your treebinding in pagedefinition to

                 

                <tree IterBinding="tableRowsIterator" id="tableRows">

                         <nodeDefinition DefName="com.sni.ilm.lwo.TableColumnList" Name="tableRows0">

                            <AttrNames>

                               <Item Value="tableColumnsCount"/>

                               <Item Value="NameValueLwo"/>

                            </AttrNames>

                            <Accessors>

                               <Item Value="NameValueLwo"/>

                            </Accessors>

                         </nodeDefinition>

                         <nodeDefinition DefName="com.sni.ilm.lwo.NameValueLwo" Name="nameValueLwo0">

                            <AttrNames>

                               <Item Value="name"/>

                               <Item Value="value"/>

                            </AttrNames>

                         </nodeDefinition>

                </tree>

                 

                The collection needs to be added as an attribute. If still not working, if you upload a sample application I could give a try.

                 

                Thanks

                Arun

                • 6. Re: Sample Code for nested iterator for Mobile ADF
                  MobileADFDev

                  That also didnt help...I have created the sample app, but how can i export it to a jar or zip file and upload it?

                   

                  I just zipped the application folder and uploaded in Samepage.io. Here is the link

                   

                  https://samepage.io/4bcacf3e9f6e1874ddfc59dab29b4aafc7bc19e6/share/ae60aa337a4ab3b84738bc7ef291b56e10fb1420

                  • 7. Re: Sample Code for nested iterator for Mobile ADF
                    MobileADFDev

                    958923, any help?

                    • 9. Re: Sample Code for nested iterator for Mobile ADF
                      ArunBabu

                      Your code seems to have a few typos. I have corrected it in the below fields. If the below code is also not working you may need to update to the lates ADF Mobile version ie 11.1.2.4

                      I have tested the below code in my machine and it works fine

                      reportList.amx

                      {code}

                      <?xml version="1.0" encoding="UTF-8" ?>

                      <amx:view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amx="http://xmlns.oracle.com/adf/mf/amx"

                                xmlns:dvtm="http://xmlns.oracle.com/adf/mf/amx/dvt">

                          <amx:panelPage id="pp1">

                              <amx:facet name="header">

                                  <amx:outputText value="Report" id="ot1"/>

                              </amx:facet>

                              <amx:tableLayout id="tableLayout1" borderWidth="1" cellPadding="10">

                                  <amx:rowLayout id="rowLayout1">

                                      <amx:iterator var="row" value="#{bindings.tableHeader.collectionModel}" id="i1">

                                          <amx:cellFormat id="header1" halign="center" inlineStyle="background-color:Silver;">

                                              <amx:outputText id="header1ot" value="#{row.value}"

                                                              inlineStyle="font-size:2px; font-weight:bold;"/>

                                          </amx:cellFormat>

                                      </amx:iterator>

                                  </amx:rowLayout>

                                  <amx:iterator var="row" value="#{bindings.tableRows.collectionModel}" id="i2">

                                      <amx:rowLayout id="rowLayout2">

                                          <amx:cellFormat id="cellFormatA0" halign="center">

                                              <amx:outputText id="otA0" value="#{row.value}"/>

                                          </amx:cellFormat>

                                          <amx:iterator var="columns" value="#{row.nameValueLwo}" id="i3">

                                              <amx:cellFormat id="cellFormatA" halign="center">

                                                  <amx:outputText id="otA" value="#{columns.value}"/>

                                              </amx:cellFormat>

                                          </amx:iterator>

                                      </amx:rowLayout>

                                  </amx:iterator>

                              </amx:tableLayout>

                          </amx:panelPage>

                      </amx:view>

                      {code}

                       

                      reportListPageDef.xml

                      {code}

                      <?xml version="1.0" encoding="UTF-8" ?>

                      <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.2.62.76" id="reportListPageDef"

                                      Package="testiterator.mobile.pageDefs">

                          <parameters/>

                          <executables>

                              <variableIterator id="variables"/>

                              <iterator Binds="root" RangeSize="25" DataControl="GenerateReport" id="GenerateReportIterator"/>

                              <accessorIterator MasterBinding="GenerateReportIterator" Binds="tableHeader" RangeSize="25"

                                                DataControl="GenerateReport" BeanClass="testiterator.mobile.lwo.NameValueLwo"

                                                id="tableHeaderIterator"/>

                              <accessorIterator MasterBinding="GenerateReportIterator" Binds="tableRows" RangeSize="25"

                                                DataControl="GenerateReport" BeanClass="testiterator.mobile.lwo.TableColumnList"

                                                id="tableRowsIterator"/>

                          </executables>

                          <bindings>

                              <tree IterBinding="tableHeaderIterator" id="tableHeader">

                                  <nodeDefinition DefName="testiterator.mobile.lwo.NameValueLwo" Name="tableHeader0">

                                      <AttrNames>

                                          <Item Value="value"/>

                                      </AttrNames>

                                  </nodeDefinition>

                              </tree>

                              <tree IterBinding="tableRowsIterator" id="tableRows">

                                  <nodeDefinition DefName="testiterator.mobile.lwo.TableColumnList" Name="tableRows0">

                                      <AttrNames>

                                          <Item Value="tableColumnsCount"/>

                                          <Item Value="nameValueLwo"/>

                                      </AttrNames>

                                      <Accessors>

                                          <Item Value="nameValueLwo"/>

                                      </Accessors>

                                  </nodeDefinition>

                                  <nodeDefinition DefName="testiterator.mobile.lwo.NameValueLwo" Name="nameValueLwo0">

                                      <AttrNames>

                                          <Item Value="name"/>

                                          <Item Value="value"/>

                                      </AttrNames>

                                  </nodeDefinition>

                              </tree>

                          </bindings>

                      </pageDefinition>

                      {code}

                      • 10. Re: Sample Code for nested iterator for Mobile ADF
                        MobileADFDev

                        Thank you very much. Your suggestion worked. The issue was the wrong package was used for an LWO in the pagedef.

                         

                        Can you please help me with another question?

                         

                        How to make sure an instance of the Bean is not created when i go to a new AMX page. I tried to use all scopes (PageFlow and Application) of the bean but all of them create a new instance of the bean when the control comes into the next page. So whatever variables i set in the first page is not passed over to the next page. below is how i wrote my app.

                         

                        Click a button on FirstPage to call a bean's method using actionListener -> The method in SampleBean call DB function and set values to the member variables in this bean -> Will go to Second Page based on the taskflow's action.

                        • 11. Re: Sample Code for nested iterator for Mobile ADF
                          ArunBabu

                          Please mark your original question as Answered if your question has been answered and posting the new one as seperate question would be better.

                           

                          Regarding the second question, for both pageFlowScope and applicationScope new instance of bean wont be created. Also the usecase seems to be pretty common one. The values set in the SampleBean from the db should be accessible in the second page also. Again posting the sample app can be helpful!

                           

                          Arun

                          • 12. Re: Sample Code for nested iterator for Mobile ADF
                            MobileADFDev

                            I have created the new thread here, https://forums.oracle.com/thread/2558082 and also provided the code as well.