Page tree
Skip to end of metadata
Go to start of metadata

author: Stefanie Bacher

Use

To run a JNet or a JGantt in a Web Dynpro for Java application, you have to follow the steps described below. This example does not describe how to build the xml file for a Gantt or for a Network, it focuses on the Web Dynpro part. This example explains how to bind a Gantt UI element and its data source to the context. This works exactly the same way for the Network UI element.

Restriction in SAP NW 7.0

In this example the Active Control Framework (ACF) UI elements JNet and JGantt are bound to so-called immutable resource objects. Immutable resources can be displayed in JNet, JGantt or Office UI elments for read-only purposes but they cannot be edited by the user. Based on a restriction of the current Web Dynpro Java API in SAP NW 7.0 the WDResourceFactory-API does not yet expose a factory method for creating mutable resource objects. In typical ACF scenrios a mutable resource is edited by the user on client-side. This Web Dynpro Java API restriction will be corrected in a higher SP stack of SAP NetWeaver 7.0. It is not given in SAP NetWeaver CE 7.1 where the factory method WDResourceFactory.createMassDataResource() is exposed.

Prerequisites

You created a Web Dynpro project or DC together with the required components.

You inserted a Gantt UI element into your view. In this example, a file called gantt.xml is read. The file is stored in Mime Repository in directory <project name>/src/mimes/Components/<component name>. If you do so, you can refer to this file without specifying a directory.

I will provide a little sample gantt.xml soon, at the moment you can find one searching the Web Dynpro for Java forum (wink).

And here it is: gantt.zip

Creating the Context

  1. Create a value node called DataSourceNode and an attribute called DataSource.
  2. Select the DataSourceNode, switch to the Properties view, select supplyFunction and create a supplyFunction called supplyDataSourceNode.
  3. Select the DataSource attribute and set the type to Resource. If you don't know how to do this, follow this link: Data Binding for Resource Property.
     

Bringing xml file to Context 

  1.  Insert the following code into the supply function:
public void supplyDataSourceNode(IPrivateTestAppView.IDataSourceNodeNode node,IPrivate<view name>View.IContextElement parentElement)
{//@@begin supplyDataSourceNode(IWDNode,IWDNodeElement)
IPrivate<view name>View.IDataSourceNodeElement element =node.createDataSourceNodeElement();
node.addElement(element);
try{
String fileName =WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), "gantt.xml");
FileInputStream is = new FileInputStream(fileName);element.setDataSource(WDResourceFactory.createResource(is, "",WDWebResourceType.XML, false));
}
// handle exceptions properly ifthis were not a demo app
catch (WDAliasResolvingException e)
{
}
catch (IOException e){}//@@end}

Mapping the Event Parameters

For each event, you want to react on, you have to map the event parameters to eventhandler parameters. The following example will explain this just for the onRowAdded event.

  1. Create an action called RowAdded with default event handler
  2. Add the following parameters of type String
  • chart
  • component
  • graph
  • parameters

    Now the event and the corresponding action have the same parameters.

3. Map these parameters in the wdDoModify() method:

IWDGantt gantt = (IWDGantt)view.getElement("<Gantt UI elementname>");
IWDParameterMapping mapping = gantt.mappingOfOnRowAdded();
mapping.addSourceMapping("graph", "graph");
mapping.addSourceMapping("chart", "chart");
mapping.addSourceMapping("component", "component");
mapping.addSourceMapping("parameters", "parameters");

Additional Information

JNet/JGantt Developer Documentation