1 Reply Latest reply on Mar 26, 2007 5:45 PM by Sergey Smirnov

    Updating a single row in a repeat?

    Dustin Norlander Apprentice


      I have been trying to figure out how to do this for ages and I haven't com up with an appropriate way.

      Say I want to iterate over a list of emails using a:repeat. I want to have an action outside the a:repeat section that will update a single row. Now, if jsf allowed dynamic ids it would be easy just have id="#{email.id}" and have reRender="#{email.id}" in my action (I think it's unbelievable stupid that jsf does not allow dynamic ids). But since that is not possible how can I accomplish this?

      thanks for any suggestions,

        • 1. Re: Updating a single row in a repeat?
          Sergey Smirnov Master

          Yes, you cannot use #{} EL for id. Just forget about it.

          What might be the way to go:

          a:repeat has two useful attribute: rowKey and ajaxKeys. The first one, by default if you do not override it in data model, equals to number of row (Integer type).

          ajaxKeys is a Set (java.util.Set) of rows that should be re-rendered. If ajaxKeys attribute equals null, just the whole table is re-rendered.

          However, you can define it and only the referenced row will be updated.


          <h:form id="myform">
           <a:repeat id="accounts" var="account" ajaxKeys="#{accoundBean.rowsToUpdate}">
           <h:outputText id="email" value="#{account.email}" />
           <a:commandButton action="#{accountBean.update}" reRender="accounts:email" />

          If getRowsToUpdate returns null, the whole table will be re-rendered. However, if you specify the Set in the accountBean.update method, for example, only the specified row(s) will be re-rendered