0

I had written one method and call back method for continuation....

global class MyWrapper {
    public static object state{get;set;}
    public String Request { get; set; }
    public String Variable1 { get; set; }
    public String Variable2 { get; set; }

    global MyWrapper(String req, String var1, String var2) {
        Request = req;
        Variable1 = var1;
        Variable2 = var2;
    }

    //continuation method
    @RemoteAction
    global static somemehod(string par1,id par2,boolean par3){

       continuation.state = assgininment;
    }

    //call back method
    public static object(object state){
    }
}

In the above line i am getting an error continuation:

state does not exist.

when i tried declaring the state variable globally , in call back method it is showing an error like duplicate variable state.any suggestions how to resolve it.???

2
  • Can you show your params in method? Where declared Contination instance variable? – RasMisha Sep 4 '16 at 12:11
  • Your code doesn't look much like the example in the Continuation Class documentation. And I can imagine static fields and fields declared to be of type Object not being preserved. – Keith C Sep 4 '16 at 12:32
2

You need to instantiate an instance of the Continuation class in order to assign to the state, because it is an instance variable, not a static variable of the Continuation class - see this example from the documentation (I wish it showed them actually declaring Continuation continuationInstance = new Continuation()):

// Declare inner class to hold state info
private class StateInfo {
    String msg { get; set; }
    List<String> urls  { get; set; }
    StateInfo(String msg, List<String> urls) {
        this.msg = msg;
        this.urls = urls;
    }
}

// Then in the action method, set state for the continuation
continuationInstance.state = new StateInfo('Some state data', urls);

The error you are seeing is the parser interpreting Continuation.state as an attempt to reference a static variable state in the Continuation class, which does not exist.

Your Answer

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

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