JBoss.orgCommunity Documentation

Chapter 8. JBoss Portal support for Portlet 2.0 coordination features

8.1. Introduction
8.1.1. Explicit vs. implicit coordination
8.2. General configuration considerations
8.2.1. Overview of the configuration interface
8.3. Alias Bindings
8.3.1. Definition
8.3.2. Configuration via XML
8.3.3. Graphical configuration
8.4. Parameter bindings
8.4.1. Definition
8.4.2. Configuration via XML
8.4.3. Graphical configuration
8.5. Event wirings
8.5.1. Definition
8.5.2. Configuration via XML
8.5.3. Graphical configuration
8.6. <implicit-mode>
8.7. Coordination Samples

While the Portlet 2.0 specification provides for more advanced coordination between portlets than the 1.0 version of the specification, it is left up to specific implementations how portlets are wired together. This chapter will look into how the coordination features are implemented in JBoss Portal.

If you are interested in these features, we strongly encourage you to read the Portlet 2.0 (JSR-286) specification as we will assume in this chapter that you are familiar with the different coordination concepts.

Most JSR-286 specification implementations support the coordination features using what is called an implicit coordination model. This model is called implicit because the relations between the different interacting portlets are inferred based on the event or parameter names that are used to pass information between the portlets. This follows the well-known principle of convention over configuration and provides a good default behavior as it doesn't require explicit user action to wire portlets.

However, such an implicit model of how portlets are wired together fails to handle more complex cases. In particular, it is often the case that semantically related events or public parameters are named differently by different portlet providers. As it is not always possible to modify the portlets to adjust for this minor naming difference of otherwise semantically compatible portlets, JBoss Portal introduces an explicit coordination model that takes precedence over the implicit model when so required.

Consider, for example, the following case: we have 3 windows (A, B and C) on a given page. Each window is associated to a given portlet (Portlet A, Portlet B and Portlet C, respectively). Portlet A can produce the Event A event, while Portlet B and Portlet C can consume Event B and Event C, respectively. Assuming that these events are semantically equivalent, we would like to wire these portlets via their events such that when Portlet A emits an Event A, it gets converted to the appropriate event and transmitted to both Portlet B and Portlet C so that their respective windows can be appropriately updated. This scenario, as depicted below, is impossible using implicit wiring of events:


We look at how to bypass the default implicit model using JBoss Portal's explicit model in the rest of this chapter. It is, however, interesting to note that JBoss Portal can function with both models at the same time. More precisely, it is possible to use the implicit handling of coordination while still specifying explicit wirings, as we will see later.

As most other features of JBoss Portal, the coordination functionality can be configured either declaratively using the now familiar *-object.xml descriptors (see Chapter 6, XML Descriptors for a refresher on these descriptors) or, at runtime, using the administration configuration GUI. We detail, below, both configuration options for each type of coordination entities.

Note

Explicit coordination is currently scoped only at the page level. More specificially, explicit coordination between portlets is only supported between portlets located on the same page.

Explicit alias bindings can be defined in any page definition of your *-object.xml descriptors. For example, this is how the example that we detailed above would be implemented, within a page definition:

...
<coordination>(1)
   <bindings> (2)
      <implici(3)t-mode>FALSE</implicit-mode>
      <alias-b(4)inding>
         <id>alias</id>
         <qname>paramA</qname>
         <qname>paramC</qname>
      </alias-binding>
   </bindings>
</coordination>
1

Coordination configuration is done via the newly introduced <coordination> element.

2

Alias bindings are defined using the <bindings> element. Note that this element is also where parameter bindings are defined.

3

We specify here that we want JBoss Portal to send parameter values when an explicit bindings are defined (<implicit-mode> set to FALSE).

4

An alias binding definition consists of:

  • an id used to identify it

  • a list of public render parameter names or previously defined alias or parameter binding names

In this example, we defined an alias binding named "alias" which aliases the public render parameters paramA and paramC.

