This discussion is archived
1 2 Previous Next 21 Replies Latest reply: Sep 20, 2011 1:32 AM by Frank Nimphius RSS

af:commandButton inside af:table

inthelineoffire Pro
Currently Being Moderated
Hi ADF Experts,

I am stuck with a strange problem

I have an af:commandButton inside af:table. Clicking on which will print a statement (as of now).
I have another af:commandButton outside af:table calling the same method.
The problem is the commandButton outside the af:table is working and the method is executing where as the commandButton inside af:table is not working.

Code

<af:table var="party" value="#{createOpportunity.partyList}" id="table1"
contentDelivery="immediate"
emptyText="No records found"
rendered="#{createOpportunity.flag}" binding="#{createOpportunity.table1}"
rowSelection="single" >
<af:column>
<f:facet name="header">
<af:outputText value="Person Name"
styleClass="tableHeader"/>
</f:facet>
<af:outputText value="#{party.person_first_name}"
/>
</af:column>
<af:column>
<f:facet name="header">
<af:outputText value="Last Name"
/>
</f:facet>
<af:outputText value="#{party.person_last_name}"
/>
</af:column>
<af:column>
<f:facet name="header">
<af:outputText value="Phone Number"
/>
</f:facet>
<af:outputText value="#{party.phone_number}"
/>
</af:column>
<af:column id="btn">
<af:commandButton id="cmd_deal_details"
styleClass="align:center;" text="Go" actionListener="#{createOpportunity.selectedRow}"/> // this is not working , message is not printed
</af:column>
</af:table>


<af:commandButton text="Select" id="cb02"
actionListener="#{createOpportunity.selectedRow}"/> // this is working and printing the message


Managed Bean Code:

public String selectedRow(ActionEvent e) {
System.out.println("Inside selectdata method");

return null;
}


Any leads will be of gr8 help
Thnks

