org.apache.tapestry.scriptaculous
Class Suggest

java.lang.Object
  extended by org.apache.hivemind.impl.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.form.AbstractFormComponent
              extended by org.apache.tapestry.scriptaculous.Suggest
All Implemented Interfaces:
org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder, IFormComponent, TranslatedField, ValidatableField, IComponent, IDirect, IDirectEvent, IDynamicInvoker, Component, IRender

public abstract class Suggest
extends AbstractFormComponent
implements TranslatedField, IDirect

Implementation of the Ajax.Autocompleter in the form of a TextField like component with the additional ability to dynamically suggest values via XHR requests.

This component will use the html element tag name defined in your html template to include it to determine whether or not to render a TextArea or TextField style input element. For example, specifying a component definition such as:

<input jwcid="@Suggest" value="literal:A default value" />

would render something looking like:

<input type="text" name="suggest" id="suggest" autocomplete="off" value="literal:A default value" />

while a defintion of

<textarea jwcid="@Suggest" value="literal:A default value" />

would render something like:

  <textarea name="suggest" id="suggest" >A default value<textarea/>
 


Field Summary
 
Fields inherited from class org.apache.tapestry.AbstractComponent
_body, _bodyCount
 
Constructor Summary
Suggest()
           
 
Method Summary
protected  void finishLoad()
          Sets the default ListItemRenderer for component, to be overriden as necessary by component parameters.
abstract  IEngineService getEngineService()
          Injected.
abstract  IActionListener getListener()
           
abstract  ListenerInvoker getListenerInvoker()
          Injected service used to invoke whatever listeners people have setup to handle changing value from this field.
abstract  ListItemRenderer getListItemRenderer()
           
abstract  Object getListSource()
           
abstract  int getMaxResults()
           
abstract  String getOptions()
           
abstract  Object getParameters()
           
abstract  ResponseBuilder getResponse()
          Injected response builder for doing specific XHR things.
abstract  IScript getScript()
          Associated javascript template.
abstract  TranslatedFieldSupport getTranslatedFieldSupport()
          Injected.
 List getUpdateComponents()
          If set, will be used to update/refresh portions of a response during XHR requests.
abstract  String getUpdateElementClass()
           
abstract  ValidatableFieldSupport getValidatableFieldSupport()
          Injected.
abstract  Object getValue()
           
abstract  ValueConverter getValueConverter()
          Used to convert form input values.
 boolean isAsync()
          Used to specify whether or not the result of this invocation should be returned asynchronously or use normal browser page reload semantics.
 boolean isJson()
          Used to specify that the return invocation of the response created should be in the "http://json.org" format.
 boolean isRequired()
          Returns false.
abstract  boolean isSearchTriggered()
          Used internally to track listener invoked searches versus normal rendering requests.
protected  void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
          Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle) to actually render the component (with any parameter values already set).
protected  void renderFormComponent(IMarkupWriter writer, IRequestCycle cycle)
          Invoked from AbstractFormComponent.renderComponent(IMarkupWriter, IRequestCycle) to render the component.
 void renderList(IMarkupWriter writer, IRequestCycle cycle)
          Invoked only when a search has been triggered to render out the <li> list of dynamic suggestion options.
protected  void rewindFormComponent(IMarkupWriter writer, IRequestCycle cycle)
          Rewinds the component, doing translation, validation and binding.
abstract  void setListItemRenderer(ListItemRenderer renderer)
           
abstract  void setListSource(Object value)
           
abstract  void setSearchTriggered(boolean value)
           
abstract  void setValue(Object value)
           
 void trigger(IRequestCycle cycle)
          Triggers the listener.
 
Methods inherited from class org.apache.tapestry.form.AbstractFormComponent
generateClientId, getCanTakeFocus, getForm, getIdParameter, getName, getRenderBodyOnRewind, peekClientId, renderDelegateAttributes, renderDelegatePrefix, renderDelegateSuffix, setForm, setName, setName
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, checkActiveLock, cleanupAfterRender, enterActiveState, equals, finishLoad, 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, 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.form.TranslatedField
getTranslator
 
Methods inherited from interface org.apache.tapestry.form.ValidatableField
getValidators
 
Methods inherited from interface org.apache.tapestry.form.IFormComponent
getClientId, getDisplayName, getForm, getName, isDisabled, setName
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, enterActiveState, finishLoad, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, 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.IDirect
isStateful
 

Constructor Detail

Suggest

public Suggest()
Method Detail

getListenerInvoker

public abstract ListenerInvoker getListenerInvoker()
Injected service used to invoke whatever listeners people have setup to handle changing value from this field.

Returns:
The invoker.

getResponse

public abstract ResponseBuilder getResponse()
Injected response builder for doing specific XHR things.

Returns:
ResponseBuilder for this request.

getScript

public abstract IScript getScript()
Associated javascript template.

Returns:
The script template.

getValueConverter

public abstract ValueConverter getValueConverter()
Used to convert form input values.

