views:

151

answers:

4

Hi guys,

I have implemented a list created by a repeater:

<ui:repeat value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>

and a Button that filters my list:

<h:commandLink action="#{overviewController.filterNew}">
<h:outputText value="Filter List" />
</h:commandLink>

So, is there an easy way to render only my repeater after clicking the command link (with AJAX) :-)


I tried following:

<f:ajax render="repeater">
ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>
<f:ajax />


<h:commandLink action="#{overviewController.filterNew}">
<h:outputText value="Filter List" />
<f:ajax event="click" render="repeater"/>
</h:commandLink>

but that did not work..


Update

<h:form>
ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>

<h:commandLink action="#{overviewController.filterNew}">
<h:outputText value="Filter List" />
<f:ajax event="click" render="repeater"/>
</h:commandLink>
</h:form>

doesn't work either... Maybe I hav to put the action method (overviewController.filterNew) into the ajax tag?


Update 2

    <f:ajax event="click" render="repeater">
    <h:commandLink action="#{overviewController.filterEBus}">
    <h:outputText value="EBusiness" />
    </h:commandLink>
    </f:ajax>

Doesn't work either!


Maybe it's not possible to rerender a repeater ? is there another element like a div tag or something that can be rerendered???

...

Thank you for your help

+3  A: 

Yes:

Bozho
nice explanation.
org.life.java
thank's but doesn't work :-/
Sven
+1  A: 
<f:ajax render="repeater">
ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>
<f:ajax />

why did you wrap it with f:ajax? It's redundant in this case.

Make sure that your components are surrounded by <h:form> tag

<h:form>
<ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>

<h:commandLink action="#{overviewController.filterNew}">
<h:outputText value="Filter List" />
<f:ajax event="click" render="repeater"/>
</h:commandLink>
</h:form>
Odelya
That's what I tried as well. And I surrounded the whole part with h:form tags :-( It just dies nothing -.-
Sven
+2  A: 

Put it in a <h:panelGroup> with an id.

<h:form>
    <h:commandLink action="#{overviewController.filterNew}">
        <h:outputText value="Filter List" />
        <f:ajax execute="@form" render="projects" />
    </h:commandLink>
</h:form>
<h:panelGroup id="projects">
    <ui:repeat value="#{projectData.paginator.list}" var="project">
        <h:outputText value="#{project.title}" />
    </ui:repeat>
</h:panelGroup>
BalusC
BalusC for president!
Sven
When are the elections?
BalusC
A: 

How about this:

<ui:repeat id="repeater" value="#{projectData.paginator.list}" var="project">
  <h:outputText value="#{project.title}" />
</ui:repeat>

<h:commandLink>
  <h:outputText value="Filter List" />
  <f:ajax render="repeater" listener="#{overviewController.filterNew}" />
</h:commandLink>
amorfis
`ui:repeat` doesn't support the `id` attribute. Which makes sense since it doesn't represent anything, it's just a flow control tag.
BalusC
Ok, so he'll need to wrap it in <h:panelGroup>
amorfis