Contexts for actions on the Gantt Chart view
Describes the contexts in which actions can be executed in response to interactions on the view.
Describes the JavaServer Faces lifecycle and image servlet contexts for actions on the view.
Explains how to install a select object interactor and a listener in the JSF context.
Describes the value change listener and interactor in the image servlet context.
Introduction
Actions executed in response to interactions on the view can be executed in two different contexts: JavaServer Faces lifecycle or image servlet. The execution context can be configured by setting the invocationContext attribute on the JSF interactor components.
The value change listeners registered in the interactor can determine whether they are called in a JSF context or in an image servlet context with the following code.
Determining the Context in Which a Value Change Listener is Called
IlvObjectSelectInteractor source =
(IlvObjectSelectInteractor)valueChangeEvent.getSource();
boolean jsfContext = source.getInvocationContext() ==
IlvDHTMLConstants.JSF_CONTEXT;
This section shows the differences between the two invocation contexts through the execution of an action when a hierarchy node is selected.
JavaServer Faces lifecycle context
This topic shows you the JViews JSF code for installing a select object interactor and a listener. It also shows you the Java™ code for writing a value-change event listener.
In JViews Gantt
To expand an activity in a Gantt chart view, a select hierarchy node interactor must be installed on the Gantt chart view. The
value property of the interactor holds the
IlvHierarchyNode that was clicked. (The hierarchy node is an
activity in a Gantt chart or a
resource in a Schedule chart.) Thus, a
valueChangeListener can be registered to handle the selection event.
Installing a select hierarchy node interactor and a listener
<jvgf:nodeSelectInteractor id="expand"
valueChangeListener="#{ganttBean.expandAllRows}"
invocationContext="JSF_CONTEXT"/>
<jvgf:ganttView id="ganttView" sheetInteractorId="expand" [...] />
NOTE JSF_CONTEXT is the default value, so the invocationContext attribute could have been omitted.
Java code of the value-change event
The Java code of the value change event listener is:
public void expandAllRows (ValueChangeEvent event) {
IlvActivity activity = (IlvActivity) event.getNewValue();
if (activity != null) {
//The source of the event is the interactor
IlvFacesNodeSelectInteractor interactor =
(IlvFacesNodeSelectInteractor)event.getSource();
//Retrieve the JSF view connected to the interactor
IlvFacesHierarchyChartView jsfView =
(IlvFacesHierarchyChartView)interactor.getView();
//Retrieve the IlvHierarchyChart wrapped by the JSF component.
IlvHierarchyChart chart = jsfView.getChart();
if (chart.isRowExpanded(activity)) {
chart.collapseRow(activity);
} else {
chart.expandAllRows(activity);
}
}
}
In JViews Charts
To highlight a point in a chart view, a chart select interactor must be installed on the chart view. The
value property of the interactor holds the
IlvDataSetPoint that was clicked. Thus, a
valueChangeListener can be registered to handle the selection event.
Installing a chart select interactor and a listener
<jvcf:chartSelectInteractor id="selectInteractor"
valueChangeListener="#{demoBean.pointSelected}"
pickingMode="item"
invocationContext="JSF_CONTEXT">
<jvcf:chartView id="chart" interactorId="objSelect" [...] />
NOTE JSF_CONTEXT is the default value, so the invocationContext attribute could have been omitted.
Java code of the value-change event
The Java code of the value change event listener is:
public void pointSelected(ValueChangeEvent evt) {
IlvDataSetPoint point = (IlvDataSetPoint) evt.getNewValue();
if (point != null) {
//The source of the event is the interactor
IlvObjectSelectInteractor interactor =
(IlvObjectSelectInteractor) evt.getSource();
//Retrieve the JSF view connected to the interactor
IlvChartDHTMLView jsfView = (IlvChartDHTMLView) interactor.getView();
//Retrieve the IlvChart wrapped by the JSF component.
IlvChart chart = jsfView.getChart();
//Set a pseudo class on the display point.
//A CSS rule like point:selected { ... }
//will customize the graphic representation of the point.
chart.setPseudoClasses(point.getDataSet(),
point.getIndex(),
new String[]{"selected"} );
}
Note the following concerning the use of this approach:
Since the method is called during the JavaServer™ Faces lifecycle, there can be interaction with other JSF components.
The form is submitted, so the complete page is reloaded.
Image servlet context
The image servlet uses the same value change listener as the JavaServer™ Faces lifecycle; there is a slight difference in the interactor, which is shown in bold in the example.
Value change listener and interactor in image servlet context (JViews Gantt)
<jvgf:nodeSelectInteractor id="expand"
valueChangeListener="#{ganttBean.expandAllRows}"
invocationContext="IMAGE_SERVLET_CONTEXT"/>
<jvgf:ganttView id="ganttView" sheetInteractorId="expand" [...] />
Value change listener and interactor in image servlet context (JViews Charts)
<jvcf:chartSelectInteractor id="selectInteractor"
valueChangeListener="#{demoBean.pointSelected}"
invocationContext="IMAGE_SERVLET_CONTEXT">
pickingMode="item"
<jvcf:chartView id="chart" interactorId="objSelect" [...] />
In this mode the interactor queries an image update. The server fires the value change event just before image generation.
This approach in JViews Gantt:
Avoids submitting the page and refreshes the image only.
This approach in JViews Charts:
Avoids submitting the page and refreshes the image only.
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.