• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF beginner, help with Ajax and datatable is needed

 
jeena jacob
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,
Please try to help me in resolving my issue.

I have this code working good, but it is not ajax based , please help to convert this to ajax
[code=<h:column>
<f:facet name="headers"></f:facet>
<h:commandButton value="Delete" action="#{productviewer.delete}">
<f:setPropertyActionListener target="#{productviewer.selectedProduct}" value="#{o}"></f:setPropertyActionListener>
</h:commandButton>
</h:column>][/code]

I did not see the same kind of attributes for ajax events.

how do I convert this to ajax so I can have the same functionality using ajax.

Thanks in advance.
Jeena Jacob


 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Jeena!

Actually, it's bad form to put parameters on a View Definition. Or for that matter, anything that resembles executable code. JSF is designed with the idea that the View Definition is a template and the logic - and the data - is in the backing beans. It's a lot easier to maintain and debug a JSF app when you do that.

Using AJAX isn't that hard. If you code an AJAX tag with a listener attribute, the backing bean will invoke that listener. If your desired data parameter is stored in (or injected into) the backing bean, then the listener will have its value available without having to post it out to the view and read it back in again.

In the case where the AJAX control occurs on a row in a dataTable, just wrap a DataModel around the data collection and the ajax and action listener methods can tell which row was being processed by invoking the DataModel object's getRowData() method.
 
jeena jacob
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
Thanks...
Do you have any example to play around or suggest the use of AJAX listener attribute which can take objects as arguments.
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To repeat: JSF isn't designed to have the View pass arguments. The action methods (including AJAX listeners) are expected to get their data directly from the backing bean.

An AJAX listener method takes exactly one argument, which is the JSF ajax event object. Oracle's documentation is sloppy on this point, but I'm reasonably certain that you can also code an AJAX listener to take no parameters and thus be POJO. User-defined parameters on an AJAX listener method, however are not supported.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!