org.apache.cocoon.forms.formmodel
Class ImageMap

java.lang.Object
  extended by org.apache.cocoon.forms.formmodel.AbstractWidget
      extended by org.apache.cocoon.forms.formmodel.ImageMap
All Implemented Interfaces:
ActionListenerEnabled, Widget, Locatable

public class ImageMap
extends AbstractWidget
implements ActionListenerEnabled

A server-side map widget. An ImageMap widget can cause a ImageMapEvent to be triggered on the server side, which will be handled by either the event handlers defined in the form definition, and/or by the FormHandler registered with the form, if any. An ImageMap widget is basically an Action widget displayed as an image and with mouse coordinates stored upon clicking. The image's URI can be set or get, or bind via the binding framework, mouse coordinates can be either retrieved from the ImageMapEvent triggered or from the widget itself.

Since:
2.1.8
Version:
$Id: ImageMap.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
static String COMMAND_AT
           
static String IMAGEMAP_EL
           
static String ONACTION_EL
           
static String VALUE_EL
           
 
Fields inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget
wasValid
 
Fields inherited from interface org.apache.cocoon.forms.formmodel.Widget
PATH_SEPARATOR
 
Constructor Summary
ImageMap(ImageMapDefinition definition)
           
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds an ActionListener to this widget instance.
 void broadcastEvent(WidgetEvent event)
          Broadcast an event previously queued by this widget to its event listeners.
 WidgetDefinition getDefinition()
          Concrete subclasses should allow access to their underlaying Definition through this method.
 String getImageURI()
           
 Object getValue()
          Get the value of a widget.
 int getX()
           
 AttributesImpl getXMLElementAttributes()
          Adds the @imageuri attribute to the XML element
 String getXMLElementName()
          The XML element name used in AbstractWidget.generateSaxFragment(ContentHandler, Locale) to produce the wrapping element for all the XML-instance-content of this Widget.
 int getY()
           
protected  void handleActivate()
          Handle the fact that this action was activated.
 void readFromRequest(FormContext formContext)
          Lets this widget read its data from a request.
 void removeActionListener(ActionListener listener)
           
 void setImageURI(String newImgURI)
           
 void setValue(Object newImgURI)
          Sets the value of this widget.
 boolean validate()
          Always return true (an action has no validation)
 
Methods inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget
addValidator, generateDisplayData, generateItemSaxFragment, generateLabel, generateSaxFragment, getAttribute, getChild, getCombinedState, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getWidget, initialize, isRequired, isValid, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState, toString, widgetNameChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMAND_AT

public static final String COMMAND_AT
See Also:
Constant Field Values

VALUE_EL

public static final String VALUE_EL
See Also:
Constant Field Values

ONACTION_EL

public static final String ONACTION_EL
See Also:
Constant Field Values

IMAGEMAP_EL

public static final String IMAGEMAP_EL
See Also:
Constant Field Values
Constructor Detail

ImageMap

public ImageMap(ImageMapDefinition definition)
Method Detail

getDefinition

public WidgetDefinition getDefinition()
Description copied from class: AbstractWidget
Concrete subclasses should allow access to their underlaying Definition through this method. If subclasses decide to return null they should also organize own implementations of AbstractWidget.getId(), AbstractWidget.getLocation(), AbstractWidget.validate(), AbstractWidget.generateLabel(ContentHandler) and AbstractWidget.generateDisplayData(ContentHandler) to avoid NPE's.

Specified by:
getDefinition in interface Widget
Specified by:
getDefinition in class AbstractWidget
Returns:
the widgetDefinition from which this widget was instantiated. (See WidgetDefinition.createInstance())

getX

public int getX()

getY

public int getY()

getImageURI

public String getImageURI()

setImageURI

public void setImageURI(String newImgURI)

setValue

public void setValue(Object newImgURI)
Description copied from interface: Widget
Sets the value of this widget.

Not all widgets do have a value (notably ContainerWidgets, but this method is provided here as a convenience to ease writing and avoiding casts.

Specified by:
setValue in interface Widget
Overrides:
setValue in class AbstractWidget
Parameters:
newImgURI - the new widget's value.

getValue

public Object getValue()
Description copied from interface: Widget
Get the value of a widget.

Not all widgets do have a value (notably ContainerWidgets, but this method is provided here as a convenience to ease writing and avoiding casts.

Specified by:
getValue in interface Widget
Overrides:
getValue in class AbstractWidget
Returns:
the value of the widget.

readFromRequest

public void readFromRequest(FormContext formContext)
Description copied from interface: Widget
Lets this widget read its data from a request. At this point the Widget may try to convert the request parameter to its native datatype (if it is not a string), but it should not yet generate any validation errors.

Specified by:
readFromRequest in interface Widget

getXMLElementAttributes

public AttributesImpl getXMLElementAttributes()
Adds the @imageuri attribute to the XML element

Overrides:
getXMLElementAttributes in class AbstractWidget
Returns:
the attributes for the main element for this widget's sax-fragment.

handleActivate

protected void handleActivate()
Handle the fact that this action was activated. The default here is to end the current form processing and redisplay the form, which means that actual behaviour should be implemented in event listeners.


validate

public boolean validate()
Always return true (an action has no validation)

Specified by:
validate in interface Widget
Overrides:
validate in class AbstractWidget
Returns:
true to indicate all validations were ok, false otherwise
See Also:
Widget.validate()

getXMLElementName

public String getXMLElementName()
Description copied from class: AbstractWidget
The XML element name used in AbstractWidget.generateSaxFragment(ContentHandler, Locale) to produce the wrapping element for all the XML-instance-content of this Widget.

Specified by:
getXMLElementName in class AbstractWidget
Returns:
the main elementname for this widget's sax-fragment.

addActionListener

public void addActionListener(ActionListener listener)
Adds an ActionListener to this widget instance. Listeners defined on the widget instance will be executed in addtion to any listeners that might have been defined in the widget definition.

Specified by:
addActionListener in interface ActionListenerEnabled

removeActionListener

public void removeActionListener(ActionListener listener)
Specified by:
removeActionListener in interface ActionListenerEnabled

broadcastEvent

public void broadcastEvent(WidgetEvent event)
Description copied from class: AbstractWidget
Broadcast an event previously queued by this widget to its event listeners. Abstract implementation throws a UnsupportedOperationException. Concrete subclass widgets need to override when supporting event broadcasting.

Specified by:
broadcastEvent in interface Widget
Overrides:
broadcastEvent in class AbstractWidget


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.