You need to sign in to do that
Don't have an account?
Passing values from one apex class to other
Hi,
I have a tricky situation.
I have a page VF1 with SelectRadio (there are other things, for simplicity consider only this) and corresponding Apex class, class1. when the form on the page is submitted the variables are set in class1.
Now, I need to pass some of the values captured in class1 variables to class2.
For that, I declared a callingMethod in Class1 and calledMethod in class2 passing the variables List<string>.
To invoke the CallingMethod, declared a static{ callingMethod();} block in class1. The problem is I am getting the values as 'null' in class2, may be because of the fact that static block is executed before the varaibles are set on submit button.Please suggest me any workarounds or Am I going in wrong direction.
Appreciate your time.
This is what I am trying to explain:
class1{
static{
callingMethod(List<String> abc);
}
//populate List<String> static callingMethod(List<String> lst) { class2.calledMethod(lst); } } ============== Class2 { static calledMethod(List<String> lst) { // read values from list. I am getting 'null' values } }
Thank you for your reply.
Yes, I think I can get one of these good ideas work. Meanwhile I have been trying other ways.
Let you know once I get something working.
Thanks