Friday, 15 June 2012

java - Migration to RichFaces 4: HtmlAjaxCommandLink -> UICommandButton -



java - Migration to RichFaces 4: HtmlAjaxCommandLink -> UICommandButton -

i convert legacy project more modern libraries version. older version used next ajax4jsf code:

htmlajaxcommandlink link = new htmlajaxcommandlink() link.addajaxlistener(new ajaxlistener() { @override public void processajax(ajaxevent event) { } });

according documentation, htmlajaxcommandlink replaced uicommandlink in richfaces 4.

though, cannot seem fine replacement addajaxlistener control.

what can replaced with?

since jsf2, ajax has been standardized jsf api. components supporting client behavior should implement clientbehaviorholder in turn offers addclientbehavior() method add together client behavior. concrete client behavior implementation ajax ajaxbehavior in turn offers addajaxbehaviorlistener() method you're looking for.

all all, in particular case, can replaced follows:

uicommandlink link = new uicommandlink(); // note: can utilize standard jsf htmlcommandlink. link.setid("linkid"); // fixed id mandatory successful processing. link.setvalue("click here"); // not sure if need it. complete. ajaxbehavior ajaxaction = new ajaxbehavior(); ajaxaction.addajaxbehaviorlistener(new ajaxbehaviorlistener() { @override public void processajaxbehavior(ajaxbehaviorevent event) throws abortprocessingexception { system.out.println("ajax behavior listener invoked."); // actual job jere. } }); link.addclientbehavior("action", ajaxaction); // note: don't utilize "click" event!

java jsf-2 richfaces ajax4jsf

No comments:

Post a Comment