com.sun.webui.jsf.component
Class Rating

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIOutput
              extended by javax.faces.component.UIInput
                  extended by com.sun.webui.jsf.component.WebuiInput
                      extended by com.sun.webui.jsf.component.Rating
All Implemented Interfaces:
javax.faces.component.EditableValueHolder, javax.faces.component.StateHolder, javax.faces.component.ValueHolder

public class Rating
extends WebuiInput

The Rating component presents a row of stars indicating a rating assigned to an item. When the user assigns a new rating to an item, an Ajax request transmits the rating to the server. The rows of stars can also indicate the average rating of all users.


Field Summary
static int CLEAR_GRADE
          The value of a grade when it is marked "cleared".
static int NOT_INTERESTED_GRADE
          The value of a grade when it is marked "not interested".
 
Fields inherited from class javax.faces.component.UIInput
COMPONENT_FAMILY, COMPONENT_TYPE, CONVERSION_MESSAGE_ID, REQUIRED_MESSAGE_ID, UPDATE_MESSAGE_ID
 
Constructor Summary
Rating()
          Creates a new instance of Rating
 
Method Summary
 double getAverageGrade()
          Get the average grade the general user population has assigned to the item.
 java.lang.String getClearAcknowledgedText()
          Returns the acknowledged text for the clear control.
 java.lang.String getClearHoverText()
          Returns the hover text for the clear control.
 java.lang.String getFamily()
          Return the family for this component.
 int getGrade()
          Return the grade (number of "stars") the user has assigned the item.
 java.lang.String getGradeAcknowledgedText()
          Returns the acknowledged text for the grade controls.
 java.lang.String[] getGradeHoverTexts()
          Returns the hover texts that are used for the grade controls, ordered from lowest to highest rating.
 int getMaxGrade()
          Return the maximum grade (number of "stars") this rating instance allows.
 java.lang.String[] getModeToggleAcknowledgedTexts()
          Returns the acknowledged texts that are used for the mode toggle control.
 java.lang.String[] getModeToggleHoverTexts()
          Returns the hover texts that are used for the mode toggle control.
 java.lang.String getNotInterestedAcknowledgedText()
          Returns the acknowledged text for the "not interested" control.
 java.lang.String getNotInterestedHoverText()
          Returns the hover text for the "not interested" control.
 java.lang.String getRendererType()
           
 java.lang.String getStyle()
          CSS style or styles to be applied to the outermost HTML element when this component is rendered.
 java.lang.String getStyleClass()
          CSS style class or classes to be applied to the outermost HTML element when this component is rendered.
 int getTabIndex()
          Return the position of this element in the tabbing order.
 java.lang.Object getValue()
           
 javax.el.ValueExpression getValueExpression(java.lang.String name)
          Return the ValueExpression stored for the specified name (if any), respecting any property aliases.
 boolean isAutoSubmit()
          Return true if the grade is automatically submitted to the server via an Ajax request immediately after the grade is selected, false if not.
 boolean isGradeReadOnly()
          Return true if the grade of this rating component can be changed by the user.
 boolean isInAverageMode()
          Return true if the component is rendered displaying the average grade, false if component is rendered displaying the user's grade (normal mode).
 boolean isIncludeClear()
          Return true if a control to clear the user's rating is rendered, false if not.
 boolean isIncludeModeToggle()
          Return true if a control to toggle the mode (to show the average rating or the user's rating) is rendered, false if not.
 boolean isIncludeNotInterested()
          Return true if a control to allow the user to assign a "not interested" rating is rendered, false if not.
 boolean isIncludeText()
          Return true if an area to show hover text or post-click acknowledged text is rendered, false if not.
 boolean isModeReadOnly()
          Return true if the mode of this rating component can be changed by the user (via the mode toggle control), false if not
 boolean isVisible()
          Use to indicate whether the component should be viewable by the user in the rendered HTML page.
 void restoreState(javax.faces.context.FacesContext _context, java.lang.Object _state)
          Restore the state of this component.
 java.lang.Object saveState(javax.faces.context.FacesContext _context)
          Save the state of this component.
 void setAutoSubmit(boolean autoSubmit)
          Set whether the grade is automatically submitted to the server via an Ajax request immediately after the grade is selected.
 void setAverageGrade(double averageGrade)
          Set the average grade the general user population has assigned to the item.
 void setClearAcknowledgedText(java.lang.String clearAcknowledgedText)
          Set the acknowledged text for the clear control.
 void setClearHoverText(java.lang.String clearHoverText)
          Set the hover text for the clear control.
 void setGrade(int grade)
          Set the grade (number of "stars") the user has assigned the item.
 void setGradeAcknowledgedText(java.lang.String gradeAcknowledgedText)
          Set the acknowledged text for the grade controls.
 void setGradeHoverTexts(java.lang.String[] gradeHoverTexts)
          Set the hover texts that will be used for the grade controls, ordered from lowest to highest rating.
 void setGradeReadOnly(boolean gradeReadOnly)
          Set whether the grade of this rating component can be changed by the user.
 void setInAverageMode(boolean inAverageMode)
          Set whether the component will be rendered displaying the average grade.
 void setIncludeClear(boolean includeClear)
          Set whether a control to clear the user's rating should be displayed.
 void setIncludeModeToggle(boolean includeModeToggle)
          Set whether a control to toggle the mode (to show the average rating or the user's rating) should be rendered.
 void setIncludeNotInterested(boolean includeNotInterested)
          Set whether a control to allow the user to assign a "not interested" rating should be rendered.
 void setIncludeText(boolean includeText)
          Set whether an area for hover or post-click acknowledged text should be rendered.
 void setMaxGrade(int maxGrade)
          Set the maximum grade (number of "stars") this rating instance allows.
 void setModeReadOnly(boolean modeReadOnly)
          Set whether the mode of this rating component can be changed by the user (via the mode toggle control).
 void setModeToggleAcknowledgedTexts(java.lang.String[] modeToggleAcknowledgedTexts)
          Sets the acknowledged texts to be used for the mode toggle control.
 void setModeToggleHoverTexts(java.lang.String[] modeToggleHoverTexts)
          Sets the hover texts to be used for the mode toggle control.
 void setNotInterestedAcknowledgedText(java.lang.String notInterestedAcknowledgedText)
          Set the acknowledged text for the "not interested" control.
 void setNotInterestedHoverText(java.lang.String notInterestedHoverText)
          Set the hover text for the "not interested" control.
 void setStyle(java.lang.String style)
          CSS style or styles to be applied to the outermost HTML element when this component is rendered.
 void setStyleClass(java.lang.String styleClass)
          CSS style class or classes to be applied to the outermost HTML element when this component is rendered.
 void setTabIndex(int tabIndex)
          Set the position of this element in the tabbing order.
 void setValueExpression(java.lang.String name, javax.el.ValueExpression binding)
          Set the ValueExpression stored for the specified name (if any), respecting any property aliases.
 void setVisible(boolean visible)
          Use to indicate whether the component should be viewable by the user in the rendered HTML page.
 
Methods inherited from class com.sun.webui.jsf.component.WebuiInput
broadcast, getValidator, getValidatorExpression, getValueChangeListener, getValueChangeListenerExpression, processDecodes, processUpdates, processValidators, setConverter, setId, setImmediate, setRendered, setRequired, setValidatorExpression, setValueChangeListenerExpression
 
Methods inherited from class javax.faces.component.UIInput
addValidator, addValueChangeListener, decode, getConverterMessage, getRequiredMessage, getSubmittedValue, getValidatorMessage, getValidators, getValueChangeListeners, isImmediate, isLocalValueSet, isRequired, isValid, removeValidator, removeValueChangeListener, resetValue, setConverterMessage, setLocalValueSet, setRequiredMessage, setSubmittedValue, setValid, setValidator, setValidatorMessage, setValue, setValueChangeListener, updateModel, validate
 
Methods inherited from class javax.faces.component.UIOutput
getConverter, getLocalValue
 
Methods inherited from class javax.faces.component.UIComponentBase
encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, restoreAttachedState, saveAttachedState, setParent, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue
 

Field Detail

NOT_INTERESTED_GRADE

public static int NOT_INTERESTED_GRADE
The value of a grade when it is marked "not interested".


CLEAR_GRADE

public static int CLEAR_GRADE
The value of a grade when it is marked "cleared".

Constructor Detail

Rating

public Rating()
Creates a new instance of Rating

Method Detail

getFamily

public java.lang.String getFamily()

Return the family for this component.

Overrides:
getFamily in class javax.faces.component.UIInput

getRendererType

public java.lang.String getRendererType()
Overrides:
getRendererType in class javax.faces.component.UIComponentBase

getValueExpression

public javax.el.ValueExpression getValueExpression(java.lang.String name)

Return the ValueExpression stored for the specified name (if any), respecting any property aliases.

Overrides:
getValueExpression in class javax.faces.component.UIComponentBase
Parameters:
name - Name of value binding expression to retrieve

setValueExpression

public void setValueExpression(java.lang.String name,
                               javax.el.ValueExpression binding)

Set the ValueExpression stored for the specified name (if any), respecting any property aliases.

Overrides:
setValueExpression in class javax.faces.component.UIComponentBase
Parameters:
name - Name of value binding to set
binding - ValueExpression to set, or null to remove

getValue

public java.lang.Object getValue()
Specified by:
getValue in interface javax.faces.component.ValueHolder
Overrides:
getValue in class javax.faces.component.UIOutput

getStyle

public java.lang.String getStyle()

CSS style or styles to be applied to the outermost HTML element when this component is rendered.


setStyle

public void setStyle(java.lang.String style)

CSS style or styles to be applied to the outermost HTML element when this component is rendered.

See Also:
getStyle()

getStyleClass

public java.lang.String getStyleClass()

CSS style class or classes to be applied to the outermost HTML element when this component is rendered.


setStyleClass

public void setStyleClass(java.lang.String styleClass)

CSS style class or classes to be applied to the outermost HTML element when this component is rendered.

See Also:
getStyleClass()

isVisible

public boolean isVisible()

Use to indicate whether the component should be viewable by the user in the rendered HTML page. If set to false, the HTML code for the component is present in the page, but the component is hidden with style attributes. By default, visible is set to false, so HTML for the component HTML is included and not visible to the user. If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present.


setVisible

public void setVisible(boolean visible)

Use to indicate whether the component should be viewable by the user in the rendered HTML page. If set to false, the HTML code for the component is present in the page, but the component is hidden with style attributes. By default, visible is set to false, so HTML for the component HTML is included and not visible to the user. If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present.

See Also:
isVisible()

isAutoSubmit

public boolean isAutoSubmit()

Return true if the grade is automatically submitted to the server via an Ajax request immediately after the grade is selected, false if not.


setAutoSubmit

public void setAutoSubmit(boolean autoSubmit)

Set whether the grade is automatically submitted to the server via an Ajax request immediately after the grade is selected. The default is false - it is NOT automatically submitted.


getAverageGrade

public double getAverageGrade()

Get the average grade the general user population has assigned to the item. Will be between 0.0 and the maximum grade and rounded to the nearest 1/2 grade.


setAverageGrade

public void setAverageGrade(double averageGrade)

Set the average grade the general user population has assigned to the item. Must be between 0.0 and the maximum grade. The default is 0.


getClearAcknowledgedText

public java.lang.String getClearAcknowledgedText()

Returns the acknowledged text for the clear control. Returns null if not set.


setClearAcknowledgedText

public void setClearAcknowledgedText(java.lang.String clearAcknowledgedText)
Set the acknowledged text for the clear control.


getClearHoverText

public java.lang.String getClearHoverText()

Returns the hover text for the clear control. Returns null if not set.


setClearHoverText

public void setClearHoverText(java.lang.String clearHoverText)
Set the hover text for the clear control.


getGrade

public int getGrade()

Return the grade (number of "stars") the user has assigned the item. For "not interested", the value returned is Rating.NOT_INTERESTED_GRADE, and for a "clear" grade the value returned is Rating.CLEAR_GRADE.


setGrade

public void setGrade(int grade)

Set the grade (number of "stars") the user has assigned the item. Use Rating.NOT_INTERESTED_GRADE for "not interested" and Rating.CLEAR_GRADE for a "clear" grade (effectively, set it to 0). The default is Rating.CLEAR_GRADE.


getGradeAcknowledgedText

public java.lang.String getGradeAcknowledgedText()

Returns the acknowledged text for the grade controls. Returns null if not set.


setGradeAcknowledgedText

public void setGradeAcknowledgedText(java.lang.String gradeAcknowledgedText)
Set the acknowledged text for the grade controls.


getGradeHoverTexts

public java.lang.String[] getGradeHoverTexts()

Returns the hover texts that are used for the grade controls, ordered from lowest to highest rating. That is, the first element of the returned array will be the hover text associated with the lowest rating; the last element with the highest rating. Returns null if no texts have been set.


setGradeHoverTexts

public void setGradeHoverTexts(java.lang.String[] gradeHoverTexts)

Set the hover texts that will be used for the grade controls, ordered from lowest to highest rating. That is, hoverTexts[0] will be the hover text associated with the lowest rating; hoverTexts[hoverTexts.length-1] with the highest rating. Null can be specified as a member of the array. There are no defaults.


isGradeReadOnly

public boolean isGradeReadOnly()

Return true if the grade of this rating component can be changed by the user.


setGradeReadOnly

public void setGradeReadOnly(boolean gradeReadOnly)

Set whether the grade of this rating component can be changed by the user. The default is false - it is NOT read-only, and therefore can be changed by the user.


isInAverageMode

public boolean isInAverageMode()

Return true if the component is rendered displaying the average grade, false if component is rendered displaying the user's grade (normal mode).


setInAverageMode

public void setInAverageMode(boolean inAverageMode)

Set whether the component will be rendered displaying the average grade. The default is false, the component will be rendered showing the user's rating (normal mode).


isIncludeClear

public boolean isIncludeClear()

Return true if a control to clear the user's rating is rendered, false if not.


setIncludeClear

public void setIncludeClear(boolean includeClear)

Set whether a control to clear the user's rating should be displayed. The default is true.


isIncludeModeToggle

public boolean isIncludeModeToggle()

Return true if a control to toggle the mode (to show the average rating or the user's rating) is rendered, false if not.


setIncludeModeToggle

public void setIncludeModeToggle(boolean includeModeToggle)

Set whether a control to toggle the mode (to show the average rating or the user's rating) should be rendered. The default is false.


isIncludeNotInterested

public boolean isIncludeNotInterested()

Return true if a control to allow the user to assign a "not interested" rating is rendered, false if not.


setIncludeNotInterested

public void setIncludeNotInterested(boolean includeNotInterested)

Set whether a control to allow the user to assign a "not interested" rating should be rendered. The default is true.


isIncludeText

public boolean isIncludeText()

Return true if an area to show hover text or post-click acknowledged text is rendered, false if not.


setIncludeText

public void setIncludeText(boolean includeText)

Set whether an area for hover or post-click acknowledged text should be rendered. The default is true.


getMaxGrade

public int getMaxGrade()

Return the maximum grade (number of "stars") this rating instance allows.


setMaxGrade

public void setMaxGrade(int maxGrade)

Set the maximum grade (number of "stars") this rating instance allows. There is no default, and so must be set.


isModeReadOnly

public boolean isModeReadOnly()

Return true if the mode of this rating component can be changed by the user (via the mode toggle control), false if not


setModeReadOnly

public void setModeReadOnly(boolean modeReadOnly)

Set whether the mode of this rating component can be changed by the user (via the mode toggle control). The default is false - it is NOT read-only, and therefore can be changed by the user.


getModeToggleAcknowledgedTexts

public java.lang.String[] getModeToggleAcknowledgedTexts()

Returns the acknowledged texts that are used for the mode toggle control. The first element of the returned array is the acknowledged text displayed after clicking on the mode toggle control to preview the user's rating (nomal mode). The second element is the text displayed after clicking on the mode toggle control to preview the average rating (average mode). If at least one of the texts has been specified but one has not, then null is returned in the array element for the missing text. Returns null if no acknowledged texts have been specified.


setModeToggleAcknowledgedTexts

public void setModeToggleAcknowledgedTexts(java.lang.String[] modeToggleAcknowledgedTexts)

Sets the acknowledged texts to be used for the mode toggle control. The first element of the array is the acknowledged text displayed after clicking on the mode toggle control to preview the user's rating (normal mode). The second element is the text displayed after clicking to preview the average rating (average mode). Null can be specified as a member of the array.


getModeToggleHoverTexts

public java.lang.String[] getModeToggleHoverTexts()

Returns the hover texts that are used for the mode toggle control. The first element of the returned array is the hover text displayed when hovering over the mode toggle control to preview the user's rating (nomal mode). The second element is the text displayed when hovering to preview the average rating (average mode). If at least one of the texts has been specified but one has not, then null is returned in the array element for the missing text. Returns null if no hover texts have been specified.


setModeToggleHoverTexts

public void setModeToggleHoverTexts(java.lang.String[] modeToggleHoverTexts)

Sets the hover texts to be used for the mode toggle control. The first element of the array is the hover text displayed when hovering over the mode toggle control to preview the user's rating (normal mode). The second element is the text displayed when hovering to preview the average rating (normal mode). Null can be specified as a member of the array.


getNotInterestedAcknowledgedText

public java.lang.String getNotInterestedAcknowledgedText()

Returns the acknowledged text for the "not interested" control. Returns null if not set.


setNotInterestedAcknowledgedText

public void setNotInterestedAcknowledgedText(java.lang.String notInterestedAcknowledgedText)
Set the acknowledged text for the "not interested" control.


getNotInterestedHoverText

public java.lang.String getNotInterestedHoverText()

Returns the hover text for the "not interested" control. Returns null if not set.


setNotInterestedHoverText

public void setNotInterestedHoverText(java.lang.String notInterestedHoverText)
Set the hover text for the "not interested" control.


getTabIndex

public int getTabIndex()

Return the position of this element in the tabbing order.


setTabIndex

public void setTabIndex(int tabIndex)

Set the position of this element in the tabbing order.


restoreState

public void restoreState(javax.faces.context.FacesContext _context,
                         java.lang.Object _state)

Restore the state of this component.

Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class WebuiInput

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext _context)

Save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class WebuiInput


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.