Migrating JSF 1.1 with Ajax4jsf 1.x to JSF 2

末鹿安然 提交于 2019-11-27 14:51:09
BalusC

Get rid of Ajax4jsf 1.x altogether. It's indeed not compatible with JSF2. Instead, JSF2 offers a new main ajax tag <f:ajax> which covers all the core functionality as previously offered by Ajax4jsf 1.x.

If upgrading to RichFaces 4 is not an option (because, as you said yourself, you aren't using RichFaces components anywhere), then just remove Ajax4jsf 1.x and replace all <a4j:xxx> tags by standard JSF2 equivalents.

  • <a4j:ajaxListener>: use <f:ajax listener>.
  • <a4j:keepAlive>: just put managed bean in the view scope by @ViewScoped.
  • <a4j:log>: use jsf.ajax.addOnEvent() or jsf.ajax.addOnError() in JS context.
  • <a4j:commandLink>: just nest <f:ajax> inside <h:commandLink>.
  • <a4j:outputPanel>: use <h:panelGroup> and remember to include its ID in <f:ajax render> or PrimeFaces <p:outputPanel>.
  • <a4j:repeat>: just use standard <ui:repeat>.
  • <a4j:form>: just use <h:form>, it will autorecognize <f:ajax>.
  • <a4j:htmlCommandLink>: just nest <f:ajax> inside <h:commandLink>.
  • <a4j:jsFunction>: no replacement. Consider OmniFaces <o:commandScript> or PrimeFaces <p:remoteCommand>.
  • <a4j:region>: just use <f:ajax execute>, you can even wrap <f:ajax> around a group of components.
  • <a4j:loadBundle>: just use standard <f:loadBundle>.
  • <a4j:status>: use jsf.ajax.addOnEvent() or jsf.ajax.addOnError() in JS context.
  • <a4j:actionparam>: just use standard <f:param>.
  • <a4j:loadScript>: just use standard <h:outputScript>.
  • <a4j:mediaOutput>: no replacement. Consider PrimeFaces <p:media>.
  • <a4j:poll>: no replacement. Consider OmniFaces <o:commandScript> or PrimeFaces <p:poll>.
  • <a4j:commandButton>: just nest <f:ajax> inside <h:commandButton>.
  • <a4j:include>: just use standard <ui:include>.
  • <a4j:loadStyle>: just use standard <h:outputStylesheet>.
  • <a4j:support>: just use standard <f:ajax>.

You also need to rename/rewrite JSP files to Facelets files. In simple cases, this is usually just a matter of changing root declarations and file extensions. Facelets makes it easier to replace all duplicated code by a single template. The following answer applies:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!