views:

207

answers:

2

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?

A: 

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.

Juan Manuel
more info http://download.oracle.com/docs/cd/E12839_01/web.1111/b31973/af_lifecycle.htm#CHDGGGBI
Juan Manuel
A: 

I'm not sure backing bean scope is the right one you want to use. I'd suggest either pageFlowScope or Session scope. These will most closely map to what you want to model.

PageFlowScope follows what the user is clicking on, so two instances of the same web app/same user have different PageFlow Scopes.

Session scope is common to all instances of the web app by the same user.

Application scope is common to all users. I would avoid this almost always.

Request scope only lasts between view requests. Not really useful except for extremely short duration data.

Mark Robinson