I have a repeat block that loops over a List<String> and outputs them to an HTML table.
Underneath that is the actionFunction declaration followed by an HTML button which when clicked calls the actionFunction.
The controller function simply concats to the end of a public string property which I then debug out.
When I first click the button the output is "set in constr; testParamVal;" which is expected however when I click the button the second time the output is the same where as I was expecting "set in constr; testParamVal; testParamVal;".
Upon lots of trial and error I found that if I removed the HTML table tags from around the repeat block this worked as expected.
Is this a bug or am I missing something?? Thanks!
Working
VF Page:
<apex:page controller="TestPage2_Ctrl">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="actionFunction Test" columns="1" id="testPBS">
<!-- <table> -->
<apex:repeat value="{!TestList}" var="strVal">
<!-- <tr>
<td>{!strVal}</td>
</tr> -->
{!strVal}
</apex:repeat>
<!-- </table> -->
<apex:actionFunction name="testPostback" action="{!TestPostback}" rerender="testPBS" />
<button type="submit" onclick="testPostback(); return false;">
Test postback
</button>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class TestPage2_Ctrl {
public String TestVal {get; set;}
public List<String> TestList {get; set;}
public TestPage2_Ctrl() {
TestList = new List<String>();
TestList.add('testVal 1');
TestList.add('testVal 2');
TestList.add('testVal 3');
TestVal = 'set in constr; ';
}
public void TestPostback() {
TestVal += 'testParamVal; ';
system.debug('TestVal post add: ' + TestVal); // expect "set in constr; testParamVal; testParamVal;" on second button click
}
}
Not Working
VF Page:
<apex:page controller="TestPage2_Ctrl">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="actionFunction Test" columns="1" id="testPBS">
<table>
<apex:repeat value="{!TestList}" var="strVal">
<tr>
<td>{!strVal}</td>
</tr>
{!strVal}
</apex:repeat>
</table>
<apex:actionFunction name="testPostback" action="{!TestPostback}" rerender="testPBS" />
<button type="submit" onclick="testPostback(); return false;">
Test postback
</button>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
Same as above
EDIT
VF API version is 28.0 Apex API version is also 28.0. On a Winter 15 dev sandbox