How can <f:setPropertyActionListener> used with primefaces datatable rowExpansion

402 Views Asked by At

can <f:setPropertyActionListener> be used in primefaces datatable rowExpansion? I tried

<p:ajax event="rowToggle" listener="#{queryStudiesBean.onRowToggle}" >
      <f:setPropertyActionListener target="#{queryPatientBean.test}" value="sucess"/>
</p:ajax>

but it says

<f:setPropertyActionListener> Parent is not of type ActionSource

also I tried

<p:rowToggler>
    <f:setPropertyActionListener target="#{queryPatientBean.test}" value="sucess"/>
</p:rowToggler>

but it gives the same error, is there anyway to use it?

2

There are 2 best solutions below

1
On

<f:setPropertyActionListener> works with ActionSource components like <p:commandLink> and <p:commandButton>.

<p:rowExpansion>
   <p:commandLink>
      <f:setPropertyActionListener>
   </p:commandLink>
</p:rowExpansion>
1
On

I knew how to do it finally, I put the <f:setPropertyActionListener> inside remoteCommand, which in turn needs to be inside a form:

<form>
      <p:remoteCommand name="callButton" ajax="false" id="callButton" action="#{queryPatientBean.printTest()}">
           <f:setPropertyActionListener target="#{queryPatientBean.test}" value="success"/>
      </p:remoteCommand>
</form>

then I called this remoteCommand from <p:ajax> onstart:

<p:ajax event="rowToggle" onstart="callButton();" listener="#{queryStudiesBean.onRowToggle}" />