net.sf.tacos.components.dojo
Class DojoWidget

java.lang.Object
  extended by org.apache.hivemind.impl.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.dojo.AbstractWidget
              extended by net.sf.tacos.components.dojo.GenericWidget
                  extended by net.sf.tacos.components.dojo.DojoWidget
All Implemented Interfaces:
IDojoContainer, Locatable, LocationHolder, org.apache.tapestry.dojo.IWidget, org.apache.tapestry.IComponent, org.apache.tapestry.IDirect, org.apache.tapestry.IDirectEvent, org.apache.tapestry.IDynamicInvoker, org.apache.tapestry.internal.Component, org.apache.tapestry.IRender

public abstract class DojoWidget
extends GenericWidget
implements IDojoContainer, org.apache.tapestry.IDirect

Implementation of any dojo widget as a tapestry component. The formal parameter dojoType is used to determine which dojo widget to create. Informal parameters are used as javascript properties to create widget with. Please have a look into the http://dojotoolkit.org/api for further information about the widget properties. A simple example is the dojo Clock widget:

<div jwcid="@dojo:Widget" dojoType="Clock" timeZoneOffset="5" labelColor="#fff"/>

The formal parameter isContainer allows a widget to have children. All the widgets within the body of a container are added as childs. For example dojo tabs:

<div jwcid="@dojo:Widget" dojoType="TabContainer" isContainer="true">
        <div jwcid="@dojo:Widget" dojoType="ContentPane" label="Athens">Athens</div>
        <div jwcid="@dojo:Widget" dojoType="ContentPane" label="Moscow">Moscow</div>
</div>

DojoWidget allows you to connect any client side event to a listener method. Please see the dojo api for further information about the events fired by the particular widget. To connect a client side even just use the informal parameter with the corresponding name. For example, specifying a component definition such as:

 <div jwcid="@dojo:Widget" dojoType="..." onClick="listener:onClick" onMouseDown="listener:onMouseDown"/>
 

It's possible to specify a list of events for which to generate non async requests specifying the dojo events list in the noAsync parameter as a comma separated list. This is particularly useful with menu/button widget that most of the times need normal requests to be generated.

 <div jwcid="@dojo:Widget" dojoType="MenuItem2" onClick="listener:onMenuClick" noAsync="onClick"/>
 

Furthermore it is poossible to connect a client side event to a javascript function. For this purpose use the prefix callback. For example:

 <div jwcid="@dojo:Widget" dojoType="SliderHorizontal" onValueChanged="callback:sliderCallback"/>
 

Whereby sliderCallback is a javascript function:

  function sliderCallback(value) {
        alert(value);
  }
 

Since:
4.1.0

Field Summary
static String CONTAINER_ATTRIBUTE
           
 
Fields inherited from class org.apache.tapestry.AbstractComponent
_body, _bodyCount
 
Constructor Summary
DojoWidget()
           
 
Method Summary
 void addChild(org.apache.tapestry.dojo.IWidget widget)
          Adds a child IWidget to a container.
 Map getAsyncListenerBindings()
          Returns a Map of the bindings implementing the IActionListener interface for which to generate async requests.
protected  Map getBindingsByClass(Collection names, Class clazz)
          Filters the Map of the bindings of the component and returns a Map of bindings the specified Class parameter is assignable from.
 Map getCallbackBindings()
          Returns a Map of the bindings implementing the ICallbackFunction interface.
abstract  List getChildren()
          Returns a list of children widgetIds.
 boolean getContainerState()
          If the current component is a container.
abstract  String getDojoType()
          Returns the type of the dojo widget
abstract  org.apache.tapestry.engine.IEngineService getEngine()
          Injected engine service .
 Map getListenerBindings()
          Returns a Map of the bindings implementing the IActionListener interface for which to generate non async requests.
abstract  org.apache.tapestry.listener.ListenerInvoker getListenerInvoker()
          Injected listener invoker.
abstract  String getNoAsync()
          Returns widget events for which to generate no async requests
 String getNoAsyncEventUrl(String eventName)
          Returns the url to use for a non async event
abstract  Object getParameters()
          Returns listener parameters
abstract  org.apache.tapestry.IScript getScript()
          Injected script.
abstract  String getStyle()
          Returns the style.
 void renderWidget(org.apache.tapestry.IMarkupWriter writer, org.apache.tapestry.IRequestCycle cycle)
          
 void trigger(org.apache.tapestry.IRequestCycle cycle)
          Invoked by the direct service to trigger the application-specific action by notifying the listener.
 
Methods inherited from class net.sf.tacos.components.dojo.GenericWidget
getIsContainer, getNeverDestroy, renderComponent
 
