org.chenillekit.tapestry.core.components
Class RatingField<T>

java.lang.Object
  extended by org.apache.tapestry5.corelib.base.AbstractField
      extended by org.chenillekit.tapestry.core.components.RatingField<T>
All Implemented Interfaces:
ClientElement, Field

@Import(library={"../Chenillekit.js","Rating.js"},
        stylesheet="Rating.css")
public class RatingField<T>
extends AbstractField

This component provides the ability to associate a RadioGroup and its subordinate Radio fields with a set of values displayed as a rating scale. This is typified by the "star field" where grayed stars represent the choices and highlighted stars represent the chosen value and all values up to the chosen value from left to right.

This is in fact that default visual appearance. However, the images can be overridden via parameters and the entire component can, of course, be styled via CSS.

As an added benefit, since the underlying representation is simply a RadioGroup with Radio fields it should degrade well when JS and/or CSS is disabled. This should keep the component rather accessible.

By default the first value display image will be hidden as this typically will indicate no value.

Version:
$Id: RatingField.java 674 2010-07-29 12:47:25Z homburgs $

Constructor Summary
RatingField()
           
 
Method Summary
 void afterRender(MarkupWriter writer)
           
protected  void configure(JSONObject options)
          Invoked to allow subclasses to further configure the parameters passed to this component's javascript options.
 ValueEncoder getEncoder()
          Returns an appropriate ValueEncoder implementation based on the value type.
 String getRadioLabel()
          Returns a reasonable label for the radio value.
 Asset getSelectedImage()
          Returns the image representing a selected value.
 Asset getUnselectedImage()
          Returns the image representing an unselected value.
protected  void processSubmission(String elementName)
          Method implemented by subclasses to actually do the work of processing the submission of the form.
 
Methods inherited from class org.apache.tapestry5.corelib.base.AbstractField
createDefaultParameterBinding, decorateInsideField, getClientId, getControlName, getLabel, isDisabled, isRequired, putPropertyNameIntoBeanValidationContext, removePropertyNameFromBeanValidationContext, setDecorator, setFormSupport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RatingField

public RatingField()
Method Detail

getUnselectedImage

public Asset getUnselectedImage()
Returns the image representing an unselected value.

Returns:

getSelectedImage

public Asset getSelectedImage()
Returns the image representing a selected value.

Returns:

getEncoder

public ValueEncoder getEncoder()
Returns an appropriate ValueEncoder implementation based on the value type.

Returns:

getRadioLabel

public String getRadioLabel()
Returns a reasonable label for the radio value. If the value is primitive it will be returned as is. Otherwise the toString() method will be called on the value object.

Returns:

processSubmission

protected void processSubmission(String elementName)
Method implemented by subclasses to actually do the work of processing the submission of the form. The element's elementName property will already have been set. This method is only invoked if the field is not disabled.

Specified by:
processSubmission in class AbstractField
Parameters:
elementName - the name of the element (used to find the correct parameter in the request)

afterRender

public void afterRender(MarkupWriter writer)

configure

protected void configure(JSONObject options)
Invoked to allow subclasses to further configure the parameters passed to this component's javascript options. Subclasses may override this method to configure additional features of the Window.

This implementation does nothing.

Parameters:
options - windows option object


Copyright © 2008-2010 ChenilleKit. All Rights Reserved.