edu.nrao.sss.webapp.faces.component
Class NotesUIComponent

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 edu.nrao.sss.webapp.faces.component.NotesUIComponent
All Implemented Interfaces:
EditableValueHolder, StateHolder, ValueHolder

public class NotesUIComponent
extends UIInput


Field Summary
protected static String RENDERED_SCRIPT_KEY
           
 
Fields inherited from class javax.faces.component.UIInput
COMPONENT_FAMILY, COMPONENT_TYPE, CONVERSION_MESSAGE_ID, REQUIRED_MESSAGE_ID
 
Constructor Summary
NotesUIComponent()
           
 
Method Summary
protected  boolean compareValues(Object previous, Object value)
          Overridden to compare 2 lists.
 void decode(FacesContext context)
           
 void encodeBegin(FacesContext context)
           
 void encodeChildren(FacesContext context)
          Overridden to be empty.
protected  void encodeCollapseButton(ResponseWriter writer, String nid, String sumid)
          encodes a link that calls javascript functions to expand and collapse a note.
protected  void encodeCollapseNoteJSFunctions(ResponseWriter writer)
          writes a javascript function that toggles the collapsed state of a note.
 void encodeEnd(FacesContext context)
          Overridden to output the necessary javascript for this component.
protected  void encodeNewLink(ResponseWriter writer, String id)
          Writes a link that will create a new note widget (via JS).
protected  void encodeNewNoteJSFunction(ResponseWriter writer, int numNotes)
          writes a javascript function that inserts a new notes widget into the html at the end of the list of notes widgets.
protected  void encodeNote(FacesContext context, String id, String note, int index)
          Encodes note rendering the note, a collapse/expand button, and a remove link (depending on the isEnabled flag).
protected  void encodeRemoveLink(ResponseWriter writer, String pid, String nid, String hid)
           
protected  void encodeRemoveNoteJSFunctions(ResponseWriter writer)
          writes javascript functions that handle removing a note and poping up a dialog warning them with confirm and cancel options.
protected  Object getConvertedValue(FacesContext context, Object newSubmittedValue)
          Override the getConvertedValue method to return the List? Or just return * the thing it gets unchanged?
protected  String getNoteHeaderId(String nid)
           
protected  String getNoteId(FacesContext context, int noteIndex)
           
protected  String getNoteStateId(String nid)
           
protected  String getNoteSummaryId(String nid)
           
 Boolean isCollapsed(String nid)
           
 boolean isEnabled()
           
 void restoreState(FacesContext context, Object state)
           
 Object saveState(FacesContext context)
           
 void setCollapsed(Hashtable<String,Boolean> state)
           
 void setEnabled(Boolean e)
           
 
Methods inherited from class javax.faces.component.UIInput
addValidator, addValueChangeListener, broadcast, getFamily, getSubmittedValue, getValidator, getValidators, getValueChangeListener, getValueChangeListeners, isImmediate, isLocalValueSet, isRequired, isValid, processDecodes, processUpdates, processValidators, removeValidator, removeValueChangeListener, setImmediate, setLocalValueSet, setRequired, setSubmittedValue, setValid, setValidator, setValue, setValueChangeListener, updateModel, validate, validateValue
 
Methods inherited from class javax.faces.component.UIOutput
getConverter, getLocalValue, getValue, setConverter
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, getValueBinding, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue, getValue, setConverter
 

Field Detail

RENDERED_SCRIPT_KEY

protected static final String RENDERED_SCRIPT_KEY
See Also:
Constant Field Values
Constructor Detail

NotesUIComponent

public NotesUIComponent()
Method Detail

encodeBegin

public void encodeBegin(FacesContext context)
                 throws IOException
Overrides:
encodeBegin in class UIComponentBase
Throws:
IOException

encodeNote

protected void encodeNote(FacesContext context,
                          String id,
                          String note,
                          int index)
                   throws IOException
Encodes note rendering the note, a collapse/expand button, and a remove link (depending on the isEnabled flag).

Throws:
IOException

encodeNewLink

protected void encodeNewLink(ResponseWriter writer,
                             String id)
                      throws IOException
Writes a link that will create a new note widget (via JS).

Parameters:
id - The client id of this component
Throws:
IOException

encodeRemoveLink

protected void encodeRemoveLink(ResponseWriter writer,
                                String pid,
                                String nid,
                                String hid)
                         throws IOException
Throws:
IOException

encodeCollapseButton

protected void encodeCollapseButton(ResponseWriter writer,
                                    String nid,
                                    String sumid)
                             throws IOException
encodes a link that calls javascript functions to expand and collapse a note. Also encodes a hidden field to keep track of the expanded state of the note.

Throws:
IOException

encodeEnd

public void encodeEnd(FacesContext context)
               throws IOException
Overridden to output the necessary javascript for this component. If the javascript has already be rendered for this response, nothing is done.

Overrides:
encodeEnd in class UIComponentBase
Throws:
IOException

encodeNewNoteJSFunction

protected void encodeNewNoteJSFunction(ResponseWriter writer,
                                       int numNotes)
                                throws IOException
writes a javascript function that inserts a new notes widget into the html at the end of the list of notes widgets.

Throws:
IOException

encodeRemoveNoteJSFunctions

protected void encodeRemoveNoteJSFunctions(ResponseWriter writer)
                                    throws IOException
writes javascript functions that handle removing a note and poping up a dialog warning them with confirm and cancel options.

Throws:
IOException

encodeCollapseNoteJSFunctions

protected void encodeCollapseNoteJSFunctions(ResponseWriter writer)
                                      throws IOException
writes a javascript function that toggles the collapsed state of a note. Also outputs hidden form fields to keep track of said state.

Throws:
IOException

decode

public void decode(FacesContext context)
Overrides:
decode in class UIInput

getConvertedValue

protected Object getConvertedValue(FacesContext context,
                                   Object newSubmittedValue)
                            throws ConverterException
Override the getConvertedValue method to return the List? Or just return * the thing it gets unchanged?

Overrides:
getConvertedValue in class UIInput
Throws:
ConverterException

compareValues

protected boolean compareValues(Object previous,
                                Object value)
Overridden to compare 2 lists.

Overrides:
compareValues in class UIInput
Returns:
true if the new value is different from the old value.

saveState

public Object saveState(FacesContext context)
Specified by:
saveState in interface StateHolder
Overrides:
saveState in class UIInput

restoreState

public void restoreState(FacesContext context,
                         Object state)
Specified by:
restoreState in interface StateHolder
Overrides:
restoreState in class UIInput

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(Boolean e)

isCollapsed

public Boolean isCollapsed(String nid)

setCollapsed

public void setCollapsed(Hashtable<String,Boolean> state)

getNoteId

protected String getNoteId(FacesContext context,
                           int noteIndex)

getNoteStateId

protected String getNoteStateId(String nid)

getNoteHeaderId

protected String getNoteHeaderId(String nid)

getNoteSummaryId

protected String getNoteSummaryId(String nid)

encodeChildren

public void encodeChildren(FacesContext context)
                    throws IOException
Overridden to be empty.

Overrides:
encodeChildren in class UIComponentBase
Throws:
IOException


Copyright © 2009. All Rights Reserved.