Advanced Features > Using DHTML-Based JSF Components to Build Web Applications > Contexts for Actions on the View > JavaServer Faces Lifecycle Context

To select a graphic object in a view, 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.

<jvf:objectSelectInteractor id="objSelect"
     valueChangeListener="#{frameworkBean.selectObject}"
                 invocationContext="JSF_CONTEXT"/>

<jvf:view id="view"interactorId="objSelect" [...] />

Code Sample 6.19 Installing a Select Object Interactor and a Listener

Note
JSF_CONTEXT is the default value, so the invocationContext attribute could have been omitted.

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);
  }
}

Code Sample 6.20 Java Code of Value-Change Event

Note the following concerning the use of this method: