Project Wonder 5.0

er.coolcomponents
Class CCRating

java.lang.Object
  extended by com.webobjects.appserver.WOElement
      extended by com.webobjects.appserver.WODynamicElement
          extended by com.webobjects.appserver._private.WODynamicGroup
              extended by er.ajax.AjaxDynamicElement
                  extended by er.coolcomponents.CCRating
All Implemented Interfaces:
IAjaxElement

public class CCRating
extends AjaxDynamicElement

WebObjects wrapper for LivePipe Rating component, MIT license.

CCRating is a fully customizable CSS based ratings widget. By default it acts as an input. Alternatively, it can notify the server when the rating is changed, update the bound value, and call an action method.

It uses four (customizable) CSS class names to determine each link's state:

Example Usages

 Rating: CCRating {
     value = rating;
 }
 
 Rating: CCRating {
     value = rating;
     actAsInput = false;
 }
 
 Rating: CCRating {
     value = rating;
     actAsInput = false;
     action = rated;
 }
 
 Rating: CCRating {
     value = rating;
     min = 1;
     max = 10;
     multiple = true;
 }
 

See Also:
Control.Rating
Author:
chill (WebObjects wrapper only, not LivePipe Rating)
Bindings
value the value to show in the ratings widget and the value set when the user selects a different rating
           
actAsInput optional, default is true, if false updates the value binding when clicked and optionally calls action method
           
action optional, action method to fire when rating changed. Ignored if actAsInput is true or unbound
           
min optional, the value sent to the server when the lowest rating is selected, indirectly controls the number of rating points displayed
           
max optional, the value sent to the server when the highest rating is selected, indirectly controls the number of rating points displayed
           
multiple optional, true if the user can change a previous rating
           
id optional, HTML ID for the div and Control.Rating widget
           
capture optional, stops the click event on each rating from propagating
           
style optional CSS style for container element
           
class optional CSS class for container element in addition to the standard rating_container class
           
classNames optional, dictionary of state names and CSS class names with state names of: off, half, on, selected
           
rated optional, true if this has already been rated
           
reverse optional, true if the links should be shown in reverse order
           
updateOptions highly optional, Ajax Options for the request
           
formValueName optional, the name of the form value that will contain the value
           
elementName optional, defaults to div, the name of the HTML element to use to hold the rating UI
           
afterChange, optional, script to run client side after a change e.g. afterChange = "alert(v)";. Receives one parameter, v, the new value selected
           

Field Summary
 
Fields inherited from class er.ajax.AjaxDynamicElement
log
 
Fields inherited from class com.webobjects.appserver._private.WODynamicGroup
_children
 
Fields inherited from class com.webobjects.appserver.WODynamicElement
_ConstructorParameters
 
Constructor Summary
CCRating(String name, NSDictionary associations, WOElement children)
           
 
Method Summary
protected  boolean actAsInput(WOContext context)
           
protected  void addRequiredWebResources(WOResponse response, WOContext context)
          Override this method to append the needed scripts for this component.
 void appendToResponse(WOResponse response, WOContext context)
          Build div, optional input, and JavaScript into response.
protected  NSMutableDictionary createOptions(WOContext context)
          Produce dictionary for options object for Control.Rating.
protected  String formValueName(WOContext context)
           
 WOActionResults handleRequest(WORequest request, WOContext context)
          Handles server action if this is not being use as an input.
protected  String id(WOContext context)
           
protected  void setValueFromFormValue(WORequest request, WOContext context)
          Sets the value binding based on the form value.
 void takeValuesFromRequest(WORequest request, WOContext context)
          Sets value binding if this is being used as an input.
 
Methods inherited from class er.ajax.AjaxDynamicElement
_containerID, addScriptResourceInHead, addScriptResourceInHead, addStylesheetResourceInHead, addStylesheetResourceInHead, appendTagAttributeToResponse, associations, bindingNamed, booleanValueForBinding, hasBinding, invokeAction, setValueForBinding, shouldHandleRequest, stringValueForBinding, stringValueForBinding, valueForBinding, valueForBinding
 
Methods inherited from class com.webobjects.appserver._private.WODynamicGroup
addChildElement, appendChildrenToResponse, childrenElements, EmptyGroup, hasChildrenElements, invokeChildrenAction, takeChildrenValuesFromRequest, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CCRating

public CCRating(String name,
                NSDictionary associations,
                WOElement children)
Method Detail

addRequiredWebResources

protected void addRequiredWebResources(WOResponse response,
                                       WOContext context)
Description copied from class: AjaxDynamicElement
Override this method to append the needed scripts for this component.

Specified by:
addRequiredWebResources in class AjaxDynamicElement
context - the current context

appendToResponse

public void appendToResponse(WOResponse response,
                             WOContext context)
Build div, optional input, and JavaScript into response.

Overrides:
appendToResponse in class AjaxDynamicElement
Parameters:
response - the current response
context - the current context
See Also:
AjaxDynamicElement.appendToResponse(com.webobjects.appserver.WOResponse, com.webobjects.appserver.WOContext)

createOptions

protected NSMutableDictionary createOptions(WOContext context)
Produce dictionary for options object for Control.Rating.

Parameters:
context - WOContext providing component to resolve bindings in
Returns:
binding values converted into Ajax options

handleRequest

public WOActionResults handleRequest(WORequest request,
                                     WOContext context)
Handles server action if this is not being use as an input. Sets the value binding and calls the optional action method.

Specified by:
handleRequest in interface IAjaxElement
Specified by:
handleRequest in class AjaxDynamicElement
Parameters:
request - the current request
context - the current context
Returns:
null, this component returns nothing to the client
See Also:
AjaxDynamicElement.handleRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext), takeValuesFromRequest(WORequest, WOContext)

takeValuesFromRequest

public void takeValuesFromRequest(WORequest request,
                                  WOContext context)
Sets value binding if this is being used as an input.

Overrides:
takeValuesFromRequest in class AjaxDynamicElement
See Also:
AjaxDynamicElement.takeValuesFromRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext), handleRequest(WORequest, WOContext)

setValueFromFormValue

protected void setValueFromFormValue(WORequest request,
                                     WOContext context)
Sets the value binding based on the form value.

Parameters:
request - the WORequest to get the form values from
context - WOContext used to determine component used in
See Also:
takeValuesFromRequest(WORequest, WOContext), handleRequest(WORequest, WOContext)

formValueName

protected String formValueName(WOContext context)
Parameters:
context - WOContext used to determine component used in
Returns:
optional value for formValueName, or calculated value if unbound

id

protected String id(WOContext context)
Parameters:
context - WOContext used to determine component used in
Returns:
optional value for id, or calculated value if unbound

actAsInput

protected boolean actAsInput(WOContext context)
Parameters:
context - WOContext used to determine component used in
Returns:
optional value for actAsInput, or true if unbound

Last updated: Wed, Feb 22, 2012 • 07:00 AM EST

Copyright © 2002 – 2011 Project Wonder.