function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
URVASHIURVASHI 

How to use custom controller with extension

Hi,

Can anyone help.

 

I want use a extension with custom controller

<apex:page controller="MyApexClass" extensions="MyExtClass"...> ... </apex:page>
public with sharing class MyExtClass {
  private MyApexClass ctrl;
  public MyExtClass(MyApexClass controllerParam){
      ctrl = controllerParam;
  }
}

I have used in similar manner but now,if i have a vf page with select list and its getter and setter method are in MyExtClass(extension) then how do i use that variable value in my controller MyApexClass.

 

like for example:

How do i use selectedvalue3 in my controller MyApexClass.

Is there any way to do this?

public with sharing class MyExtClass {
public string selectedValue3{get;set;} private MyApexClass ctrl; public MyExtClass(MyApexClass controllerParam){ ctrl = controllerParam; } }
Naveen NelavelliNaveen Nelavelli

you can achieve this in another way like..

 

inside MyApexClass create object of MyExtClass and access  MyExtClass elements ...its like...

 

class MyApexClass{

        //declring as class element so tht it can be accesed by all the classes

           MyExtClass   me;

//constructor

           MyApexClass(){

 

                        me=new MyExtClass  ();

          }

 

  public void method(){

//usig above u can use all elements if u want selectedValue3...

     me.selectedValue3

 

 }

}