• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add ajax behavior to synamically created component?

 
Burferd Grabarkowitz
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using JSF 2.0.

I have a need to generate components in my backing beans and have them displayed on the page when rendered.
Creating the component is not an issue, I can do that with the code listed below.
However I want to add ajax functionality and I do not know how to do that in the backing bean.

A simple example of an ajax enabled component on an xhtml page would be something like:



To create something similar in a backing bean I use the following code in my backing bean:



I then add this as a child of a component on the page.

What I don't know how do do is add the ajax behavior to this compponent.

Does anyone know how to do this?

Thanks.



 
Tim Holloway
Bartender
Posts: 18414
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your HtmCommandButton class should include attributes for each of the JavaScript properties that the control supports. So you'd have to attach the javaScript to the appropriate attribute (for example, "onclick", using button.setOnclick()).

The tricky part is that I believe that the actual value passed to that method has to be an EL expression object - you can't just attach the raw JavaScript text directly.
 
Burferd Grabarkowitz
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question still remains, how can that be done.
Could anyone give an example?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!