Explicit parameter bindings can be defined in any page definition of your *-object.xml descriptors. For example, this is how the example that we detailed above would be implemented, within a page definition:

...
<coordination>(1)
   <bindings> (2)
      <paramet(3)er-binding>
         <id>parameterBinding</id>
         <wind(4)ow-coordination>
            <window-name>Window A</window-name>
            <qname>{nsA}paramA</qname>
         </window-coordination>
         <window-coordination>
            <window-name>Window B</window-name>
            <qname>{nsB}paramB</qname>
         </window-coordination>
      </parameter-binding>
   </bindings>
</coordination>
1

Coordination configuration is done via the newly introduced <coordination> element.

2

Parameter bindings are defined using the <bindings> element. Note that this element is also where alias bindings are defined. Note here that we don't specify a value for the <implicit-mode> element, it will thus default to TRUE, meaning that implicit binding of parameters will also be performed by JBoss Portal in addition to the explicit binding we are defining here.

3

A parameter binding definition consists of:

  • an id used to identify it

  • a list of <window-coordination> elements identifying which parameters will be bound for which portlets

In this example, we defined a parameter binding named "parameterBinding" which specifies that whenever Window A or Window B updates the value of the public parameter {nsA}paramA or {nsA}paramA (respectively), the other will receive the new value for the public render parameter it knows about.

4

A window / parameter name pair identifying either a public parameter to be wired.

Explicit event wirings can be defined in any page definition of your *-object.xml descriptors. For example, this is how the example that we detailed above would be implemented, within a page definition:

...
<coordination>(1)
 <wirings>    (2)
     <implicit(3)-mode>TRUE</implicit-mode>
     <event-wi(4)ring>
         <name(5)>wiring</name>
         <sour(6)ces>
             <(7)window-coordination>
                 <window-name>Window A</window-name>
                 <qname>Event A</qname>
             </window-coordination>
         </sources>
         <dest(8)inations>
             <window-coordination>
                 <window-name>Window B</window-name>
                 <qname>Event B</qname>
             </window-coordination>
             <window-coordination>
                 <window-name>Window C</window-name>
                 <qname>Event C</qname>
             </window-coordination>
         </destinations>
     </event-wiring>
  </wirings>
</coordination>
1

Coordination configuration is done via the newly introduced <coordination> element.

2

Event wirings are defined using the <wirings> element.

3

We specify here that we default to implicit wiring of events for this page. However, we will define one explicit event wiring that will take precedence over the implicit wiring when needed.

4

An event wiring definition consists of:

  • a name used to identify it

  • a list of source events that are to be mapped to the destination ones

  • a list of destination events that will be mapped from the source events

5

The name of the event wiring which must be unique in the scope of the specified page.

6

The list of source events, each being identified by a <window-coordination> element.

7

A window / event name pair identifying either a source or destination of event to be mapped.

8

The list of destination events, each being identified by a <window-coordination> element.

While the new <coordination> element can be used in both <page> and <portal> elements, the only configuration that can be specified at the portal level is whether to use the implicit mode or not:


<portal>
      ...
      <coordination>
         <bindings>
            <implicit-mode>TRUE</implicit-mode>
         </bindings>
         <wirings>
            <implicit-mode>FALSE</implicit-mode>
         </wirings>
      </coordination>
      ...
</portal>

Specifying this <implicit-mode> element at the portal level allows the user to specify which default behavior to apply to child pages. Quite reasonably, if <implicit-mode> is set to TRUE then the implicit mode will be used by default. This does not, however, preclude specific pages to define explicit associations where needed. Setting <implicit-mode> to FALSE, however, completely deactivates the implicit handling of coordination features, leaving it up to users to configure only the associations that need to be made. Note also that the implicit mode can be set for either bindings or wirings. If no value is provided, implicit mode is used by default.

As part of the core-samples module, JBoss Portal provides several examples of how coordination can be used. These examples are gathered in the Coordination Samples page. You can look at how the examples are configured using the administration interface or by looking at the portal-coordination-samples.war/WEB-INF/default-object.xml file.