The DataTable RowEditEvent notification is being delivered during the Apply Request Values phase.
I'm expecting the notification to occur during the Invoke Application phase.
Is this a bug?
RowEditEvent Notification At Wrong Phase
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
I changed the source code of org.primefaces.component.datatable.DataHelper.java from:
to:
This fixed the problem. Should I create a bug ticket? Should I commit the fix?
Code: Select all
table.queueEvent(new RowEditEvent(table, table.getRowData()));
Code: Select all
RowEditEvent event = new RowEditEvent(table, table.getRowData());
event.setPhaseId(PhaseId.INVOKE_APPLICATION);
table.queueEvent(event);
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
I just did an SVN update. Optimus committed a fix on October 1. See http://code.google.com/p/primefaces/sou ... ail?r=3507
Hi,
I have the exact same error: RowEditEvent:getObject() return the old value instead of the new value.
It seems that you forgot to commit the changes you made on org.primefaces.component.datatable.DataHelper.java
http://code.google.com/p/primefaces/sou ... ail?r=3507 says that you only commit the changes on org.primefaces.event.RowEditEvent.java
Anyways, PrimeFaces rocks
Cheers,
Remy
Here is my code:
The xhtml page:
The result: request.getParameter( "myForm:carList:0:color" ); show the new value but getObject the old one.
I have the exact same error: RowEditEvent:getObject() return the old value instead of the new value.
It seems that you forgot to commit the changes you made on org.primefaces.component.datatable.DataHelper.java
http://code.google.com/p/primefaces/sou ... ail?r=3507 says that you only commit the changes on org.primefaces.event.RowEditEvent.java
Anyways, PrimeFaces rocks
Cheers,
Remy
Here is my code:
Code: Select all
@ManagedBean(name="adminDB")
@SessionScoped
public class AdminDB extends BaseBean implements Serializable{
private static final long serialVersionUID = 7469250264779637490L;
public void editType(RowEditEvent e){
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
String newColor = request.getParameter( "myForm:carList:0:color" );
System.out.println("newTipo: "+newColor);
//UIComponent myInput1 = e.getComponent().findComponent("in");
Tipo t=(Tipo)e.getObject();
System.out.println("Tipo:"+t.getId()+" "+t.getNombre());
}
[from BaseBean class]
@SuppressWarnings("unchecked")
public List<Tipo> getTypes() {
List<Tipo> l;
Session session = HibernateUtil.currentSession();
Criteria c = session.createCriteria(Tipo.class);
l = (List<Tipo>)c.list();
HibernateUtil.closeSession();
return l;
}
}
Code: Select all
<h:form id="myForm">
<p:dataTable var="car" value="#{adminDB.types}" widgetVar="cars" id="carList" rowEditListener="#{adminDB.editType}">
<f:facet name="header">
In-Cell Editing
</f:facet>
<p:column headerText="Model">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.id}" id="idout"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{car.id}" id="idin"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Year">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.nombre}" id="out"/>
</f:facet>
<f:facet name="input">
<p:inputText value="#{car.nombre}" id="color"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Options">
<p:rowEditor />
</p:column>
</p:dataTable>
</h:form>
Code: Select all
newTipo: NewSolo1234
Tipo:1 Sólo
Hi again,
It´s exactly that, the rowEditEvent method is not call at the right moment (and/or should create a new object and not modified the existing one):
If I use the showcase (adding a rowEditListener method) : when I edit the model of the car object and validate it, (see code here http://www.primefaces.org/showcase/ui/d ... diting.jsf)
first the getCarsSmall is called (many times),
then the setModel of the Car class
again the getCarsSmall
finally the rowEditListenermethod.
=> The rowEditListener method should have been call at first!
As in the showcase, if you load your data in the constructor of the managerbean you dont care of that wrong behaviour.
But if you load your data (form DB in my case) when calling getCarsSmall, you can´t have the edited value.
Should I open a ticket? I'm using Primeface 2.2
Cheers,
Remy
It´s exactly that, the rowEditEvent method is not call at the right moment (and/or should create a new object and not modified the existing one):
If I use the showcase (adding a rowEditListener method) : when I edit the model of the car object and validate it, (see code here http://www.primefaces.org/showcase/ui/d ... diting.jsf)
first the getCarsSmall is called (many times),
then the setModel of the Car class
again the getCarsSmall
finally the rowEditListenermethod.
=> The rowEditListener method should have been call at first!
As in the showcase, if you load your data in the constructor of the managerbean you dont care of that wrong behaviour.
But if you load your data (form DB in my case) when calling getCarsSmall, you can´t have the edited value.
Should I open a ticket? I'm using Primeface 2.2
Cheers,
Remy
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
This thread is about a bug that was around a long time ago and has been fixed already.
The rowEditListener should be called last - in the INVOKE_APPLICATION phase - and it is (now).
The getter method is NOT the place to load data. You need to read this thread:
http://primefaces.prime.com.tr/forum/vi ... f=3&t=5239
The rowEditListener should be called last - in the INVOKE_APPLICATION phase - and it is (now).
The getter method is NOT the place to load data. You need to read this thread:
http://primefaces.prime.com.tr/forum/vi ... f=3&t=5239
-
- Posts: 5
- Joined: 18 Jun 2011, 04:06
This is an old post but I am also running into a similar situation. I am constructing the entire dataTable in the managed bean:
If I don't build the "dataTable" in the get method, the table that is rendered is mangled. It looks like the DOM is messed up as the input and out fields for each column are showing and the pencil edit button is not working. If I just return the dataTable attribute in the getter and build the dataTable each time I persist a row, or in a PostConstruct, I get this problem.
However, if put the logic of building the dataTable in the getter, it renders fine, but I see the same problem as above. The rowEdit event is called after the table is populated and I lose the edits.
I'm using @SessionScoped, but even @RequestScoped with a PostConstruct to build the table does not work either.
This is a bit of a blocker for me. It works fine if I just use p:dataTable tags instead of the binding
Thanks
Alan
Code: Select all
<p:dataTable binding="#{choiceBean.dataTable}">
<p:ajax event="rowEdit" listener="#{choiceBean.onRowEdit}" />
</p:dataTable>
However, if put the logic of building the dataTable in the getter, it renders fine, but I see the same problem as above. The rowEdit event is called after the table is populated and I lose the edits.
I'm using @SessionScoped, but even @RequestScoped with a PostConstruct to build the table does not work either.
This is a bit of a blocker for me. It works fine if I just use p:dataTable tags instead of the binding
Thanks
Alan
-
- Information
-
Who is online
Users browsing this forum: No registered users and 52 guests