I have a base control (MyCustomControl) and two Controls that extend it
(MyExtendedControl1 and MyExtendedControl2).

At runtime, I would like to be able to choose which sub-implementation to use.
Is this possible?

Thanks in advance,

Chris



@ControlReferences({
        MyCustomControl.class,
        MyExtendedControl1.class,
        MyExtendedControl2.class
        })

public class MyClass() {

   MyCustomControl myControl = null;

   MyClass() {
      if (somelogic) {
         setControl1;
      } else {
         setControl2;
      }
      myControl.hello()
   }

   private void setControl1() {
      myControl = (MyExtendedControl1) Controls.instantiate(
          getClass().getClassLoader(), "sample.MyExtendedControl1Bean", null);
   }

   private void setControl2() {
      myControl = (MyExtendedControl2) Controls.instantiate(
         getClass().getClassLoader(), "sample.MyExtendedControl2Bean", null);
   }
}

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to