|
| Re: Calling Custom Controls from POJOs |
 |
Sun, 2 Mar 2008 04:40:41 -0800 |
This is waht I used in Workshop for WLS 10, I'm sure it will work
There are 2 ways of resolving the NPE
1)
package com.bea.samples.pojos;
import javax.xml.rpc.ServiceException;
import com.bea.samples.controls.service.MyControlBean;
import org.apache.beehive.controls.api.bean.ControlReferences;
import org.apache.beehive.controls.api.bean.Controls;
@ControlReferences ({com.bea.samples.controls.service.MyServiceControl.class})
public class TestControl {
public void testContractServiceControl() throws ServiceException,
ClassNotFoundException
{
MyServiceControlBean controlBean = (MyServiceControlBean)Controls.instantiate
(Thread.currentThread().getContextClassLoader(),
"com.bea.samples.controls.service.MyServiceControlBean", null);
controlBean.doSomething();
}
}
2)
package com.bea.samples.pojos;
import javax.xml.rpc.ServiceException;
import org.apache.beehive.controls.api.bean.Control;
public class TestControl2 {
@Control
public com.bea.samples.controls.service.MyServiceControl cntrl;
//Contructor
public TestControl2()
{
try
{
//Client Initialization
org.apache.beehive.controls.api.bean.Controls.initializeClient(
null, this, null );
}
catch(ClassNotFoundException cnfe )
{
System.out.println("ClassNotFoundException: " +cnfe.getMessage() );
}
}
public void testContractServiceControl() throws ServiceException,
ClassNotFoundException
{
cntrl.getContractDetail("", "", "");
}
}
Notice how we are doing the client initialization within the pojo’s
constructor. The intializeClient is nothing but a helper method for initializing
instances of declarative control clients meaning objects that use co |
| Post Reply
|
|
|
|
|
|
|
|
|
|