Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

p:cellEditor does not save textarea onblur when clicking a link

Tags:

jsf

primefaces

Saving a text inside a p:cellEditor > p:inputTextarea works perfectly onblur when clicking outside the cell. However when clicking on a link (e.g. commandButton, commandLink) coming from a p:cellEditor > p:inputTextarea it does not execute the p:ajax cellEdit event beforehand. It instead executes the clicked link.

This is not correct since it works for p:inputTextarea without a p:cellEditor. I realize this might as well be a Primefaces bug. Any idea how to work around this?

<p:dataTable>

    <p:ajax event="cellEdit" listener="#{bean.onCellEdit}" />

    <p:cellEditor>
        <f:facet name="output">
          <h:outputText    value="#{model.text}" />
        </f:facet>
        <f:facet name="input">
          <p:inputTextarea value="#{model.text}" />
        </f:facet>
    </p:cellEditor>

<p:dataTable>

<p:commandButton actionListener="#{bean.someOtherAction}" />

I submitted the bug to Primefaces. But is there a workaround for this via javascript/jQuery?

like image 923
Endre Avatar asked Sep 30 '22 18:09

Endre


1 Answers

After no success on the Primefaces bug report I ended up hooking up the listener to all of the p:cellEditor instances directly. It seems to work and I'm not losing inputs anymore.

<p:cellEditor>
    <f:facet name="output">
      <h:outputText    value="#{model.text}" />
    </f:facet>
    <f:facet name="input">
      <p:inputTextarea value="#{model.text}">
      <!-- this is the relevant line -->
      <p:ajax listener="#{bean.onCellEdit}" global="false" update="@this" />
      <!-- end relevant line -->
      </p:inputTextarea>
    </f:facet>
</p:cellEditor>
like image 64
Endre Avatar answered Oct 15 '22 22:10

Endre