Returns:
The value converter to use.

getValidatableFieldSupport

public abstract ValidatableFieldSupport getValidatableFieldSupport()
Injected.

Returns:
Service used to validate input.

getTranslatedFieldSupport

public abstract TranslatedFieldSupport getTranslatedFieldSupport()
Injected.

Returns:
Translation service.

getEngineService

public abstract IEngineService getEngineService()
Injected.

Returns:
The DirectService engine.

getValue

public abstract Object getValue()

setValue

public abstract void setValue(Object value)

getListItemRenderer

public abstract ListItemRenderer getListItemRenderer()

setListItemRenderer

public abstract void setListItemRenderer(ListItemRenderer renderer)

getListener

public abstract IActionListener getListener()

getListSource

public abstract Object getListSource()

setListSource

public abstract void setListSource(Object value)

getMaxResults

public abstract int getMaxResults()

getParameters

public abstract Object getParameters()

getOptions

public abstract String getOptions()

getUpdateElementClass

public abstract String getUpdateElementClass()

isSearchTriggered

public abstract boolean isSearchTriggered()
Used internally to track listener invoked searches versus normal rendering requests.

Returns:
True if search was triggered, false otherwise.

setSearchTriggered

public abstract void setSearchTriggered(boolean value)

isRequired

public boolean isRequired()
Description copied from class: AbstractFormComponent
Returns false. Subclasses that might be required must override this method. Typically, this involves checking against the component's validators.

Specified by:
isRequired in interface IFormComponent
Overrides:
isRequired in class AbstractFormComponent

renderComponent

protected void renderComponent(IMarkupWriter writer,
                               IRequestCycle cycle)
Description copied from class: AbstractFormComponent
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle) to actually render the component (with any parameter values already set). This implementation checks the rewinding state of the IForm that contains the component and forwards processing to either AbstractFormComponent.renderFormComponent(IMarkupWriter, IRequestCycle) or AbstractFormComponent.rewindFormComponent(IMarkupWriter, IRequestCycle). Those two are the methods that subclasses should implement.

Overrides:
renderComponent in class AbstractFormComponent
See Also:
AbstractComponent.renderComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)

renderList

public void renderList(IMarkupWriter writer,
                       IRequestCycle cycle)
Invoked only when a search has been triggered to render out the <li> list of dynamic suggestion options.

Parameters:
writer - The markup writer.
cycle - The associated request.

renderFormComponent

protected void renderFormComponent(IMarkupWriter writer,
                                   IRequestCycle cycle)
Description copied from class: AbstractFormComponent
Invoked from AbstractFormComponent.renderComponent(IMarkupWriter, IRequestCycle) to render the component.

Specified by:
renderFormComponent in class AbstractFormComponent

rewindFormComponent

protected void rewindFormComponent(IMarkupWriter writer,
                                   IRequestCycle cycle)
Rewinds the component, doing translation, validation and binding.

Specified by:
rewindFormComponent in class AbstractFormComponent

trigger

public void trigger(IRequestCycle cycle)
Triggers the listener. The parameters passed are the current text and those specified in the parameters parameter of the component. If the listener parameter is not bound, attempt to locate an implicit listener named by the capitalized component id, prefixed by "do".

Specified by:
trigger in interface IDirect
Parameters:
cycle - The current request.

getUpdateComponents

public List getUpdateComponents()
Description copied from interface: IDynamicInvoker
If set, will be used to update/refresh portions of a response during XHR requests.

For instance, if you have a page listing projects and you wanted to update an Any components contents whenever one of the project links was clicked you would use a DirectLink with the parameters:

      updateComponents="{'projectDetails'}"
      async="true"
 

Specified by:
getUpdateComponents in interface IDynamicInvoker
Returns:
The list of components to update, if any.

isAsync

public boolean isAsync()
Description copied from interface: IDynamicInvoker
Used to specify whether or not the result of this invocation should be returned asynchronously or use normal browser page reload semantics.

Async being true means responses will be encoded as XML using XmlHttpRequests. If you would like your request/response to be in another format - like JSON - you must also specify the additional parameter IDynamicInvoker.isJson(). Without setting the IDynamicInvoker.getUpdateComponents() parameter this parameter is pretty useless.

Specified by:
isAsync in interface IDynamicInvoker
Returns:
True if invocation should be processed asynchronously.
See Also:
IDynamicInvoker.isJson()

isJson

public boolean isJson()
Description copied from interface: IDynamicInvoker
Used to specify that the return invocation of the response created should be in the "http://json.org" format. Without setting the IDynamicInvoker.getUpdateComponents() parameter this parameter is pretty useless.

Specified by:
isJson in interface IDynamicInvoker
Returns:
True if response should be encoded using JSON semantics.
See Also:
org.apache.tapestry.IJSONRender}

finishLoad

protected void finishLoad()
Sets the default ListItemRenderer for component, to be overriden as necessary by component parameters.

Overrides:
finishLoad in class AbstractComponent


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.