IlpNetwork
is instantiated. However, you can customize the way this underlying
component is created, in two different ways:
binding
tag attribute allows you to replace the default network view JSF
component with a customized backing bean that controls how the
IlpNetwork
is created through the
createNetworkComponent
method, as illustrated below:
protected IlpNetwork createNetworkComponent(IlpContext context, String config) { IlpNetwork myNetwork = new IlpNetwork(config, context); IlpDefaultDataSource dataSource = new IlpDefaultDataSource(context); try { myNetwork.setStyleSheets(new String[] { "myStyles.css" }); dataSource.parse("myData.xml"); } catch(Exception x) { System.err.println("Could not configure custom component"); } myNetwork.setDataSource(dataSource); return myNetwork; }
networkView
JSF component
binding
attribute can be set with a value binding to a backing bean
that extends IltFacesDHTMLNetworkView (the JavaScript
implementation of the network view JSF component). The
following example illustrates this:
<jvtf:networkView id="aNetwork" context="#{contextBean}" style="width:740;height:550" binding="#{myJSFNetwork}" />
#{myJSFNetwork}
is a value binding to a backing bean declared in the
faces_config.xml
like this:
<managed-bean> <description>A bean extending IltFacesDHTMLNetworkView</description> <managed-bean-name>myJSFNetwork</managed-bean-name> <managed-bean-class>example.MyNetworkView</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean>
<installdir>
stands for the directory where Rogue Wave JViews TGO is
installed.
network
tag attribute allows you to define the customized instance of an
IlpNetwork component through method
binding. You should declare a bean with a method that returns
your instance of
IlpNetwork
and bind this method with the
network
tag attribute, as illustrated below:
public IlpNetwork getCustomNetwork() { if (null == network) { // Get the default configuration file name String config = IltFacesNetworkView.DefaultConfigurationFileName; network = new IlpNetwork(config, context); IlpDefaultDataSource dataSource = new IlpDefaultDataSource(context); try { network.setStyleSheets(new String[] { "myStyles.css" }); dataSource.parse("myData.xml"); } catch(Exception x) { System.err.println("Could not configure custom component"); } network.setDataSource(dataSource); } return network; }
IltFacesNetworkView.DefaultConfigurationFileName
.
networkView
JSF component
network
attribute of the network view JSF component, as follows:
<jvtf:networkView id="aNetwork" context="#{contextBean}" width="740" height="550" network="#{myIlpNetwork.network}" />
width
and
height
are used to specify the size of the network view. Other
examples produce the same results using the
style
tag attribute with the CSS properties "
width
" and "
height
".
network
attribute is set with a method that binds to a bean defined in
the
faces_config.xml
. The corresponding method (
getNetwork
in this case) will be invoked when the JSPā¢ page is parsed. It
allows the user to have access to the
IlpNetwork
API as well as to its instantiation. Using the
network
attribute and keeping the
IlpNetwork
in a bean is a good way to provide quick access to the
underlying
IlpNetwork
API within the web application. Note that the context is not
passed to the
myIlpNetwork.getNetwork
method, which means that this bean must be configured with the
appropriate context in the
faces_config.xml
file. For example:
<managed-bean> <description>A bean with read access to the 'network' property</description> <managed-bean-name>myIlpNetwork</managed-bean-name> <managed-bean-class>example.MyNetwork</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>context</property-name> <property-class>ilog.cpl.service.IlpContext</property-class> <value>#{contextBean}</value> </managed-property> </managed-bean>
<installdir>
stands for the directory where Rogue Wave JViews TGO is
installed.