开发者

how to rerender a dynamic id (nested within datalist) in jsf/a4j?

Using jsf 1.1.11/richfaces 3.1.5 and have a facelet with multiple tables (lists driving tables are all stored in 开发者_Go百科a map) on one page, each with their own sorting/pagination which fire off ajax requests on user clicks. Bean is request-scoped. Page structure is of form:

<h:panelGroup id="allResults">
    <t:dataList id="keysItr" var="groupType" value="#{bean.tableKeys}">
        <t:dataList id="group" var="result" value="#{bean.groupResults[groupType].results}">
        ...table logic with sorting a4j commands
        </t:dataList>
        <h:panelGroup id="paginator">
        ... paginator logic from {bean.groupResults[groupType].paginator} with a4j commands
        </h:panelGroup>
    </t:dataList>
</h:panelGroup>

So if I execute any of those a4j commands and rerender allResults, it will work for that particular table, but then of course will also reset the paginator/sort behavior for all the other ones (back to their defaults of page 1, unsorted) - I want to just rerender the specific table affected by the user click, but the table paginator and dataList ids are dynamic since they are nested within the keysItr dataList.

I wrote some javascript along with a4j:jsfunction that will grab all the dynamically generated keys of the tables/paginators on page load (since they are just of the form _container1:_containerN:rowIndexVar:id so easy to do a search for them) and throw it into a session-bean and tried putting those id values in the reRender attribute of the a4j actions but nothing fires so do not think a4j allows ids fully-qualified with the naming_containers and everything on reRender attribute?

Anyways, just wondering if maybe then there would be some way to force a rerender of the particular table/paginator in the backing bean if I already know the id's and can grab the component I want. I have some code I've used before that will iterate through the child components recursively from facescontext viewRoot to get the actual UIComponent referred to by the id, but then don't know what to do next in order for a rerender to happen. Any thoughts or other approaches I could take to get this to work? Thanks.


The component 's dynamic ID generated by richfaces can be accessd by the #{rich:clientId('id')} .

For example , suppose you have

<h:form id="form">
   < rich:dataTable id="table" > 
      ..............
   </rich:dataTable>
</h:form>

You can use #{rich:clientId('table')} in the JSF page to access the dynamic ID of the table , which will get form:table in this example.

Then , you can reRender this table in your a4j:command:

<a4j:commandButton .... reRender="#{rich:clientId('table')}"/>

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