+ Start a Discussion
Aiden ByrneAiden Byrne 

Broken Visualforce binding in Summer 11

We use Visualforce binding to display results from different object queries based on user selection. An admin can dynamically define the query we run so Visualforce binding is perfect for this.

 

Our code has broke in Summer 11. We get errors whenever results for a different object are retrieved. The new field change does not appear to be respected by Visual Force.

 

I was able to write the following test code to illustrate. When you run you will see 10 accounts in your org. Now change the dropdown to contacts, and you see a binding error.  It looks like Visualforce isn’t refreshing the QueryViewDisplayFields as expected. As mentioned, this functionality worked before but is broken in the Summer release.  If you change the selected option to ‘Contacts’ in the constructor, you’ll see that the contacts display fine. Now if the user changes the options to accounts the binding breaks.

 

<apex:page controller="BindingTest">
<apex:form >

<apex:outputLabel dir="" value="Showing: " />
                &nbsp;&nbsp;&nbsp;
<apex:selectList multiselect="false" value="{!SelectedOption}" size="1">    
        <apex:selectOptions value="{!OptionsList}" id="recordOptions" />
        <apex:actionSupport event="onchange" status="counterStatus"
            oncomplete="ReadData();" rerender="none"  />                
</apex:selectList>

<apex:actionFunction name="ReadData"
    action="{!ReadData}" rerender="SearchResults" />

<apex:pageBlock id="SearchResults" >
     
        <apex:pageblocktable value="{!QueryViewRecords}" var="viewRow">

        <apex:repeat value="{!QueryViewDisplayFields}" var="myfield" id="innerset">
        <apex:column value="{!viewRow[myfield]}" />
        </apex:repeat>
                                        
        </apex:pageblocktable>                

</apex:pageBlock>

</apex:form>
</apex:page>

 

 

public with sharing class BindingTest
{
    public String SelectedOption {get; set;}

    public List<SelectOption> OptionsList {get; set;}
    public List<SObject> QueryViewRecords {get; set;}
    
    public List<String> QueryViewDisplayFields
    {
        get
        {
            List<String> returnResults = new List<String>();    
            
            if( SelectedOption == 'Accounts' )
            {            
                returnResults.add('name');
                returnResults.add('phone');
                returnResults.add('annualrevenue');
            }
            else
            {            
                returnResults.add('firstname');
                returnResults.add('lastname');
            }

            return returnResults;            
        }
    }
    
    public BindingTest()
    {
        OptionsList = new List<SelectOption>();
        OptionsList.add(new SelectOption('Accounts', 'Accounts'));
        OptionsList.add(new SelectOption('Contacts', 'Contacts'));
        
        SelectedOption = 'Contacts';
        ReadData();
    }

    public void ReadData()
    {
         if( SelectedOption == 'Accounts' )
         {
             QueryViewRecords = [select name, phone, annualrevenue from account limit 10];
         }
         else
         {
             QueryViewRecords = [select firstname, lastname from Contact limit 10];         
         }
    }
}

aballardaballard

If you haven't already done so, I suggest you file a case on this... if it really is a regression it will get fixed faster if there is a customer case!

Aiden ByrneAiden Byrne

Thanks, yes, I opened a case. 

NuDevNuDev

Aiden, have you received any response from Salesforce on this yet?  I'm running into the same issue, unfortunately.

aballardaballard

Can you post the case number?

Aiden ByrneAiden Byrne

The case number is #05536438.

 

The support engineer confirmed this as a Spring/Summer issue and has escalated this to Tier 3. Thats where it's at, so I don't have an ETA or details beyond this.

 

There is one wrinkle. The code I attached in this posting shows the error I get, and should work as far as I can tell. But, from working with the support person over Go To Meeting, she was seeing the same problem running attached on Spring. She escalated the case based on running my product in Spring, seeing that it worked, then running it in Summer and seeing this error.

Alibaba1Alibaba1

try this workaround, bypassing actiuonFunction.  Executing apex method ReadData directly from action:support

 

Change

<apex:actionSupport event="onchange" status="counterStatus" oncomplete="ReadData();" rerender="SearchResults"  />
to
<apex:actionSupport event="onchange" status="counterStatus" action="{!ReadData}" rerender="SearchResults"  />

 

It appears the issue is tied to action:Function ajax request.

Aiden ByrneAiden Byrne

Alibaba,

 

this is a great catch. I heard back from Salesforce support that the code attached in this thread was not working in either Spring or Summer. By applying your suggested change the sample code started working in Spring (still broke in Summer). So, now it does appear to clearly illistrate the issue that I have in my larger app. I bet you are still on the spring release, is that correct? Code with your change applied;

 

 

<apex:page controller="BindingTest">
<apex:form >
<apex:outputLabel dir="" value="Showing: " />
                &nbsp;&nbsp;&nbsp;
