Search code examples
bindingoracle-adfjdeveloper

How to bind an ADF Table on button click


Coming from ASP.NET I'm having a hard time with basic ADF concepts.

I need to bind a table on a button click, and for some reason I don't understand (I'm leaning towards page life cycle, which I guess is different from ASP.NET) it's not working.

This is my ADF code:

<af:commandButton text="#{viewcontrollerBundle.CMD_SEARCH}"
    id="cmdSearch"
    action="#{backingBeanScope.indexBean.cmdSearch_click}"
    partialSubmit="true"/>

<af:table var="row" rowBandingInterval="0" id="t1"
                    value="#{backingBeanScope.indexBean.transactionList}"
                    partialTriggers="::cmdSearch"
                    binding="#{backingBeanScope.indexBean.table}">
            <af:column sortable="false" headerText="idTransaction" id="c2">
              <af:outputText value="#{row.idTransaction}" id="ot4"/>
            </af:column>
            <af:column sortable="false" headerText="referenceCode" id="c5">
              <af:outputText value="#{row.referenceCode}" id="ot7"/>
            </af:column>
          </af:table>

This is cmdSearch_click:

public String cmdSearch_click() {
    List l = new ArrayList();
    Transaction t = new Transaction();
    t.setIdTransaction(BigDecimal.valueOf(1));
    t.setReferenceCode("AAA");
    l.add(t);

    t = new Transaction();
    t.setIdTransaction(BigDecimal.valueOf(2));
    t.setReferenceCode("BBB");
    l.add(t);

    setTransactionList(l);

    // AdfFacesContext.getCurrentInstance().addPartialTarget(table);

    return null;
 }

The commented line also doesn't work.

If I populate the list on my Bean's constructor, the table renders ok.

Any ideas?


Solution

  • It was a scope issue.

    After reading this post, I think the correct way to do it is to set it to viewScope

    If anyone thinks this is incorrect, please let me know. For now this is my answer.