开发者

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.setI开发者_运维知识库dTransaction(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?


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.


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.


You should not set it to sessionScope. It would then be valid till the user session is active. You might want to use either pageFlowScope (this is valid for the life of a page) or a requestScope which is valid from the time a request is made by the client till it receives a response.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