1

I'm still developing my data table UI application, and finally I'm about the final stage of the development of this component: inline cell editing.

First of all, the data table is built fully dynamically at the Java side, and no facelet declarations are used to describe the table. If I'd have a static table declaration, the editing could be specified like this (see the In-Cell Editing chapter):

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

I can easily specify the data table editable with dataTable.setEditable(true) in the Java code - and it works, please note, the editing Save/Cancel icons are working nice but have no effect at the back end. Since I cannot it declare in the way specified at the PF ShowCase Labs page (must I always use the listeners there?) because of the data tables are rendered dynamically, I'm trying to use the following:

public static AjaxBehavior createAjaxBehavior(MethodExpression expression) {
    final AjaxBehavior behavior = new AjaxBehavior();
    behavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(expression));
    return behavior;
}
...
dataTable.addClientBehavior("rowEdit", createAjaxBehavior(createMethodExpression(TableBean.class, "onEdit", void.class, new Class<?>[] {RowEditEvent.class})));

But as soon as I add the rowEdit listener, like I'm trying to do above, and wow I suddenly got: mojarra is not defined and no Save/Cancel row edit buttons are working. Ok, I've found a similar problem described and resolved here, included the necessary script manually, and now the client-side JavaScript error is gone, however I still cannot exit the row editing mode, and the row is still not updated.

I wasted all day trying to figure out what's going on, and I'm blind to see the correct way. Do I simply miss something behind (like identifying a certain row, or probably specifying something else somewhere -- but my Java code does not generate anything more than specified in the PF example), or anything whatever?

Thanks in advance.

Community
  • 1
  • 1
Lyubomyr Shaydariv
  • 20,327
  • 12
  • 64
  • 105
  • Did you have a look at showcase-labs Editable Datatable [source code](http://code.google.com/p/primefaces/source/browse/examples/trunk/showcase/src/main/webapp/ui/datatableEditing.xhtml) or source from [demo page](http://www.primefaces.org/showcase-labs/ui/datatableEditing.jsf)? – Flavio Cysne Jul 19 '12 at 17:01
  • @FlavioCysne, sure, this is where my dynamic code is inspired from. – Lyubomyr Shaydariv Jul 20 '12 at 08:11

2 Answers2

1

Well, I've just figured out the real reason in the following method:

public static AjaxBehavior createAjaxBehavior(MethodExpression expression) {
    final AjaxBehavior behavior = new AjaxBehavior();
    behavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(expression));
    return behavior;
}

In fact, the method actually returned javax.faces.component.behavior.AjaxBehavior (h:ajax?) instead of org.primefaces.component.behavior.ajax.AjaxBehavior (p:ajax) -- this happened because of quick auto-complete so I simply missed that fact.

I'm frustrated that the PrimeFaces library didn't reply any error.


Just to complete the Q & A:

  • Mojarra 2.1.7
  • PrimeFaces 3.2
Lyubomyr Shaydariv
  • 20,327
  • 12
  • 64
  • 105
-1

Should now (at least for PF 6.0) be org.primefaces.behavior.ajax.AjaxBehavior.

Lyubomyr Shaydariv
  • 20,327
  • 12
  • 64
  • 105
Marc Dzaebel
  • 425
  • 4
  • 12