To select a graphic object in a view at the
JViews Framework level, a select object interactor
must be installed on the view. The
value
property
of the interactor holds the
IlvGraphic object
that was clicked. Thus, a
valueChangeListener
can
be registered to handle the selection event.
Installing a select object interactor and a listener
<jvf:objectSelectInteractor id="objSelect"
valueChangeListener="#{frameworkBean.selectObject}"
invocationContext="JSF_CONTEXT"/>
<jvf:view id="view" interactorId="objSelect" [...] />
Note
JSF_CONTEXT
is the default
value, so the invocationContext
attribute
could have been omitted.
Java code of value-change event
The Java code of the value change event listener is:
public void selectObject(ValueChangeEvent event) {
Object value = event.getNewValue();
if (value != null && value instanceof IlvGraphic) {
//The source of the event is the interactor
IlvFacesObjectSelectInteractor source =
(IlvFacesObjectSelectInteractor)valueChangeEvent.getSource();
//Retrieve the JSF view connected to the interactor
IlvFacesView jsfView = (IlvFacesView)source.getView();
//Retrieve the IlvManagerView wrapped by the JSF component.
IlvManagerView managerView = jsfView.getView();
//Select the clicked object
IlvGraphic g = (IlvGraphic) value;
managerView.getManager().deSelectAll(false);
managerView.getManager().setSelected(g, true, false);
}
}