Get bean instance on CAF to refresh web service on action

Hi,

I’m trying to create an action for a button that refresh a webservice to publish a document to broker and gets redirected to a new portlet.

publishDoc2.refresh(); works well when using the WS on the UI (by drag and drop functionality) but when called inside an action gives java null exception.

If I try the getPublisDoc2 it looses the input parameters :?

So my question is a bit more generic how to get the instance of a bean inside an action?

publishDoc2.refresh();
		
		//navigate to the page that has the target portlet on it.
		try {
			IPortletURL refreshUrl = createActionUrl();  
	        
			refreshUrl.clearParameters();  
			refreshUrl.clearState();
			refreshUrl.setBaseURL("/portlet/abc___SelectApplicationCategory");
			//set the portlet that is the target of the action
			refreshUrl.setPortlet("/portlet/abc___SelectApplicationCategory");
			refreshUrl.setTargetAction("default");
			
			//redirect..
			Debug.info("redirectURL : " + refreshUrl.toString());
			getFacesContext().getExternalContext().redirect(refreshUrl.toString()); 
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

Cheers,

My guess is the input parameters aren’t being passed in, but it’s hard to tell from your description. Some questions:

  1. What line is the NPE thrown from? Is it the refresh, or later?
  2. If you turn pipeline debug in IS on the Flow service that backs your web service, do you get anything? This will show you if the web service is being called at all.
  3. Are you using a Command Button or an Async Command Button? This is just to make the redirect work; you should use a Command Button.

Yeap those are my thoughts as well.

After reading you’re reply I did a test, drag and drop the webservice to the portlet and ran my custom action again (clicking the submit button). This time it worked. :shock:

To have access to this kind of beans they have to deployed on the portlet and hidden (I don’t want the user to see it)? Is this correct way to do it?

I thought the beans created on the initialisation with the binding and if you have it on Bindings window it would be available on CAF(java source), ok they are available but not populated (“instantiated”). I can see in the source you always have YourBeanType YourBean=null, but should this be populated at initialisation time.

A second alternative is to make the YourBean=getYourBean() and then manually populate each required field.

On the publishdoc.resfresh().

Tried this out but nothing is being written and thanks for the tip.

It’s a Command Button exiting the page not an ajax call. :wink: