This is a short example of using richfaces jsFunction with parameter.
<r:jsFunction name="addTag" action="#{bean.method}">
<r:param name="param" assignTo="#{bean.tagId}"/>
</r:jsFunction>
then you can use from javascript addTag('1') and the parameter will be stored to the bean.
I need to accomplish the same functionality creating the jsFunction and ading parameter programmatically. This is the code that I use but not works:
UIAjaxFunction jsFunctionAddTag = new UIAjaxFunction();
jsFunctionAddTag.setName("addTag");
FacesContext fc = FacesContext.getCurrentInstance();
ExpressionFactory ef = fc.getApplication().getExpressionFactory();
MethodExpression me = ef.createMethodExpression(fc.getELContext(), "#{bean.method}",
null, new Class[]{});
jsFunctionAddTag.setActionExpression(me);
UIParameter param = new UIParameter();
param.setName("param");
param.setAssignToExpression(ef.createValueExpression(fc.getELContext(),
"#{bean.tagId}", String.class));
jsFunctionAddTag.getChildren().add(param);
When the method is executed the value of tagId is not setted. What I'm doing wrong?