You need to sign in to do that
Don't have an account?
josh bowes
Form tag causes serialization error when extension controller contains describe call
Hello,
I've got some Visualforce pages that use controllers which contain describe calls to get picklist values. The picklist values are being used to populate Google visualizaition API data.
Any time I add an <apex:form> tag to the Visualforce, the page returns:
System.SerializationException: Not Serializable: Schema.DescribeFieldResult
Here are the controller and visualforce. The first VF example works fine, the second returns the error above - the only difference is the form tag.
Controller:
Visualforce that works:
Visualforce that returns serialization error:
This is causing me a lot of headaches because I can't use commandlink or commandbutton - does anyone see what the problem is? Is this a bug or am I doing something wrong?
I've got some Visualforce pages that use controllers which contain describe calls to get picklist values. The picklist values are being used to populate Google visualizaition API data.
Any time I add an <apex:form> tag to the Visualforce, the page returns:
System.SerializationException: Not Serializable: Schema.DescribeFieldResult
Here are the controller and visualforce. The first VF example works fine, the second returns the error above - the only difference is the form tag.
Controller:
public class myextensioncontroller { private final myobject__c myobject; public myextensioncontroller(ApexPages.StandardController stdController) { this.myobject = (myobject__c)stdController.getRecord(); } Schema.DescribeFieldResult p = myobject__c.mypicklist__c.getDescribe(); List<Schema.PicklistEntry> stgvals = p.getPicklistValues(); public List<myobject__c> getmyobjectdata(){ return [select id, name from myobject__c]; } }
<apex:page standardcontroller="myobject__c" extensions="myextensioncontroller"> <apex:pageblock > <apex:pageblocktable value="{!myobjectdata}" var="myobj"> <apex:column value="{!myobj.name}"/> </apex:pageblocktable> </apex:pageblock> </apex:page>
Visualforce that returns serialization error:
<apex:page standardcontroller="myobject__c" extensions="myextensioncontroller"> <apex:form></apex:form> <apex:pageblock > <apex:pageblocktable value="{!myobjectdata}" var="myobj"> <apex:column value="{!myobj.name}"/> </apex:pageblocktable> </apex:pageblock> </apex:page>
You can either move your describe call out of a local variable and into the method that is going to be using it (I assume the end goal is to generate a list of SelectOptions containing the picklist values? if so you can move it into the getter that builds up the options) or you can use the transient keyword for p and stgvals.
By defining DescribeSObjectResult variable in local method, it solved my problem of getting Serialization Exception error.
Thanks