Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

i am using dynamic Visualforce component created in Apex

public with sharing class Sample3 {
    public Component.Flow.Interview flow{get;set;}
    public Sample3(){
    flow= new Component.Flow.Interview();
    flow.name='Calculator';     
    }
}

and VF page is

<apex:page controller="Sample3">
<apex:dynamicComponent componentValue="{!flow}"/>
</apex:page>

but when i open visualforce page its giving me error

    Not Serializable: Component.flow.interview 
as mentioned in comment i made a demo Class and VF Page

can anyone please tell How to resolve this issue ??

share|improve this question
    
It would be helpful if you showed us the code for your entire VF page. There may be something else missing, like a reference to your controller. –  crmprogdev Jul 12 at 13:38
    
i edited my question perhaps now you can respond :) –  user133421 Jul 12 at 13:48
    
Just like magic, see what happens when all the details are available? Keith C to the rescue with exactly the response you needed! :) –  crmprogdev Jul 12 at 14:28
add comment

1 Answer 1

up vote 3 down vote accepted

The (attempted) serialization of the not serializable component can be avoided by making the field transient:

public with sharing class Sample3 {
    private transient Component.Flow.Interview flow;
    public Component.Flow.Interview getFlow() {
        return flow;
    }
    public Sample3() {
        flow = new Component.Flow.Interview();
        flow.name = 'Calculator';
    }
}

or simpler still by not holding the value in a field at all:

public with sharing class Sample3 {
    public Component.Flow.Interview getFlow() {
        Component.Flow.Interview flow = new Component.Flow.Interview();
        flow.name = 'Calculator';
        return flow;
    }
    public Sample3() {
    }
}

For dynamic Apex components not including the component in the view state means the components do not work fully (see e.g. Field Values In Dynamic Component Not Retaining After Error); hopefully for your flow component there are no negative consequences.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.