<p:cellEditor> Ajax Event

UI Components for JSF
Post Reply
alang
Posts: 8
Joined: 17 Aug 2011, 22:48

17 Aug 2011, 22:57

Hello,

I know this stuff will be documented in the official doc when version 3 is ready, but I would love to check out the cool stuff now :P

So my question is: What's the name of the Ajax-Event when something in a data table changed because of a p:cellEditor usage?
(I thought this could be done some times before the whole ajax stuff changes with something like "onRowEdit")

Regards
Alesandro

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

17 Aug 2011, 23:07

The source of this component is available. So you can always look at that to find out the event names

alang
Posts: 8
Joined: 17 Aug 2011, 22:48

18 Aug 2011, 11:09

It seems to be named "rowEdit" so I thought of this implementation:

Code: Select all

 <p:dataTable>
     <p:ajax event="rowEdit" listener="#{controllerBeanPM.editEvent(event)}" />
 </p:dataTable>

Code: Select all

public void editEvent(RowEditEvent event) {
    // method fired
    // event == null
}
Any ideas why this is resolved to null?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

18 Aug 2011, 11:22

Code: Select all

<p:ajax event="rowEdit" listener="#{controllerBeanPM.editEvent}" />

alang
Posts: 8
Joined: 17 Aug 2011, 22:48

18 Aug 2011, 13:35

When trying this the method does not get fired. (I'am working with PF 3.0 M2 / same behavior in M3-SNAPSHOT)

alang
Posts: 8
Joined: 17 Aug 2011, 22:48

18 Aug 2011, 17:32

Oh man - I'm really sorry for the last post, because simply restarting Glassfish solved it (don't ask me why).
Anyway this solution is now working:

Code: Select all

<p:dataTable>
     <p:ajax event="rowEdit" listener="#{controllerBeanPM.editEvent}" />
</p:dataTable>

Code: Select all

public void editEvent(RowEditEvent event) {
     // do stuff
}

zilph
Posts: 7
Joined: 17 Jun 2011, 20:52

08 Sep 2011, 18:42

Hello.. im using the Primefaces 3.0.3M snapshot.. trying to make this component work with EJB, i followed the code posted by Optimus Prime
and the backing bean method that updates using the EJB is being called.. but i'm having a problem...

I need to get the Current Item from the datatable i'm editing.. but i'm getting null pointer exception.. where or how should i place
the setProperyActionListener to update the current item... as i do in other actions when using command Buttons..

tried placing it at the Output, the RowEditor and ajax Event.. but not working.. think anyone could help with an example? thanks

<f:setPropertyActionListener value="#{user}" target="#{lazyBean.selectedPersona}" />

zilph
Posts: 7
Joined: 17 Jun 2011, 20:52

09 Sep 2011, 20:59

Solved my problem . but if you can add a better Solution i would gladly appreciate it...

This is how i managed to solved it..


Code for Creating the DataTable and setting the Ajax event to call the save/update method when rowEdit method called..


<p:dataTable var="user" value="#{lazyBean.listarConductores()}" id="tbl"
rows="10" paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,30,50"
rowKey="#{user.idlicencia}"
page=""
>
<p:ajax event="rowEdit" listener="#{lazyBean.save()}" />


and this is the code.. i used to update the current or selected item in the table... i used the valueChangeListener in the InputText component to update the current
item value... i tried using the usual SelectedItem... but couldn't use the default setProperty when using ValueChangeListener, so i had to develop a new method
that receives a parameter(curren item) and name does not start to set.....


<p:column headerText="Telefono" >
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{user.telefono}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{user.telefono}" style="width:100%" valueChangeListener="#{lazyBean.updateUser(user)}" />
</f:facet>
</p:cellEditor>
</p:column>


I know there must be a better solution.. but this worked right now.. any improvements are welcome...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests