-
1. How to progrmmatically add ajax support to a UIComponent
nbelaevski Apr 12, 2011 8:34 AM (in response to ujjets)1 of 1 people found this helpfulHi,
Check the Facelet handler code for examples: org.ajax4jsf.taglib.html.facelets.AjaxSupportHandler
-
2. How to progrmmatically add ajax support to a UIComponent
ujjets Apr 12, 2011 11:32 AM (in response to nbelaevski)Hi Nick,
Thanks for your response.
I did try looking up the api related to org.ajax4jsf.taglib.html.jsp but was unable to get ideas upt now so I am still looking.
I am kind of new to this.I found a link http://community.jboss.org/message/558921 that has given me some guidance.
If possible please point me to some code samples.
Thanks again.
-
3. How to progrmmatically add ajax support to a UIComponent
ilya_shaikovsky Apr 13, 2011 6:01 AM (in response to ujjets)1 of 1 people found this helpfulprivate UIPanel panel = null;
public void setPanel(UIPanel panel) {
this.panel = panel;
}
public UIPanel getPanel() {
return panel;
}
public void createPanel() {
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
UIInput input = (UIInput)app.createComponent("javax.faces.Input");
input.setId("input");
UIAjaxSupport ajaxSupport = (UIAjaxSupport)app.createComponent("org.ajax4jsf.Support");
ajaxSupport.setEvent("onkeyup");
input.getFacets().put("ajaxSupport", ajaxSupport);
panel.getChildren().add(input);
}
and
<h:form id="myform">
<h:panelGrid columns="2" id="grid">
<rich:panel binding="#{userBean.panel}"/>
</h:panelGrid>
<a4j:commandButton ajaxSingle="true" action="#{userBean.createPanel}" reRender="grid" value="Add Input"></a4j:commandButton>
</h:form>
works fine for me.
-
4. How to progrmmatically add ajax support to a UIComponent
ujjets Apr 13, 2011 10:07 AM (in response to ilya_shaikovsky)Hi Ilya,
Thank you very much for your inputs.I will try it and update the thread.
-
5. How to progrmmatically add ajax support to a UIComponent
ujjets Apr 13, 2011 6:11 PM (in response to ujjets)Hi Ilya,
I tried your code and it works.
*******************************************
public static UIComponent createUIAjaxSupport(String event,String action,String reRender){
UIAjaxSupport ajaxSupport = (UIAjaxSupport)getApplication().createComponent(UIAjaxSupport.COMPONENT_TYPE);
ajaxSupport.setEvent(event);
MethodExpression methodExpression =
getApplication().getExpressionFactory().createMethodExpression(getELContext(),
action,
null,
new Class[] { ActionEvent.class });
ajaxSupport.setActionExpression(methodExpression);
if (StringUtils.isNotEmpty(reRender)){
ajaxSupport.setReRender(reRender);
}
return ajaxSupport;
}
then
htmlInputText.getFacets().put("ajaxSupport", createUIAjaxSupport("onkeyup","#{bean.someMethod}",null));
*******************************************
Once again thanks for your valuable answer and hoping this will help others.
Regards,
Ujjwal