+ Start a Discussion

Loop in a template + rerender -> repeat or dataTable tag disappears




We encountered a weird problem which seems to be a really specific bug.
Here is the situation:
We use a template with a repeat tag that repeats only once (the list has only one element for the test) the body attribute:

<apex:page showHeader="false" controller="testController2">

<apex:repeat value="{!listTest}" var="te">

<apex:insert name="body" />




Here is the controller:
public with sharing class testController2 {   public List<String> listTest{ get; set; }    public testController2 (){       listTest= new List<String>();        listTest.add('1');    }}
Then in a VF page using this template we try to rerender a list. The direct display of the list works but not on a table or repeat tag. It "disappears".
Here is the page:

<apex:page showHeader="false" controller="testController"> <apex:composition template="CSTemplate"> <apex:define name="body"> <apex:form > <apex:commandButton value="test" action="{!changeValue}" rerender="dataBlock" status="status"/> <apex:outputPanel layout="block" id="dataBlock" styleClass="block"> <h2>Test</h2> <apex:actionStatus id="status" StyleClass="status" startText="working..."/> test: {!myValue} <apex:dataTable value="{!myValue}" var="data"> <apex:column > {!data} - </apex:column> </apex:dataTable> </apex:outputPanel> </apex:form> </apex:define> </apex:composition></apex:page>


And the controller:
public with sharing class testController {    public testController (){        myValue = new List<String>();        myValue.add('1');    }    public PageReference changeValue() {        myValue.add('2');        return null;    }    public List<String> myValue { get; set; }}
Some precisions:
- The display of the dataTable wihtout rerender works fine, it is after a rerender that the display disappear
- the rerender by itself works as we can see the values inside the List being updated 
- the problem doesn't occur if we don't use a loop in the template definition
- the problem doesn't occur if both the template and the page use the same Controller (this one is really weird)
To sum up:
If you use a loop in a template, the rerender of a repeat or a dataTable in a page that uses this template won't work (the list "disappears")


Message Edited by LaurentDelc on 09-08-2009 08:17 AM