How to use Ajax with JSF 2.0?

你离开我真会死。 提交于 2019-12-18 09:45:08

问题


I want to implement Ajax on my JSF web project. I googled and found that ICEFaces is supporting Ajax with JSF. Yet I dont know the usability of it.

Any one has experience Ajax/JSF, please guide me where to move.

[EDIT]

If any one has experienced on similar, please share the usability as well. the good and bad..


回答1:


JSF 2.0 has built-in support for Ajax using the f:ajax tag. All three of ICEFaces, OpenFaces, and RichFaces also have Ajax-enabled components but with JSF 2.0 it is now possible to add Ajax to your apps without using third-party libraries. IBM has a series of nice tutorials in this regards: http://www.ibm.com/developerworks/views/java/libraryview.jsp?search_by=JSF+2+fu




回答2:


I'd like to suggest - Pro JSF and Ajax: Building Rich Internet Components




回答3:


JSF 2.0 has built in basic AJAX functionality through the f:ajax tag.

David Geary shows how in part 3 of his jsf-fu articles. http://www.ibm.com/developerworks/java/library/j-jsf2fu3/index.html




回答4:


It is quite simple and elegant to use Ajax in JSF but you should not abuse because of debugging constraints.

HTML page Fragment :

 <h:commandLink  value="tab 1">
    <f:param name="tabIndex" value="1" />
    <f:ajax event="click" render=":contentForm" listener="#{tabBB.handleTabChange}"/>
 </h:commandLink>

Backing bean fragment :

public boolean handleTabChange() {
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    String index = externalContext.getRequestParameterMap().get("tabIndex");
    setTabIndex(Integer.parseInt(index));
    return true;
}


来源:https://stackoverflow.com/questions/3138488/how-to-use-ajax-with-jsf-2-0

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