Results 1 to 2 of 2
- 06-19-2011, 04:26 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 1
- Rep Power
- 0
How to add ajax behavior to dynamically created component?
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:
<h:commandButton id="buttonId" action="#{backingBean.buttonAction}" value="Push Me" >
<f:ajax render="componentName" />
</h:commandButton>
To create something similar in a backing bean I use the following code in my backing bean:
button = new HtmlCommandButton();
button.setId( "buttonId" );
button.setType( "submit" );
button.setTitle( "Push this button to....");
button.setValue( "Push Me" );
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.
- 05-31-2012, 07:02 AM #2
Member
- Join Date
- Mar 2012
- Posts
- 41
- Rep Power
- 0
Re: How to add ajax behavior to dynamically created component?
Your better learning one of the newer JSF or faces or struts frameworks that integrate AJAX, but,
In the above code you need to assign an id= to your button with the java code the way you did above(there is a method for that in the API).
Assuming here you know DHTML and DOM level 3 DHTML-javascript, you simply get the id="formname:button1" from your JSF page and perhaps an AJAX framework .js script integrated to the page and assign whatever characteristics required onto the button by its output html id with the appropriate AJAX framework method.
Similar Threads
-
dynamically populate the city combo box based on the values of state combo +ajax+jsp
By sandy1000 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-29-2010, 10:00 AM -
How to resize the component dynamically??
By Y. Progammer in forum New To JavaReplies: 14Last Post: 03-17-2010, 05:04 PM -
How can i execute one java file(dynamically created) from the other
By Rak239 in forum New To JavaReplies: 1Last Post: 11-03-2009, 07:07 AM -
How to create ActionListners for dynamically created MenuItem?
By anilshelar in forum AWT / SwingReplies: 3Last Post: 10-27-2009, 02:19 PM -
[SOLVED] Can variable names be dynamically created?
By CJSLMAN in forum New To JavaReplies: 4Last Post: 01-03-2009, 01:06 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks