cancel
Showing results for 
Search instead for 
Did you mean: 

Lost Bean when processing my portal component !!!

Former Member
0 Kudos

Hi Friends,

I've created a portal component by using JSPDynPage. I defined an object "KanbanScreen", but when I process this object (input data and callback to server) then an error "NullPointerException" appears at some time.


.....
public void doProcessAfterInput() throws PageException {
    	
		IPortalComponentRequest request = (IPortalComponentRequest)this.getRequest();
		IPortalComponentContext myContext = request.getComponentContext();
		IPortalComponentProfile myProfile = myContext.getProfile();
		myBean =(KanbanScreen) myContext.getValue("myBeanName");

		myBean.setVendorIdAvailable(false);  //error at this line code

		this.vendorIdAvailable = true;
		

	}

public void doProcessBeforeOutput() throws PageException {

	IPortalComponentRequest request =
		(IPortalComponentRequest) this.getRequest();
	IPortalComponentContext myContext = request.getComponentContext();
	IPortalComponentProfile myProfile = myContext.getProfile();
	IPortalComponentURI componentURI = (IPortalComponentURI) request.createPortalComponentURI();
	componentURI.setContextName(myContext.getContextName());
	myBean.setUrl(componentURI.toString());
	boolean found = false;
.....

I doubt the cause of this problem at line code :

<b>componentURI.setContextName(myContext.getContextName());</b>

Anyone can tell me exactly the cause of this problem?

Thanks,

Gy

Accepted Solutions (1)

Accepted Solutions (1)

former_member182416
Active Contributor
0 Kudos

Hi

Error is Coming because the Bean is not Found.

Have you put the Bean in Context in doInitialization() method ?

Regards

Rajendra

Former Member
0 Kudos

Hi Rajendra,

My code do initialization as below:


	Object o = myContext.getValue("myBeanName");
		if(o==null || !(o instanceof KanbanScreen)){
			myBean = new KanbanScreen();
			myContext.putValue("myBeanName",myBean);
		} else {
			myBean = (KanbanScreen) o;
		}
	   
		myBean.setContext(this.getPageContext());

I wonder that my component is working but when I try the log viewer then error "Null pointer exception" still appears.

Thanks,

Gy

former_member182416
Active Contributor
0 Kudos

Hi There ,

Try to Store the Bean in Session.

here is the Code .

1) for doInitialization()



IPortalComponentSession componentSession =
				((IPortalComponentRequest) getRequest()).getComponentSession();
			Object o = componentSession.getValue("myBeanName");
			if (o == null || !(o instanceof KanbanScreen)) {
				myBean = new KanbanScreen();
				componentSession.putValue("myBeanName", myBean);
			} else {
				myBean = (KanbanScreen) o;
			}

2) The Place wher you wish to access this Bean.


IPortalComponentSession componentSession =
				((IPortalComponentRequest) getRequest()).getComponentSession();
			Object o = componentSession.getValue("myBeanName");
			if (o == null || !(o instanceof KanbanScreen)) {
				myBean = new KanbanScreen();
				componentSession.putValue("myBeanName", myBean);
			} else {
				myBean = (KanbanScreen) o;
			}


Regards

Rajendra

Answers (0)