You are here

Inter-Component-Communication with WebCenter and ADF

In a previous post I discussed how Inter-Portlet-Communication works between two JSR 286 portlets in WebCenter. In WebCenter you can do much more when it comes to wiring two components together. You cannot only wire portlets together but also taskflows and ,components. All 3 types can be used as source or destination and you can easily mix them together.

In this post I will explain how Inter-Component-Communication (ICC) can be setup for portlets. You can download the sample application from here.

I will give an example on how to pass values from a portlet to a taskflow and component and how to use a value from a component as parameter of the portlet.

ICC between portlets can be found in one my previous posts so I will not discuss it here.

In order to pass values from a portlet to a taskflow, your portlet and taskflow will need to meet some requirements.

First of all, your portlet will need to have a parameter assigned to it. This parameter will get the value that will be passed. In order to do so, you need to add the parameter in the portlet.xml

After you have created the parameter in the Parameters section of the portlet.xml, you need to assign the parameter to your portlet:

And of course, you are required to write some code that will set the value of the parameter:

  1. public void doSubmit(ActionEvent actionEvent) {
  2.     FacesContext ctx = FacesContext.getCurrentInstance();        
  3.     ActionResponse  response =(ActionResponse)  
  4.            ctx.getExternalContext().getResponse();
  5.     response.setRenderParameter("myParam", value);
  6. }

The doSubmit is an actionListener of a button in this example.
One big remark to this is that when you are dealing with ActionResponse, PPR will not work because during a partial page submit, the ActionResponse is not available! This means that in order to make a succesfull ICC call, your portlet should submit fully instead of partially.

That's it for the portlet.
In order to pass the value from Portlet to Taskflow, you will need to have an input parameter in the taskflow:

Now let's drop the portlet to a page. Make sure you select ADF Rich Portlet. You should have something like this on your page:

  1. <adfp:portlet value="#{bindings.Portlet11_1}" id="portlet1"/>

Nothing fancy about this. The real magic happens behind the screens in the page definition. Let's open the page definition and look at the source. You will notice following entry for the portlet:

  1. <portlet id="Portlet11_1"
  2.     portletInstance="/oracle/adf/portlet/ICCPortlets/ap/portlet1_1a95904a_0135_1000_8001_c0a8fd01d285"
  3.     class="oracle.adf.model.portlet.binding.PortletBinding"
  4.     retainPortletHeader="false"
  5.     listenForAutoDeliveredPortletEvents="true"
  6.     listenForAutoDeliveredParameterChanges="true"
  7.     xmlns="http://xmlns.oracle.com/portlet/bindings">
  8.    <parameters>
  9.      <parameter name="myParam"
  10.            pageVariable="Portlet11_1_myParam"/>
  11.    </parameters>
  12.    <events>
  13.         <event eventType="ParametersChange"
  14.           name="Portlet11_1_Event"/>
  15.     </events>
  16. </portlet>

The most important part in this entry is the mapping between the parameter and a pageVariable. This allows us to reference the portlet parameter as a regular page variable which means that we can access it using a regular EL statement.

Now let's drop the taskflow to our page as a region.

You will get a popup to specify the value for the input parameter. Let's specify the pageVariable as value:

As you can see from the image, we are using #{bindings.Portlet1_1_myParam[0]} to reference the parameter. This is the pageVariable that is referenced in the parameter section of the portlet in the page definition.

Notice that the value is passed as an Array of String so we need to specify the first element by adding [0]. Otherwise an array will be passed to the taskflow containing a single element which is the parameter value.

You also need to set a partialTrigger on the region to the portlet so the taskflow will get refreshed after you click the submit button in the portlet.

In order for the taskflow to refresh properly, you also need to set the Refresh property of the taskflow in the page definition to ifNeeded. Otherwise the taskflow will not refresh!

Now let's run the page and specify a value in the input field. Press the button and let the magic happen...

Not really rocket science but it allows you build really fancy components who can work together. This is what interoperability is all about!

Now let's do the same but passing the value to a component instead.

We already did most of the work. Remember that we have a page variable where we can reference the portlet parameter? Well, that's it. We just use that page parameter in our component.

Let's add a simple outputText to our page that will show the actual value of the parameter:

  1. <af:outputText partialTriggers="portlet1" id="output"
  2.     value="#{bindings.Portlet11_1_myParam[0]}"/>

That's it! Run the page and specify a value in the portlet.

We use the same expression language statement as we do to pass the value to our taskflow. Not that difficult, right?

That's it for today. I will create a separate post on how to pass values from a taskflow or component to a portlet (the other direction as shown in this post).

You can also download the sample code with the portlet and portal project here.

Happy Communicating!

Category: 
WebCenter Tags: 
ADF Tags: 
Attachment: 

Comments

Hi Yannick,

Nice post. Any chance that you can post the other way around? That is taskflow passing a parameter(s) to a portlet?

The next post on my blog will be exactly that. I am planning this, now just finding some time :)

Hi Yannnick,
Can you please provide me the link to the blog that have written for passing values from task flow or Component to the Portlet? I was looking around passing parameters from a Page (say a text box in the page) in WebCenter Portal to a Portlet that I have dropped in that page.

Thanks.

Passing from a TF to a portlet would involve using contextual events: http://yonaweb.be/inter_component_communication_between_taskflows_adf_an...

Can you please direct me to the link of this next blog where you have written about passing a parameter(s) to a portlet

Hi Yannick,

Any idea on how to pass this value to a taskflow but on a different page? Like being redirected to that page?

That's quite tricky...
You can follow this discussion on OTN: https://forums.oracle.com/forums/thread.jspa?threadID=2361633&tstart=0 (maybe you're the poster?)

This is a question asked quite often so I might end up posting an example. I just don't know when because I'm very busy at the moment... i'll put it on top of my todo list for my blog :)

hi,

can we send parameters between Portlets of two different Applications or between two different servers?

Thanks in advance

Short answer: no.
IPC is designed for portlets on the same page.

Once you have portlets in different applications they cannot communicate which each other unless you pass values over the URL and pass request parameters to the portlets but there is no direct way of doing so.

Hi

From your article, #{bindings.Portlet11_1_myParam[0]} binds to portlet parameters. How do I manually set this variable to a custom value before portlet is called?

Thanks, Frank

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer