java - JSF / RichFaces - How to call programatically an ActionEvent from HtmlAjaxSupport (a4j:support) -
i'm doing this
htmlajaxsupport.setactionexpression(createmethodexpression( "#{questionariomb.visualizarquestoesfilhos}", null, new class[0]));
the method
public void visualizarquestoesfilhos()
is called.
but want call
public void visualizarquestoesfilhos(actionevent event)
because way, can component being clicked.
what need set in htmlajaxsupport work?
create actionlistener expression in jsf 1.2 or newer:
facescontext context = facescontext.getcurrentinstance(); methodexpression actionlistener = context.getapplication().getexpressionfactory() .createmethodexpression(context.getelcontext(), "#{bean.actionlistener}", null, new class[] {actionevent.class}); uicommandcomponent.addactionlistener(new methodexpressionactionlistener(actionlistener));
to avoid lot of boilerplate code, can wrap nicely in helper methods (if necessary in helper/utility class), e.g.:
public static methodexpression createaction(string actionexpression, class<?> returntype) { facescontext context = facescontext.getcurrentinstance(); return context.getapplication().getexpressionfactory() .createmethodexpression(context.getelcontext(), actionexpression, returntype, new class[0]); } public static methodexpressionactionlistener createactionlistener(string actionlistenerexpression) { facescontext context = facescontext.getcurrentinstance(); return new methodexpressionactionlistener(context.getapplication().getexpressionfactory() .createmethodexpression(context.getelcontext(), actionlistenerexpression, null, new class[] {actionevent.class})); }
get snippet stackoverthread adrian provided:
deprecated richfaces javax.faces.el.methodbinding replacement use
Comments
Post a Comment