Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p:commandButton ajax not called inside p:dataList

Primefaces 2.2.1

Mojarra 2.1.2

I have a sophisticated method in my jsf bean :

public void saySomething() {
   log.debug("SAY SOMETHING !");
}

And a simple button in the jsf :

<p:commandButton
   value="say something"
   process="@this" update="@none" action="#{timetableBean.saySomething}" />

Clicking on the button, results in my simple logging :

DEBUG PhaseTracker - BEFORE PHASE INVOKE_APPLICATION 5
DEBUG TimetableBean - SAY SOMETHING !
DEBUG PhaseTracker - AFTER PHASE INVOKE_APPLICATION 5

Let's go to next simple case. When placing that identical button inside a p:dataList like this :

<p:dataList id="groupUsers2" value="#{timetableBean.group.users}" var="user" itemType="circle" style="padding:0; margin: 0;">
   <p:commandButton
      value="#{user.data['selected'] ? 'V' : 'X'}"
      process="@this" update="@none" action="#{timetableBean.saySomething}" />
   <p:commandLink value="#{user.userId} - #{user.name}" process="@this" />
</p:dataList>

Clicking on the button, results in my simple logging :

DEBUG PhaseTracker - BEFORE PHASE INVOKE_APPLICATION 5
DEBUG PhaseTracker - AFTER PHASE INVOKE_APPLICATION 5

The method of saySomething() was not called !

What did i do wrong ?

like image 982
Albert Gan Avatar asked Jul 20 '11 12:07

Albert Gan


1 Answers

Problem solved.

Found the solution in here

In order for listener to be invoked, the components inside the p:dataList should be encapsulated with p:column

<p:dataList id="groupUsers2" value="#{timetableBean.group.users}" var="user" itemType="circle" style="padding:0; margin: 0;">
  <p:column>
   <p:commandButton
      value="#{user.data['selected'] ? 'V' : 'X'}"
      process="@this" update="@none" action="#{timetableBean.saySomething}" />
   <p:commandLink value="#{user.userId} - #{user.name}" process="@this" />
  </p:column>
</p:dataList>

Strange though, i didnt see this in the documentation, as it doesnt specify the p:column. Perhaps it's in the errata for primefaces 2.2.1 doc ?

Related problems here.

like image 149
Albert Gan Avatar answered Oct 31 '22 07:10

Albert Gan