org.nakedobjects.plugins.headless.applib
Interface HeadlessViewer


public interface HeadlessViewer

Provides the ability to obtain a "view" of a domain object such that it can be interacted with as if through a viewer.

The "view" is a CGLib proxy that wraps the underlying domain object. The view can then be interacted with as follows:

Calling any of the above methods may result in a (subclass of) InteractionException if the object disallows it. For example, if a property is annotated with Hidden then a HiddenException will be thrown. Similarly if an action has a validate method and the supplied arguments are invalid then a InvalidException will be thrown.

In addition, the following methods may also be called:

An exception will be thrown if any other methods are thrown.


Nested Class Summary
static class HeadlessViewer.ExecutionMode
          Whether interactions with the view are actually passed onto the underlying domain object.
 
Method Summary
 boolean addInteractionListener(InteractionListener listener)
          Registers an InteractionListener, to be notified of interactions on all views.
 java.util.List<InteractionListener> getListeners()
          All InteractionListeners that have been registered using addInteractionListener(InteractionListener).
<T> boolean
isView(T possibleView)
          Whether the supplied object has been viewed.
 void notifyListeners(InteractionEvent ev)
           
 boolean removeInteractionListener(InteractionListener listener)
          Remove an InteractionListener, to no longer be notified of interactions on views.
<T> T
view(T domainObject)
          Provides the "view" of the underlying domain object.
<T> T
view(T domainObject, HeadlessViewer.ExecutionMode mode)
          Same as view(Object), except the actual execution occurs only if the execute parameter indicates.
 

Method Detail

view

<T> T view(T domainObject)
Provides the "view" of the underlying domain object.

If the object has (see isView(Object) already been viewed), then should just return the object back unchanged.

See Also:
addInteractionListener(InteractionListener)

view

<T> T view(T domainObject,
           HeadlessViewer.ExecutionMode mode)
Same as view(Object), except the actual execution occurs only if the execute parameter indicates.

Otherwise, will do all the validations (raise exceptions as required etc.), but doesn't modify the model.


isView

<T> boolean isView(T possibleView)
Whether the supplied object has been viewed.

Type Parameters:
T -
Parameters:
possibleView - - object that might or might not be a view.
Returns:

getListeners

java.util.List<InteractionListener> getListeners()
All InteractionListeners that have been registered using addInteractionListener(InteractionListener).


addInteractionListener

boolean addInteractionListener(InteractionListener listener)
Registers an InteractionListener, to be notified of interactions on all views.

This is retrospective: the listener will be notified of interactions even on views created before the listener was installed. (From an implementation perspective this is because the views delegate back to the container to fire the events).

Parameters:
listener -
Returns:

removeInteractionListener

boolean removeInteractionListener(InteractionListener listener)
Remove an InteractionListener, to no longer be notified of interactions on views.

This is retrospective: the listener will no longer be notified of any interactions created on any views, not just on those views created subsequently. (From an implementation perspective this is because the views delegate back to the container to fire the events).

Parameters:
listener -
Returns:

notifyListeners

void notifyListeners(InteractionEvent ev)


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.