Archive for July, 2010

Displaying Mosaic nodes and subscribing to display events

Adobe LiveCycle Mosaic ES2 9.5 introduces a new way of managing the visibility of nodes (views, panels, and tiles) in your application.  This is very useful when your application has multiple views.  The get/set activePanel()/activeView() APIs from Mosaic 9.0 have been removed because they no longer apply now that Mosaic supports nested panels and more than one panel or tile could be visible at the same time.  Replacing them are the “display” APIs.

The ActionScript IDisplayable class is a superclass for IView, IPanel, and ITile:

  • IDisplayable.display() [Sets a node to be visible]
  • IDisplayable.displayed [Gets the visibility of a node]

For JavaScript the display APIs are only available on nodes that are of types “view”, “panel”, or “tile”:

  • Node.display()         [Sets a node to be visible]
  • Node.getDisplayed()    [Gets the visibility of a node]

To display a node with ActionScript:

// nodeToDisplay is of type IMosaicNode
if (nodeToDisplay is IDisplayable)
    var nodeDisplayable:IDisplayable = nodeToDisplay as IDisplayable;
    nodeDisplayable.display(); // Display the node

To display a node with JavaScript:

// nodeToDisplay is of type Node
var strNodeType = nodeToDisplay.getNodeType();

if ((strNodeType == "view") ||
    (strNodeType == "panel")||
    (strNodeType == "tile"))
    nodeToDisplay.display(); // Display the node

To get the display state of a node with ActionScript:

var strNodeDisplayStatus:String = "hidden";

// nodeToTestForDisplay is of type IMosaicNode
if (nodeToTestForDisplay is IDisplayable)
    var nodeDisplayable:IDisplayable = nodeToTestForDisplay as IDisplayable;

    if (nodeDisplayable != null)
        if (nodeDisplayable.displayed)
            strNodeDisplayStatus = "displayed";

To get the display state of a node with JavaScript:

// nodeToTestForDisplay is of type Node
var strNodeType = nodeToTestForDisplay.getNodeType();

var strNodeDisplayStatus = "hidden";

if ((strNodeType == "view") ||
    (strNodeType == "panel")||
    (strNodeType == "tile"))
    if (nodeToTestForDisplay.getDisplayed())
        strNodeDisplayStatus = "displayed";

You can also subscribe to a new event that is dispatched whenever a Mosaic node becomes displayed.

The subscribe and respond to the “DisplayMessage” event with ActionScript:

// Add a message listener for the node-display event
mosaicApp.addMessageListener(DisplayMessage.NAMESPACE, DisplayMessage.DISPLAY_EVENT_CHANGE, onDisplayMessage);

// Handle the node-display event
private function onDisplayMessage(message:Message):void
    for each (var node:IMosaicNode in message.payload.revealedNodes)
    {"Displayed node " + node.nodeLabel, "Display event", mx.controls.Alert.OK, this);

The subscribe and respond to the “DisplayEvent” event with JavaScript:


mosaicApp.addMessageListener("com.adobe.mosaic.core", "DisplayEvent.CHANGE", onDisplayMessage);

function onDisplayMessage(message)
    for (var nNodeCounter = 0; nNodeCounter < message.payload.revealedNodes.length; nNodeCounter++)
        var strNodeLabel = message.payload.revealedNodes[nNodeCounter].getNodeLabel();
        alert("Displayed node " + strNodeLabel);

Sample Flex (DisplayReceiver.mxml) and HTML (DisplayHtmlReceiver.html) tiles are attached.

Launching the Mosaic AIR client with command-line arguments

What better way is there to start a blog on Adobe LiveCycle Mosaic than to blog about a new way to start Mosaic?  Our latest release, ES2 9.5, includes command-line arguments that allow you to specify the user, password, server, and application to start when launching the Mosaic AIR client.  For example:

"C:\Program Files (x86)\Adobe LiveCycle Mosaic\Adobe LiveCycle Mosaic.exe" -user designer -pwd password -server http://localhost:8080 -app ClientDashboard

Here’s how to do the same thing with an Ant script:

<property name="username" value="designer"/>
<property name="password" value="password"/>
<property name="protocol" value="http"/>
<property name="server"   value="localhost"/>
<property name="port"     value="8080"/>

<property name="mosaic_application"  value="ClientDashboard"/>
<property name="mosaic_air_exe_file" value="Adobe LiveCycle Mosaic.exe"/>
<property name="mosaic_air_exe_dir"  location="C:/Program Files (x86)/Adobe LiveCycle Mosaic"/>
<property name="mosaic_air_exe_path" location="${mosaic_air_exe_dir}/${mosaic_air_exe_file}"/>

<!-- Start Mosaic AIR application with command-line arguments -->
<exec failonerror="true" executable="${mosaic_air_exe_path}">
    <arg value="-user"/>
    <arg value="${username}"/>
    <arg value="-pwd"/>
    <arg value="${password}"/>
    <arg value="-server"/>
    <arg value="${protocol}://${server}:${port}"/>
    <arg value="-app"/>  <!-- Specify application to start -->
    <arg value="${mosaic_application}"/>

Note: If the Mosaic AIR client is already started, this command will bring it to the front, but won’t change the running application.