<apex:selectList multiselect="false" value="{!SelectedOption}" size="1">    
        <apex:selectOptions value="{!OptionsList}" id="recordOptions" />
<apex:actionSupport event="onchange" status="counterStatus" action="{!ReadData}" rerender="SearchResults"  />          
</apex:selectList>
<apex:pageBlock id="SearchResults" >
     
        <apex:pageblocktable value="{!QueryViewRecords}" var="viewRow">
        <apex:repeat value="{!QueryViewDisplayFields}" var="myfield" id="innerset">
        <apex:column value="{!viewRow[myfield]}" />
        </apex:repeat>
                                        
        </apex:pageblocktable>                
</apex:pageBlock>
</apex:form>
</apex:page>
 
 
public with sharing class BindingTest
{
    public String SelectedOption {get; set;}
    public List<SelectOption> OptionsList {get; set;}
    public List<SObject> QueryViewRecords {get; set;}
    
    public List<String> QueryViewDisplayFields
    {
        get
        {
            List<String> returnResults = new List<String>();    
            
            if( SelectedOption == 'Accounts' )
            {            
                returnResults.add('name');
                returnResults.add('phone');
                returnResults.add('annualrevenue');
            }
            else
            {            
                returnResults.add('firstname');
                returnResults.add('lastname');
            }
            return returnResults;            
        }
    }
    
    public BindingTest()
    {
        OptionsList = new List<SelectOption>();
        OptionsList.add(new SelectOption('Accounts', 'Accounts'));
        OptionsList.add(new SelectOption('Contacts', 'Contacts'));
        
        SelectedOption = 'Contacts';
        ReadData();
    }
    public void ReadData()
    {
         if( SelectedOption == 'Accounts' )
         {
             QueryViewRecords = [select name, phone, annualrevenue from account limit 10];
         }
         else
         {
             QueryViewRecords = [select firstname, lastname from Contact limit 10];         
         }
    }
}
Alibaba1Alibaba1

that is correct, my test org is spring 11.  I just tested on another summer 11 org and confirmed the issue there :)

aballardaballard

Sure looks like something is wrong here, though it doesn't seem to have anything to do with dynamic bindings.   If I replace the column content  with something that just displays the strings in the list I see that list is never updated. 

 

 

Aiden ByrneAiden Byrne

Just FYI, this case is being worked on by Salesforce Support Tier #3.

 

In the interim, they gave the following workaround;

 

As a work around, you can use a HTML table (resonating with the comments form aballard)

 

 The following is a sample:

 

<apex:page controller="BindingTest">

<apex:form >

<apex:outputLabel dir="" value="Showing: " /> &nbsp;&nbsp;&nbsp; <apex:selectList multiselect="false" value="{!SelectedOption}" size="1"> <apex:selectOptions value="{!OptionsList}" id="recordOptions" /> <apex:actionSupport event="onchange" status="counterStatus" action="{!ReadData}" rerender="SearchResults" /> </apex:selectList> <apex:pageBlock > <table> <tr> <apex:repeat value="{!QueryViewDisplayFields}" var="myfield"> <th>{!myfield}</th> </apex:repeat> </tr> <apex:repeat value="{!QueryViewRecords}" var="viewRow"> <tr> <apex:repeat value="{!QueryViewDisplayFields}" var="myfield" id="innerset"> <td>{!viewRow[myfield]}</td> </apex:repeat> </tr> </apex:repeat> </table>

 

</apex:pageBlock>

</apex:form>

</apex:page> 

Aiden ByrneAiden Byrne

Just FYI, this case is being worked on by Salesforce Support Tier #3.

 

In the interim, they gave the following workaround;

 

As a work around, you can use a HTML table (resonating with the comments form aballard)

 

 The following is a sample:

 

<apex:page controller="BindingTest">

<apex:form >

<apex:outputLabel dir="" value="Showing: " /> &nbsp;&nbsp;&nbsp; <apex:selectList multiselect="false" value="{!SelectedOption}" size="1"> <apex:selectOptions value="{!OptionsList}" id="recordOptions" /> <apex:actionSupport event="onchange" status="counterStatus" action="{!ReadData}" rerender="SearchResults" /> </apex:selectList> <apex:pageBlock > <table> <tr> <apex:repeat value="{!QueryViewDisplayFields}" var="myfield"> <th>{!myfield}</th> </apex:repeat> </tr> <apex:repeat value="{!QueryViewRecords}" var="viewRow"> <tr> <apex:repeat value="{!QueryViewDisplayFields}" var="myfield" id="innerset"> <td>{!viewRow[myfield]}</td> </apex:repeat> </tr> </apex:repeat> </table>

 

</apex:pageBlock>

</apex:form>

</apex:page> 

NuDevNuDev

Just an FYI, I received an update to my case this morning which states that this issue has been corrected and the fix has been released.