Edited by: user13002869 on Mar 3, 2011 2:28 AM
  • 1. Re: af:commandBuon inside af:table
    Mohammad Jabr Guru
    Currently Being Moderated
    can you try to make the return type to your selectedRow method to void

    try this
    public void selectedRow(ActionEvent e) {
    System.out.println("Inside selectdata method");
    }
    instead of this
    public String selectedRow(ActionEvent e) {
    System.out.println("Inside selectdata method");
    
    return null;
    }
  • 2. Re: af:commandButton inside af:table
    inthelineoffire Pro
    Currently Being Moderated
    Thnks for the reply.

    Tried changing the return type also to void, but the problem continues.

    btw I am using JDev 11.1.1.4 g

    Edited by: user13002869 on Mar 3, 2011 1:28 AM
  • 3. Re: af:commandBuon inside af:table
    Timo Hahn Oracle ACE
    Currently Being Moderated
    You can't use an actionListener to call a action method. The two methods have different signatures. An action returns a string which is the navigation case. An actionListener does not have a return type (it's void)
    </af:column>
    <af:column id="btn">
              <af:commandButton text="commandButton 2" id="cb2" action="#{xxyyzzBean.cb2_action}"
                                partialSubmit="true" actionListener="#{xxyyzzBean.cb2ActionListener}">
    </af:column>
    should work with
        public String cb2_action()
        {
           // do something with the action
           return null;
         }
        public void cb2ActionListener(ActionEvent actionEvent)
        {
            // Add event code here...
        }
    Timo
  • 4. Re: af:commandButton inside af:table
    inthelineoffire Pro
    Currently Being Moderated
    Thnks for ur reply, Timo .
    Agreed Both the methods are different.

    I tried using actionListener(using ActionEven as parameter and returning void) as well as action (no parameters and returning some String) attribute, but both are not working inside af:table.

    JDev gives errors the moment there is a miss match in the attributes values :)

    Edited by: user13002869 on Mar 3, 2011 2:29 AM
  • 5. Re: af:commandButton inside af:table
    Timo Hahn Oracle ACE
    Currently Being Moderated
    It's working for me ...

    Have you tried with a new page and default af:table?
    Your code looks like you are using a custom table.

    Timo
  • 6. Re: af:commandButton inside af:table
    inthelineoffire Pro
    Currently Being Moderated
    Not on a new page but i tried with default af:table. Then went on to copy code form internet :P

    btw can you share the code ?

    still i dont see any thing wrong in my code as the actionlistener as well as action methods are getting executed outside the table :(
  • 7. Re: af:commandButton inside af:table
    Timo Hahn Oracle ACE
    Currently Being Moderated
    You see the code in my previous message...
    Just put the two methods into your bean and in the ui select the button inside the table and click the arrow on the right side of the Action property and the select the existing bean and the existing method. Do the same with the ActionListener property and you are done.

    Timo
  • 8. Re: af:commandButton inside af:table
    inthelineoffire Pro
    Currently Being Moderated
    Thnks for ur tme Timo.

    A pointer that might just help.

    When i am trying to set the action/actionListener value from the property inspector.. i cant see the method that i created in the backing bean.

    Following is the code

    public void getSelectedRow() {
    System.out.println("Inside selectdata method");

    }

    public void getSelectedRow(ActionEvent e) {
    System.out.println("Inside selectdata ActionEvent method");

    }

    Ideally these methods should come in the property inspector of the af:commandButton action/actionListerner property right ?
  • 9. Re: af:commandButton inside af:table
    Timo Hahn Oracle ACE
    Currently Being Moderated
    The problem is the naming of the methods. If you name a method get... the framework assumes it to be a getter for an attribute and will not show it in the dialog. Rename the method and it will show.

    Timo
  • 10. Re: af:commandButton inside af:table
    inthelineoffire Pro
    Currently Being Moderated
    Method Naming is a result of my permutation and combination to get it working.

    Back to the main problem, can some body still help me ?

    @ Timo : I created a default table also now ..but :(

    Edited by: user13002869 on Mar 3, 2011 5:15 AM
  • 11. Re: af:commandButton inside af:table
    Timo Hahn Oracle ACE
    Currently Being Moderated
    But what?

    Any error? The code I gave it pretty simple and works for me.

    Timo
  • 12. Re: af:commandButton inside af:table
    inthelineoffire Pro
    Currently Being Moderated
    The problem is there is no error.

    Clicking on the button doesn't do anything inside <af:table>, same button code outside <af:table> works.
  • 13. Re: af:commandButton inside af:table
    inthelineoffire Pro
    Currently Being Moderated
    Hi All,

    Crated a new demo page with new table and its working but .same code not working in my real example.

    Java Code:

    public Demo(){
    Party party = new Party();
    party.setPerson_first_name("Saif");
    party.setPerson_last_name("Kamaal");
    party.setPhone_number("1234556");
    partyList.add(party);

    }

    JSF Code:

    <af:table value="#{demo.partyList}" var="row"
    rowBandingInterval="0" binding="#{demo.t1}" id="t1">
    <af:column sortable="false" headerText="Party_type" align="start"
    id="c6">
    <af:outputText value="#{row.party_type}" id="ot7"/>
    </af:column>
    <af:column sortable="false" headerText="Person_pre_name_adjunct"
    align="start" id="c2">
    <af:outputText value="#{row.person_pre_name_adjunct}" id="ot4"/>
    </af:column>
    <af:column sortable="false" headerText="Person_first_name"
    align="start" id="c9">
    <af:outputText value="#{row.person_first_name}" id="ot3"/>
    </af:column>
    <af:column sortable="false" headerText="Person_last_name" align="start"
    id="c5">
    <af:outputText value="#{row.person_last_name}" id="ot9"/>
    </af:column>
    <af:column sortable="false" headerText="Phone_country_code"
    align="start" id="c4">
    <af:outputText value="#{row.phone_country_code}" id="ot5"/>
    </af:column>
    <af:column sortable="false" headerText="Phone_area_code" align="start"
    id="c10">
    <af:outputText value="#{row.phone_area_code}" id="ot10"/>
    </af:column>
    <af:column sortable="false" headerText="Phone_number" align="start"
    id="c1">
    <af:outputText value="#{row.phone_number}" id="ot1"/>
    </af:column>
    <af:column sortable="false" headerText="Email_address" align="start"
    id="c3">
    <af:outputText value="#{row.email_address}" id="ot8"/>
    </af:column>
    <af:column sortable="false" headerText="Address1" align="start" id="c7">
    <af:outputText value="#{row.address1}" id="ot6"/>
    </af:column>
    <af:column sortable="false" headerText="Po_box" align="start" id="c12">
    <af:outputText value="#{row.po_box}" id="ot11"/>
    </af:column>
    <af:column sortable="false" headerText="Emirate" align="start" id="c8">
    <af:outputText value="#{row.emirate}" id="ot2"/>
    </af:column>
    <af:column sortable="false" headerText="" id="c11">
    <af:commandButton id="cb1"
    actionListener="#{demo.selectedRow}"/>
    </af:column>
    </af:table>





    Then i copied the same code bk to my page and again its not working.
    Scenario:

    The only difference in both the page is in my page i am filling the table on click of a button (Search). Also i have set the attribute contentDelivery = "immediate" as unless i specify this the data is not getting displayed.

    If i remove contentDelivery attribute, my table is empty. I guess this attribute is a problem in my case

    neone facing the same issue ?
  • 14. Re: af:commandButton inside af:table
    865473 Newbie
    Currently Being Moderated
    Did you solved this problem?
    I'm facing the same issue.
    I'm using ADF Faces, but not ADF BC. ADF Faces seems to lose a lot of functionality when not using BC.
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points