edu.nrao.sss.webapp.faces.component
Class ExitDialogUIComponent
java.lang.Object
javax.faces.component.UIComponent
javax.faces.component.UIComponentBase
edu.nrao.sss.webapp.faces.component.FloatingDialogUIComponent
edu.nrao.sss.webapp.faces.component.ExitDialogUIComponent
- All Implemented Interfaces:
- StateHolder
public class ExitDialogUIComponent
- extends FloatingDialogUIComponent
This component extends the FloatingDialogUIComponent to provide both a
serverside and clientside check for unsaved data when the exit button is
hit. This component relies on 1 java script method being available in the
rendered page:
getClientSideChangesExist()
: returns true if changes have occured
that have not yet been submitted. This method is not rendered by
this component and must be provided by the application!
TODO: Need to rewrite this and the FloatingDialogUIComponent to break up the
rendering of the link/button into a separate method that's more easily
overridden.
NOTE: There is one outstanding problem with this safety mechanism, and that
is, if a user changes a field, doesn't submit the form, but instead reloads
the page for some reason, the form will still hold the new values they typed
in (thanks to their trusty web browser) but neither the server, nor the java
script will know that there have been changes. In this case, the user may
loose data. It's rare enough that I don't think it's necessary to try and
fix it. At least not yet.
Methods inherited from class edu.nrao.sss.webapp.faces.component.FloatingDialogUIComponent |
encodeChildren, encodeEnd, getCloseOnClick, getCloseOnMouseOut, getFamily, getLinkId, getOpenOnClick, getOpenOnMouseOver, getRendersChildren, getTitle, isEnabled, setCloseOnClick, setCloseOnMouseOut, setEnabled, setLinkId, setOpenOnClick, setOpenOnMouseOver, setTitle |
Methods inherited from class javax.faces.component.UIComponentBase |
addFacesListener, broadcast, decode, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getValueBinding, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, 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 |
RENDERED_SCRIPT_KEY
protected static final String RENDERED_SCRIPT_KEY
- See Also:
- Constant Field Values
ExitDialogUIComponent
public ExitDialogUIComponent()
encodeBegin
public void encodeBegin(FacesContext context)
throws IOException
- Override the encodeBegin method to make it output a button instead of a
link and to write out fancier java script to handle the clientside
changes flag.
- Overrides:
encodeBegin
in class FloatingDialogUIComponent
- Throws:
IOException
encodeJavascriptMethods
public void encodeJavascriptMethods(FacesContext context,
String id)
throws IOException
- Overridden to output the necessary javascript for this component. If the
javascript has already be rendered for this response, nothing is done.
- Throws:
IOException
getHasSubmittedChanges
public Boolean getHasSubmittedChanges()
setHasSubmittedChanges
public void setHasSubmittedChanges(Boolean e)
saveState
public Object saveState(FacesContext context)
- Specified by:
saveState
in interface StateHolder
- Overrides:
saveState
in class FloatingDialogUIComponent
restoreState
public void restoreState(FacesContext context,
Object state)
- Specified by:
restoreState
in interface StateHolder
- Overrides:
restoreState
in class FloatingDialogUIComponent
Copyright © 2009. All Rights Reserved.