Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integrating AJAX and JSF

 
Kevin Weisser
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've seen a few examples out showing how to either integrate AJAX using a PhaseListener approach, and also how to integrate AJAX using IBM/JSF implementation that allows you specify panels to be updatable via AJAX.

The example I'm trying to work through is where a user enters some key piece of information into a form, and that data is then used to query the database and populate other fields on the form.

The PhaseListener approach doesn't seem to make easy use of the Java bean, and it's functionality. However, it does give the user a single point of entry to get all of the data and return it as a JSON object at which point the HTML can be updated.

The second approach doesn't seem doesn't seem to allow the individual components on the form to be tied to the Java bean, because any values which may be prepopulated have to be individual function calls. This would be a ton of overhead if you had to make 10 calls to get the values for 10 compenents. However this approach does keep everything within JSF, and allows for minimal java scripting.

Does anyone have any additional suggestions/recommendations on performing an autofill type feature within JSF?

Regards,

Kevin
 
James McCluskey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried Ajax4JSF? I'm not sure if it will meet your requirements exactly, but it enables you to make an Ajax call from a standard JSF component, and you simply identify the component to rerender when the response is received. Trivial access to the bean data therefore.

I hate anything in JSF where I have to pull apart the lifecycle and apply phase listeners.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic