HtmlAjaxFunction data
lectrix Mar 12, 2008 9:02 AMHello
i am trying to create a jsf component which uses HtmlAjaxFunction as a child component.
I tested my component and it works if i put the <a4j:jsFunction/> in the JSF.
<a:jsFunction name="jsTestAction" action="#{TeamWerkstattTextsJsfBean.loadTextList}" data="#{TeamWerkstattTextsJsfBean.listXml}" oncomplete="fillGrid(data)"> </a:jsFunction>
The above jsFunction works this way:
1) on window load jsTestAction is called
2) loadTextList loads some xml data into listXml
3) oncomplete the js function fillGrid(data) is called and i do get the content of listXml into data
now i want to put this into my Component Renderer. I tried this:
... HtmlAjaxFunction myFunction = new HtmlAjaxFunction(); ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory(); ELContext elCtx = context.getELContext(); MethodExpression actionExpression = expressionFactory.createMethodExpression(elCtx, "#{TeamWerkstattTextsJsfBean.loadTextList}", null, new Class[]{}); ValueExpression dataExpression = expressionFactory.createValueExpression(elCtx, "#{TeamWerkstattTextsJsfBean.listXml}", String.class); myFunction.setName("jsDhtmlxLoadListXml"); myFunction.setActionExpression(actionExpression); myFunction.setOncomplete("fillGrid(data)"); myFunction.setParent(component.getParent()); myFunction.setData(dataExpression); myFunction.encodeBegin(context); myFunction.encodeEnd(context); writer.startElement("script", null); writer.writeText("window.addEventListener('load',function(evt){alert('onload calling...'); jsDhtmlxLoadListXml();},false);",null); writer.endElement("script"); ...
... but i do not get data in my fillGrid js function any more.
i also tried
myFunction.setData("#{TeamWerkstattTextsJsfBean.listXml}");
that didnt work either.
So my question is, how to create the <a4j:jsFunction> written above programatically in my Renderer, in particular with data attribute set?
I am using latest snapshot: richfaces-ui-3.2.0-20080312.044927-95
thanks a lot for helping!
stefan.
ps: btw, greate piece of software! thanks!