Methods inherited from class org.apache.tapestry.dojo.AbstractWidget
getDestroy, setDestroy
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, checkActiveLock, cleanupAfterRender, enterActiveState, equals, finishLoad, finishLoad, generateClientId, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getBoundId, getClientId, getComponent, getComponents, getContainedComponent, getContainedRenderers, getContainer, getEventInvoker, getExtendedId, getId, getIdPath, getInnerRenderers, getListeners, getMessages, getNamespace, getPage, getRenderWorker, getSpecification, getSpecifiedId, getTemplateTagName, hasEvents, hashCode, isInActiveState, isParameterBound, isRendering, isStateful, pageEndRender, peekClientId, prepareForRender, render, renderBody, renderIdAttribute, renderInformalParameters, setBinding, setClientId, setContainedComponent, setContainer, setHasEvents, setId, setNamespace, setPage, setTemplateTagName, toString, triggerEvent
 
Methods inherited from class org.apache.hivemind.impl.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.IDirect
isStateful
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, enterActiveState, finishLoad, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getClientId, getComponent, getComponents, getContainedComponent, getContainer, getEventInvoker, getExtendedId, getId, getIdPath, getListeners, getMessages, getNamespace, getPage, getSpecification, getSpecifiedId, getTemplateTagName, isRendering, peekClientId, renderBody, setBinding, setClientId, setContainedComponent, setContainer, setId, setNamespace, setPage, setTemplateTagName
 
Methods inherited from interface org.apache.tapestry.IRender
render
 
Methods inherited from interface org.apache.hivemind.LocationHolder
setLocation
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 
Methods inherited from interface org.apache.tapestry.IDynamicInvoker
getUpdateComponents, isAsync, isJson
 
Methods inherited from interface org.apache.tapestry.IDirectEvent
isStateful, triggerEvent
 

Field Detail

CONTAINER_ATTRIBUTE

public static final String CONTAINER_ATTRIBUTE
Constructor Detail

DojoWidget

public DojoWidget()
Method Detail

getContainerState

public boolean getContainerState()
If the current component is a container.
If the user has defined a value for 'isContainer', then that is used. Otherwise, several rules are used to determine if the component is a valid container. The rules are:

Overrides:
getContainerState in class GenericWidget

renderWidget

public void renderWidget(org.apache.tapestry.IMarkupWriter writer,
                         org.apache.tapestry.IRequestCycle cycle)

Specified by:
renderWidget in interface org.apache.tapestry.dojo.IWidget

addChild

public void addChild(org.apache.tapestry.dojo.IWidget widget)
Adds a child IWidget to a container.

Specified by:
addChild in interface IDojoContainer
Parameters:
widget - child to add

getListenerBindings

public Map getListenerBindings()
Returns a Map of the bindings implementing the IActionListener interface for which to generate non async requests.


getAsyncListenerBindings

public Map getAsyncListenerBindings()
Returns a Map of the bindings implementing the IActionListener interface for which to generate async requests.


getCallbackBindings

public Map getCallbackBindings()
Returns a Map of the bindings implementing the ICallbackFunction interface.


getBindingsByClass

protected Map getBindingsByClass(Collection names,
                                 Class clazz)
Filters the Map of the bindings of the component and returns a Map of bindings the specified Class parameter is assignable from.

Parameters:
names - names of the bindings
clazz - class to determine if it is assignable from the bindings

getNoAsyncEventUrl

public String getNoAsyncEventUrl(String eventName)
Returns the url to use for a non async event


trigger

public void trigger(org.apache.tapestry.IRequestCycle cycle)
Invoked by the direct service to trigger the application-specific action by notifying the listener.

Specified by:
trigger in interface org.apache.tapestry.IDirect

getScript

public abstract org.apache.tapestry.IScript getScript()
Injected script.


getEngine

public abstract org.apache.tapestry.engine.IEngineService getEngine()
Injected engine service .


getListenerInvoker

public abstract org.apache.tapestry.listener.ListenerInvoker getListenerInvoker()
Injected listener invoker.


getStyle

public abstract String getStyle()
Returns the style.


getDojoType

public abstract String getDojoType()
Returns the type of the dojo widget


getParameters

public abstract Object getParameters()
Returns listener parameters


getNoAsync

public abstract String getNoAsync()
Returns widget events for which to generate no async requests


getChildren

public abstract List getChildren()
Returns a list of children widgetIds. The list is always empty if GenericWidget.getIsContainer() returns false.



Copyright © 2005-2008 SourceForge.net. All Rights Reserved.