3

I am creating a table component using JSF and html table (no other faces table involved), so collection is taken as parameter and it iterates and display the table contents.

I have a "Remove" link on click of which it should remove the items and it's working fine. My problem now is after the item is removed I need to self-refresh the table component.

It worked when I used @form in the render. But that would be an issue when integrating the component with any page. Anyone has ideas to self-refresh the table component on click of the "Remove" link? Please provide your thoughts.

      <a4j:commandLink id="removeSelection" actionListener="#{cc.attrs.rowRemoveEventListener}" render="@form #{cc.attrs.renderOnRemove}" styleClass="st-remove-link" onclick="">
        <f:param name="rowKey" value="#{rowKey}"/>
        <span class="link-text">Remove</span>
        <a4j:ajax event="click" render="#{cc.clientId}" />
      </a4j:commandLink> 

The full component markup:

    <div id="#{cc.clientId}">
      <--stylesheet link here-->
      <h:panelGroup id="simpletablepanel" layout="block">
        <a4j:outputPanel id="simpletablebody" layout="block">
        <table>
          <tr>
            <td>
               <span>value</span>
            </td>
            <td>
              <a4j:commandLink id="removeSelection"
                actionListener="#{cc.attrs.rowRemoveEventListener}"
                render=":#{cc.clientId} #{cc.attrs.renderOnRemove}">
                  <f:param name="rowKey" value="#{rowKey}"/>
                  <span>Remove</span>
              </a4j:commandLink>
            </td>
          </tr>
        </tbody>
      </ui:fragment>
    </table>
  </a4j:outputPanel>
</div>
maple_shaft
  • 10,435
  • 6
  • 46
  • 74
Murali Murugesan
  • 105
  • 1
  • 11
  • 1
    Have you wrapped your component in a `
    ` already? (See [this](http://stackoverflow.com/questions/13313207/referring-to-a-composite-component-from-a-using-page-fails))
    – Elias Dorneles Jan 17 '13 at 12:13
  • yes tried that. It just refreshes the form but not the component itself. I removed and passed #{cc.clientId} in render of . Still nothing worked. – Murali Murugesan Jan 17 '13 at 12:18
  • Can you post the full component code? – Elias Dorneles Jan 17 '13 at 12:20
  • 1
    You are prepending the clientId with `:` in the render attribute, this qualifies it an absolute component path, not what you want. Use just `render="#{cc.clientId}"` instead. – Elias Dorneles Jan 17 '13 at 12:31
  • sorry that was a try with hard coded Id , I removed it and tried but still same result – Murali Murugesan Jan 17 '13 at 12:45
  • even tried execute="#{cc.clientId}" still no change – Murali Murugesan Jan 17 '13 at 12:46
  • hmm... I had some problems previously using these Richfaces tags. Could you try using the plain JSF ones? Try changing your `a4j:commandLink` to: ` `, let's see what happens? – Elias Dorneles Jan 17 '13 at 12:52
  • btw, what do you have in the `rowRemoveEventListener` method? – Elias Dorneles Jan 17 '13 at 12:53
  • ok i will give it a try. rowRemoveEventListener is a callback method. That gets triggered perfectly. – Murali Murugesan Jan 17 '13 at 13:04
  • You should re-render the panel that encloses the table, causing the table to rebuild. One possible approach when using vanilla html tables is to handle your `` elements to show the records. The backing bean should contain a list of the records that you can iterate through with, for example, `` and in the end, each delete link should trigger a table update by re-rendering the container panel. – Fritz Jan 17 '13 at 13:58
  • Thanks to you all, especially elias. Issue resolved. – Murali Murugesan Jan 18 '13 at 02:16
  • The rendering using render=":#{cc.clientId} #cc.attrs.renderOnRemove}" was creating the problem. #{cc.clientId} was refreshing correctly but the next id that is passed was wrong and it was blocking the complete reRender. Correcting that id and wrapping the component with
    and adding execute="#{cc.clientId}" to the commanLink fixed the issue.
    – Murali Murugesan Jan 18 '13 at 02:28

1 Answers1

0

just check the below link, i hope you will found something..

In JSF 2 - Trying to rerender a panelgroup that is between 2 ui:repeats

Community
  • 1
  • 1
Jimit Tank
  • 1,479
  • 5
  • 19
  • 25