JSF 2 AJAX - reload the entire div (for example, <ui: include src = "toReloadData.xhtml" / ">)
I am working with jsf2 and want to use ajax functionality. Problem: I have already seen some ajax updates. But nothing to update the whole div ...
I have an xhtml page with data from my bean, and I really do not want to update all its fields, it would be easier to update the whole ui: include ...
Does anyone know a solution? Or do I need to update all fields manually?
Best wishes
Just put them in some container component with identifier and use it in the render attribute f:ajax .
<h:form> <h:commandButton value="submit" action="#{bean.submit}"> <f:ajax render=":foo" /> </h:commandButton> </h:form> <h:panelGroup id="foo" layout="block"> <ui:include src="include.xhtml" /> </h:panelGroup> Note that <h:panelGroup layout="block"> displays a <div> . If you omit the layout attribute, it defaults to <span> (only if there are any attributes that need to be displayed in HTML, such as id ).
Ok, BalusC, but I still have a problem with inclusions and ajax. my index.xhtml includes search.xhtml and result.xhtml ajax-part is in the search.xhtml file, and the toRender identifier is in results.xhtml ... so when rendering jsf tags there is a problem that there is no toRender-Id in this time...
EDIT: Okay, the problem was not in the inclusion of inclusions, but that the ajax elements should be in the tag of the same form:
<h:form> <div id="search" class="search"> <ui:insert name="search" > <ui:include src="search.xhtml" /> </ui:insert> </div> <h:panelGroup id="ajaxResult" layout="block"> <ui:insert name="searchResults" > <ui:include src="searchResults.xhtml" /> </ui:insert> </h:panelGroup> </h:form> the search contains f: ajax tag, ajaxResult - toRenderId best regards, emre