开发者

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

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


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).


Okay BalusC, but I'm still having a problem with the includes and ajax. my index.xhtml includes a search.xhtml and a results.xhtml the ajax-part is in search.xhtml and the toRender-id is in results.xhtml... so at rendering the jsf-tags there's the problem that there's no toRender-Id at this time...

EDIT: Okay the problem was not the arrangement of the includes, it was that the ajax-parts must be in the same form tag like this:

<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>

search contains f:ajax tag, ajaxResult is toRenderId best regards, emre

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