networkView
component to add extra user interaction. Interactors are JSF
components that execute client- or server-side actions. Most of
them can be extended and configured to suit the user needs.
pan
interactor) in the JSP™ page and connect it to the
networkView
component so that it is always available.
<!-- Declare the predefined 'pan' interactor --> <jvf:panInteractor id="pan" /> <jvtf:networkView id="aNetwork" context="#{contextBean}" style="width:740;height:550" interactorId="pan" project="data/myProject.itpr" />
panInteractor
is declared. A unique identifier is associated with it ("
pan
"). Then, the
interactorId
tag attribute of the
networkView
component specifies the interactor to be connected to the network
view.
<!-- Declare the predefined 'select' interactor --> <jvtf:selectInteractor id="select" /> <!-- Declare the predefined 'pan' interactor --> <jvf:panInteractor id="pan" /> <!-- Create a 4 columns grid --> <h:panelGrid columns="4"> <!-- Declare a button for selection --> <jv:imageButton onclick="aNetwork.setInteractor(select)" buttonGroupId="interactors" image="images/arrow.gif" rolloverImage="images/arrowh.gif" selectedImage="images/arrowd.gif" title="Select Interactor" message="Select Interactor" /> <!-- Declare a button for panning --> <jv:imageButton onclick="aNetwork.setInteractor(pan)" buttonGroupId="interactors" selected="true" image="images/pan.gif" rolloverImage="images/panh.gif" selectedImage="images/pand.gif" title="Pan Interactor" message="Pan Interactor" /> <!-- Declare a button for zooming in --> <jv:imageButton onclick="aNetwork.zoomIn(true)" image="images/zoom.gif" rolloverImage="images/zoomh.gif" selectedImage="images/zoomd.gif" title="Zoom In" message="Zoom In" /> <!-- Declare a button for zooming out --> <jv:imageButton onclick="aNetwork.zoomOut(true)" image="images/unzoom.gif" rolloverImage="images/unzoomh.gif" selectedImage="images/unzoomd.gif" title="Zoom Out" message="Zoom Out" /> </h:panelGrid> <jvtf:networkView id="aNetwork" context="#{contextBean}" style="width:740;height:550" interactorId="pan" project="data/myProject.itpr" />
buttonGroupId
tag attribute is used to group image buttons so that only one
button of the group is selected at a time. The
selected
attribute is used to specify which button should be made selected
when the page is loaded. This should correspond to the interactor
initially connected to the network view with the
interactorId
tag attribute. In this case, the pan button is selected (
select="true"
) and the
pan
interactor is connected to the network view (
interactorId="pan"
).
<installdir>
stands for the directory where Rogue Wave JViews TGO is
installed.
UICommand
component, which means that it will fire
ActionEvents
to registered
ActionListeners
.
IltSelectInteractor
, which allows selecting, dragging and expanding graphic objects.
BUTTON1
and
BUTTON3
mouse buttons are supported (left and middle).
Shift
key
Control
key
Alt
key
Meta
key
MOUSE_PRESSED
MOUSE_DRAGGED
MOUSE_RELEASED
selectInteractor
is declared like any other JSF component defined in the JViews
TGO JSF tag library:
<jvtf:selectInteractor id="select" />
selectInteractor
JSF component is configured through the following tag
attributes.
Tag
Attributes |
Description
|
---|---|
cursor
|
Defines
the mouse cursor to be used when the interactor is active;
it should be one of the cursors supported by the web
browser. |
lineWidth
|
Defines
the width of the interaction area drawn by the interactor.
|
lineColor
|
Defines
the color of the interaction area drawn by the interactor.
|
actionName
|
Defines
the name of the action event triggered by this interactor;
it is used to identify events coming from this interactor.
|
autoSubmit
|
Defines
whether the request will be submitted by a mouse click or
not; this tag is used to control when the actions are
submitted.
When this tag attribute is set to
false
, the
selectInteractor
will not submit any request after the user interaction, but
wait until some other component does it.
|
actionListener
|
Defines
an action listener that is called when this interactor is
used.
Action listeners should implement the
ActionListener
interface (from JSF library), but JViews TGO JSF provide
the IltFacesGraphInteractorActionListener
abstract implementation that decodes the user interactions
into events dispatched to a given view interactor.
Subclasses should implement the method
getViewInteractor
in order to return the appropriate view interactor to
process the events. The default implementation ( IltFacesSelectInteractorListener)
dispatches all events to the
IltSelectInteractor
view interactor.
Therefore, the
actionListener
tag attribute may be used to register any
ActionListener
that will be notified whenever a user interaction has been
performed, or a subclass of
IltFacesGraphInteractorActionListener
can be registered to decode the user interaction into
events dispatched to view interactions ( IlpViewInteractor).
|
invocationContext
|
Defines
whether the server-side processing is performed in the JSF
lifecycle or directly by the image servlet. The possible
values are:
The
selectInteractor
submits requests to be processed on the server side. By
default, the request is addressed to the JavaServer JSF
controller servlet which processes all requests according
to the well-defined JSF lifecycle. This means that all
component dependencies will be verified, any registered
listener will be notified. The result is a full page
refresh with an update of all components involved. If your
interaction triggers updates of components other than the
networkView
, then the
JSF_CONTEXT
should be used.
If, on the other hand, your requests are supposed to only
update the image displayed by the
networkView
component, then you may want to benefit from the faster
IMAGE_SERVLET_CONTEXT
. In this case, the interactor requests will be addressed
to the image servlet responsible for generating the image
displayed by the
networkView
component. Note that the image servlet has no access to any
JSF component other than
networkView
, which means that your request cannot rely on other JSF
components, and that any registered listener for changes on
the
selectInteractor
and
networkView
will not be updated.
There is one exception to this rule. As the
overview
JSF component is largely used with the
networkView
JSF component, and as its displayed image is also generated
by the image servlet, you can force the overview to be
refreshed whenever the main view (
networkView
) is updated, at the cost of an extra client-server-client
roundtrip. To do so, you must set the
autoRefresh
tag attribute of the
overview
JSF component to true.
|
binding
|
Defines
a binding expression to a backing bean. |
cursor
,
lineWidth
and
lineColor
tag attributes control the look of the interactor when it is
activated, they do not affect its functionality.
<installdir>
stands for the directory where Rogue Wave JViews TGO is
installed.
IltSelectInteractor
. It is possible to override this behavior by adding action
listeners to the component.
selectInteractor
JSF component.
selectInteractor
extends the JavaServer Faces
UICommand
, it allows one or more action listeners (implementing
javax.faces.event.ActionListener
) to be registered to receive events (
javax.faces.event.ActionEvent
) whenever a user interaction is performed. For the
ActionEvent
API there are the following methods:
getComponent()
or
getSource()
: Return a reference to the interactor JSF component that is
currently active (for example,
IltFacesGraphInteractor
).
ActionListener
interface named IltFacesGraphInteractorActionListener is
provided to translate client-side interactions into server-side
events that are dispatched to a given view interactor. When
notified, this class translates user interactions into mouse
events that are automatically dispatched to the
IlpViewInteractor
returned by the abstract method
getViewInteractor(actionName)
.
selectInteractor
behavior with a customized one:
<jvtf:selectInteractor id="select" actionListener="#{MyListenerBean}" invocationContext="JSF_CONTEXT" />
actionListener
tag attribute gets a binding to a bean implementing the
javax.faces.event.ActionListener
interface. Note that
actionListener
will override the default behavior of the
selectInteractor
. It is possible to add more than one action listener,
combining customized action listeners with the default behavior
as shown in the next example:
<jvtf:selectInteractor id="select" invocationContext="JSF_CONTEXT"> <f:actionListener type="ilog.tgo.faces.graph.dhtml.event.IltFacesSelectInteractorListener"/> <f:actionListener type="demo.MyInteractionListener"/> </jvtf:selectInteractor>
selectInteractor
JSF component, and
MyInteractionListener
is a customized implementation of the
javax.faces.event.ActionListener
interface. The
actionListener
tag is used to add several action listeners to the
selectInteractor
, which are invoked in the order in which they have been
declared. Note that action listeners may conflict with each
other, especially multiple implementations of
IltFacesGraphInteractorActionListener
, as the first one invoked may change the business model and
invalidate the next action listener.
<installdir>
stands for the directory where Rogue Wave JViews TGO is
installed.
clientSelectInteractor
JSF component is an interactor designed to minimize the number of
image requests and image updates between the graph view on the
client and the image servlet on the server by dynamically
rendering and managing the selection borders in the client side.
clientSelectInteractor
dynamically renders an HTML rectangular selection around the
object. The server is notified so that the selection model is
kept synchronized with the user interactions. A new graph view
image is requested only when the user drags objects or interacts
with specific decorations (such as information icons, and
expansion icons).
selectInteractor
, the
clientSelectInteractor
always communicates with the image servlet directly. Therefore,
it does not follow the JSF lifecycle, which means that only the
view JSF component and a possibly attached overview are updated
and not all the other components in the page.
clientSelectInteractor
is declared like any other JSF component defined in the JViews
TGO JSF library:
<jvtf:clientSelectInteractor is="clientSelect" />
clientSelectInteractor
JSF component is configured through the following tag
attributes:
Tag
Attributes |
Description
|
---|---|
binding
|
Defines a binding expression to a backing bean, allowing
the user to customize the
clientSelectInteractor
JSF component.
|
message
|
Defines
the message displayed by the view when the interactor is
set. |
cursor
|
Defines
the mouse cursor to be used when the interactor is active.
It should be one of the cursors supported by the web
browser. |
menuModeId
|
The
identifier passed to dynamically generated popup menus. |
moveAllowed
|
Specifies
whether this interactor allows mouse dragging. |
objectActionMethodBinding
|
Defines
a method binding to process actions on the object or on
specific decorations attached to it. |
onSelectionChanged
|
Specifies a JavaScript handler to be called whenever the
selection changes. Deprecated in JViews TGO 8.0. See The selectionManager JSF component
for an alternative.
|
imageMode
|
Sets the interactor to image mode. A new image will be
requested every time the user interacts with the view.
Deprecated in JViews TGO 8.0. See The selectionManager JSF component
for an alternative.
|
lineWidth
|
The width of the selection border dynamically rendered by
the interactor. Deprecated in JViews TGO 8.0. See The selectionManager JSF component
for an alternative.
|
lineColor
|
The color of the selection border dynamically rendered by
the interactor. Deprecated in JViews TGO 8.0. See The selectionManager JSF component
for an alternative.
|
forceUpdateProperties
|
Forces the request of additional information when the
interactor is in image mode. Used in conjunction with the
infoProviderMethodBinding
. Deprecated in JViews TGO 8.0. See The selectionManager JSF component
for an alternative.
|
infoProviderMethodBinding
|
Defines the information provider method binding to return
additional information about the selected object.
Deprecated in JViews TGO 8.0. See The selectionManager JSF component
for an alternative.
|
<installdir>
stands for the directory where Rogue Wave JViews TGO is
installed.
clientSelectInteractor
supports interactions with the following object decorations:
objectActionMethodBinding
tag attribute, as follows:
<jvtf:clientSelectInteractor id="clientSelect" objectActionMethodBinding="#{interactorBean.objectAction}" />
objectActionMethodBinding
tag attribute is bound to the
objectAction
method declared in the
interactorBean
. The method binding must conform to the following signature:
boolean methodName(IlpGraphView, int, int)
IlpGraphView
is a reference to the graph view containing all the objects.
The two integer parameters are the
x
and
y
components of the view position where the user has clicked.
Returning
true
indicates that a new image has to be generated, while
false
indicates that nothing has been processed and the clicked
object will be selected.
objectAction
method will override the default object action behavior (which
is to react on expand, collapse, information and system icons).
It is possible to extend this default behavior by overriding
the method
processObjectAction
in class IltFacesDefaultObjectAction.
networkView
tag, as follows:
<jvtf:networkView id="tgoViewId" interactorId="select"> <f:facet name="selectionManager"> <jvtf:selectionManager imageMode="false" [...] /> </f:facet> </jvtf: networkView >
selectionManager
, like for example the line width or the color of the selection
rectangle used in regular selection mode:
<jvtf:selectionManager lineWidth="2" lineColor="red"/>
clientSelectInteractor
.
selectionManager
JSF component is configured through the following tag
attributes:
Tag
Attributes |
Description
|
---|---|
infoProviderMethodBinding
|
A method binding that respects the signature List
methodName(IlpGraphView, IlpRepresentationObject). The
returned value of this method is a list of additional
properties associated with the selected object. A valid
item of this list is a String or a list itself. As of
JViews TGO 8.0, the preferred way to transfer object
properties to client is via the
propertyAccessor
tag of the
selectionManager
.
|
binding
|
The
value binding expression linking this component to a
property in a backing bean. If this attribute is set, the
tag does not create the component itself but retrieves it
from the Bean property. This attribute must be a value
binding. |
lineColor
|
The
color of selection rectangles lines. |
forceUpdateProperties
|
Force
to make additional request to query the current selection
and additional properties in image mode to enable
client-side selection listener. |
id
|
The
ID of this component. |
imageMode
|
The image mode. In image mode, the image is refreshed on
each selection. In regular mode, only the selected
object(s) bounding box is queried and rectangles are
dynamically displayed on top of the view. Note that the
client-side listeners on selection and additional
information on selected objects are available in image mode
if and only if the
forceUpdateProperties
property is set to true. In regular mode no special
configuration is needed. By default the manager is in image
mode.
|
lineWidth
|
The
width of selection rectangle lines. |
onSelectionChanged
|
A JavaScript handler called when the selection has changed.
The handler can use the predefined variable '
selection
' which is the list of current selected items. To use this
handler the
selectionManager
must be in regular mode or the
forceUpdateProperties
must be set if in image mode. Refer to the user's
documentation for further information.
|
propertyAccessor
|
The reference to the value binding expression to an
IltFacesPropertyAccessor
instance that will be used to access model properties of
the selected objects.
|
fillOn
|
true
to display filled selection rectangles. The fill color is
the line color with a transparency of 50%. |
List getPropertyNames(IlpGraphicView view, IlpRepresentationObject object)
<jvtf:selectionManager propertyAccessor="{#serverBean.propertyAccessor}" [...] />
public class ServerBean { private IltFacesPropertyAccessor accessor = new MyPropertyAccessor(); public IltFacesPropertyAccessor getPropertyAccessor() { return accessor; } class MyPropertyAccessor extends IltFacesPropertyAccessor { protected List getPropertyNames(IlpGraphicView view, IlpRepresentationObject object) { […] } } }
<jvtf:selectionManager onSelectionChanged="displayProperties(selection)"/>
// Alert the ID and bounds of all the selected objects function displayProperties(selection) { for (var i = 0; i < selection.length; i++) alert(selection[i].getID()+"+selection[i].getBounds()); }
// Alert all the properties of all the selected objects function displayProperties(selection) { for (var i = 0; i < selection.length; i++) { var propertiesNames = selection[i].getObjectPropertyNames(); for (var j = 0; j < propertiesNames.length; j++) alert(selection[i].getObjectProperty(propertiesNames[j])); } }
forceUpdateProperties
to
true
. In regular mode this feature is available without any
overhead.
<installdir>
is the directory in which Rogue Wave JViews TGO is installed.
selectionManager
also allows for changing the selection state of objects
programmatically via its client side by means of JavaScript.
This can be accomplished by using the following API:
selectById
function allows you to select or deselect an object by
providing the object's identifier:
networkView.getSelectionManager().selectById("tgoObjectId");
tgoObjectId
and deselect the object currently selected.
networkView.getSelectionManager().selectById("tgoObjectId", true);
tgoObjectId
, if it's not already selected; or it will deselect it, if it
is already selected.
selectAll
function allows you to select all objects:
networkView.getSelectionManager().selectAll();
deselectAll
function allows you to deselect all objects:
networkView.getSelectionManager().deselectAll();
<installdir>
is the directory in which Rogue Wave JViews TGO is installed.