I've been splitting this problem up into its core and created the following - A custom component and its controller, a page and its controller only using User object so it should be easy to get it up running:

-- Component page and its controller.

public with sharing class CTRL_dummyTest {
    public User currentUser {get; set;}
    public String message {get; set;}
    public final String uniqueID{get; set;}
    public CTRL_dummyTest(){
        message = '';
        currentUser = new User();
    public void test(){
        message = 'Method has been run in: '+uniqueID+' Contact: '+ String.valueOf(currentUser.ContactId);

    <apex:component controller="CTRL_dummyTest" >
        <apex:attribute name="idx" type="String" assignTo="{!uniqueID}" description="Unique index for this component in the page" />
        <apex:outputpanel id="MSGBLOCK">
        <apex:form >
            <apex:actionFunction action="{!test}" name="newUser{!idx}" rerender="MSGBLOCK"/>

            <apex:inputField value="{!currentUser.ContactId}" onchange="newUser{!idx}();"/>

            <apex:commandButton action="{!test}" rerender="MSGBLOCK" value="herrow"/>

-- Main page that include the component and its controller:

public with sharing class ctrl_dummyTestPage {
    public integer times { get; set; }
    public List<String> strings {get; set;}
    public ctrl_dummyTestPage(){
        times = 10;
        strings = new List<String>();
        for(integer p = 0; p<times; p++){

<apex:page controller="ctrl_dummyTestPage">
    <c:DummyTest idx="100"/>
    <c:DummyTest idx="101"/>
    <apex:repeat value="{!strings}" var="string" id="theRepeat">
        <c:DummyTest idx="{!string}"/>

The first two components i.e. dummyTest idx=100, amd dummyTest idx=101 and they show the following message in the outputpanel "MSGBLOCK":

Method has been run in: 100 Contact: 003b000000MPU3lAAH Method has been run in: 101 Contact: 003b0000008WBvnAAG

that means they seams to work.

Inside the apex:reapeat each of the custom components outputpanels "MSGBLOCK": Method has been run in: 0 Contact: null Method has been run in: 1 Contact: null Method has been run in: 2 Contact: null

Does anyone know a work around for this?


Okay I'm sure that the problem lays within the apex:repeat since the following and works:

<c:DummyTest idx="100"/>
<c:DummyTest idx="101"/>
<apex:outputpanel rendered="{!strings.size > 0}">
   <c:DummyTest idx="{!string[0]}"/>
<apex:outputpanel rendered="{!strings.size > 1}">
   <c:DummyTest idx="{!string[1]}"/>
<apex:outputpanel rendered="{!strings.size > 2}">
   <c:DummyTest idx="{!string[2]}"/>

I want to be able to control the number of dummypanels dynamically i.e. the number of dummypanels should be equals to the size of the array "strings"....

Does anyone know any workaround for this??

  • Is there a lookup to Contact on your CustomObject? It looks like you are trying to access the field incorrectly. have your tried using myCustomObject.Contact__c as opposed to myCustomObject[Contact__c]? – Chris Duncombe Feb 20 '14 at 10:48
  • Yeah there is a lookup relationship to the contact. I'm also getting the lookup dialog and it's possible to fill in the myCustomObject['Contact__c']. I've also done the same thing but with a String that beeing set inside the custom controler. Get the same result the value for the string is null. – Sigge Feb 20 '14 at 11:01
  • I tried with a String instead of a Contact, but it didn't really work until i did the following: <input id="theTextInput{!uniqueID}" type="text" value="{!temporary}" name="theTextInput" onchange="newUser{!uniqueID}(document.getElementById('theTextInput{!uniqueID}').value);"></input> This works, but I want to be able to use apex:inputField and not input + js..... – Sigge Feb 20 '14 at 13:04
  • I'm running into something similar. I have an apex:repeat inside an outputpanel. Inside the repeat there is a commandlink with an action and a rerender. If I enter data in other fields inside the repeat and press the button with the actionlink and rerender the outputpanel, the values are empty again. However, I do see the values being posted but they are not returned in the ajax-call – Marcel Meijer Jul 26 '17 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.