Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF 2 AJAX - reload whole div (e.g. <ui:include src="toReloadData.xhtml" />)

Tags:

jsf

jsf-2

I'm working with jsf2 and want to use the ajax-functionality of it. Problem: I've already seen some ajax refresh things. But nothing to refresh a whole div...

I have a xhtml page with data from my bean, and i don't really want to refresh all fields of it, it would be easier to refresh the whole ui:include...

does anybody knows a solution? Or do I have to refresh all fields manually?

best regards

like image 608
eav Avatar asked Dec 29 '10 16:12

eav


1 Answers

Just put them in some container component with an ID and use it in render attribute of 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"> renders a <div>. If you omit the layout attribute, it defaults to <span> (only whenever there are any attributes which needs to be rendered to HTML, like id).

like image 158
BalusC Avatar answered Oct 10 '22 22:10

BalusC