votorola.a.web
Class VPage

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.Page
              extended by org.apache.wicket.markup.html.WebPage
                  extended by VPage
All Implemented Interfaces:
Serializable, IClusterable, IConverterLocator, IRedirectListener, IRequestListener, IHeaderContributor, INewBrowserWindowListener, IPageMapEntry
Direct Known Subclasses:
WP_Count, WP_District, WP_Doubt, WP_Election, WP_EmailAuthen1, WP_EmailAuthen2, WP_Help, WP_List, WP_Login, WP_Message, WP_Meta, WP_OpenIDReturn, WP_Regional, WP_RegionalScheme, WP_Register, WP_Registration, WP_RegistrationV, WP_RoleC, WP_RoleV, WP_Trust, WP_Vote, WP_Voter, WP_Yadis

@ThreadRestricted(value="wicket")
public abstract class VPage
extends WebPage
implements IHeaderContributor

A page in the Web-based voter interface. Access to pages, components and their models is restricted to Wicket threads. This restriction is documented (in Votorola) by the annotation @ThreadRestricted("wicket"). Runtime enforcement of compliance is not possible (e.g. by the use of assertions) because Wicket threads are synchronized through a locking mechanism (Session.getPage) that is private to Wicket.

It is not yet clear (not having looked at the code, in detail) whether Wicket is ensuring that the local memory caches of pooled threads are synchronized through main memory. Assuming Wicket does use a pool for its request threads, then it would have to synchronize each on a common lock both prior to, and subsequent to processing the request (thus invalidating and flushing the caches) to guarantee cross-thread visibility of state changes. But we can just assume this for now (it's easy enough to correct, if we're wrong).

See Also:
http://www.nabble.com/Thread-safety-for-components-to17265324.html, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.Page
Page.IPageSerializer
 
Nested classes/interfaces inherited from class org.apache.wicket.Component
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor, Component.VisibilityChange
 
Field Summary
static int SHORT_STRING_LENGTH_MAX
          The maximum length of a 'short string', in characters.
 
Fields inherited from class org.apache.wicket.Page
LATEST_VERSION, serializer
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER
 
Fields inherited from interface org.apache.wicket.markup.html.INewBrowserWindowListener
INTERFACE
 
Fields inherited from interface org.apache.wicket.IRedirectListener
INTERFACE
 
Constructor Summary
protected VPage()
          Constructs a VPage, per WebPage()
protected VPage(PageParameters pageParameters)
          Constructs a VPage, per WebPage(pageParameters)
 
Method Summary
static
<C extends Component>
C
appendStyleClass(C component, String classIdentifier)
          Appends a CSS class identifier to the component's 'class' attribute.
static EmailAddressValidatorJM emailAddressValidator()
          A shared instance of a validator for strict email addresses.
static
<C extends TextField>
C
inputLengthConstrained(C field)
          Constrains the text field to the standard input length.
static MaxLengthValidator inputLengthValidator()
          A shared instance of a validator for standard input length.
static
<C extends FormComponent>
C
invalidStyled(C component)
          Trains the form component to aquire the style class 'invalid', whenever it fails validation.
static Label newCustomLabel(String id, String key)
          Constructs a custom section of content, as a label.
static Label newLabelNBSP(String id)
          Constructs a label containing a non-breaking space character (&nbsp;).
static Component newNullComponent(String id)
          Constructs a component that is invisible, and does nothing.
static Component newNullComponentAsLabel(String id)
          Returns a label containing a non-breaking space character, for situations that preclude using a proper null component.
 void renderHead(IHeaderResponse r)
           
static String shortened(String string)
          Returns a version of the string that is truncated to SHORT_STRING_LENGTH_MAX characters.
static String shortenedWords(String string)
          Returns a version of the string, in which each of the whitespace delimited words is truncated to SHORT_STRING_LENGTH_MAX characters; or the same string, if no truncation is required.
static String styleClassForKeyword(String prefix, String keyword)
          Constructs a CSS class identifier from a prefix, and an ad hoc keyword.
 VApplication vApplication()
           
 VRequestCycle vRequestCycle()
           
 
Methods inherited from class org.apache.wicket.markup.html.WebPage
configureResponse, getMarkupType, getUrlCompressor, getWebRequestCycle, homePageLink, onDetach, onNewBrowserWindow, setHeaders
 
Methods inherited from class org.apache.wicket.Page
afterCallComponent, beforeCallComponent, componentChanged, componentRendered, detachModels, dirty, endComponentRender, expireOldestVersion, getAjaxVersionNumber, getAutoIndex, getCurrentVersionNumber, getId, getNumericId, getPageClass, getPageMap, getPageMapEntry, getPageMapName, getPageParameters, getSizeInBytes, getStatelessHint, getVersion, getVersions, hierarchyAsString, ignoreVersionMerge, internalOnModelChanged, isBookmarkable, isErrorPage, isPageStateless, moveToPageMap, newVersionManager, onBeforeRender, onPageAttached, onRedirect, onRender, removePersistedFormData, renderPage, rollbackPage, setNumericId, setStatelessHint, startComponentRender, toString, writeReplace
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onComponentTagBody, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getBehaviors, getBehaviors, getClassRelativePath, getComponentBorder, getConverter, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMetaData, getModel, getModelComparator, getModelObject, getModelObjectAsString, getModelObjectAsString, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, newPage, newPage, onAfterRender, onAttach, onBeginRequest, onComponentTag, onEndRequest, onModelChanged, onModelChanging, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMetaData, setModelObject, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisible, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.wicket.session.pagemap.IPageMapEntry
getPage
 

Field Detail

SHORT_STRING_LENGTH_MAX

public static final int SHORT_STRING_LENGTH_MAX
The maximum length of a 'short string', in characters.

See Also:
Constant Field Values
Constructor Detail

VPage

protected VPage()
Constructs a VPage, per WebPage()


VPage

protected VPage(PageParameters pageParameters)
Constructs a VPage, per WebPage(pageParameters)

Method Detail

appendStyleClass

public static <C extends Component> C appendStyleClass(C component,
                                                       String classIdentifier)
Appends a CSS class identifier to the component's 'class' attribute.

Returns:
the component

emailAddressValidator

public static EmailAddressValidatorJM emailAddressValidator()
A shared instance of a validator for strict email addresses.


inputLengthConstrained

public static <C extends TextField> C inputLengthConstrained(C field)
Constrains the text field to the standard input length. Wraps a length limiter around its model, and adds a 'maxLength' attribute.

Returns:
the field
See Also:
VoterInputTable.MAX_INPUT_LENGTH

inputLengthValidator

public static MaxLengthValidator inputLengthValidator()
A shared instance of a validator for standard input length.

See Also:
VoterInputTable.MAX_INPUT_LENGTH

invalidStyled

public static <C extends FormComponent> C invalidStyled(C component)
Trains the form component to aquire the style class 'invalid', whenever it fails validation.

Returns:
the component

newCustomLabel

public static Label newCustomLabel(String id,
                                   String key)
Constructs a custom section of content, as a label.

See Also:
VApplication.putCustomXHTML(String,String)

newLabelNBSP

public static Label newLabelNBSP(String id)
Constructs a label containing a non-breaking space character (&nbsp;).


newNullComponent

public static Component newNullComponent(String id)
Constructs a component that is invisible, and does nothing.


newNullComponentAsLabel

public static Component newNullComponentAsLabel(String id)
Returns a label containing a non-breaking space character, for situations that preclude using a proper null component. One such situation is the end of the page, where a null component somehow causes clipping of the content above (IE7).


shortened

@ThreadSafe
public static String shortened(String string)
Returns a version of the string that is truncated to SHORT_STRING_LENGTH_MAX characters.

Returns:
truncated version of string; or the same string, if no truncation is required

shortenedWords

@ThreadSafe
public static String shortenedWords(String string)
Returns a version of the string, in which each of the whitespace delimited words is truncated to SHORT_STRING_LENGTH_MAX characters; or the same string, if no truncation is required.


styleClassForKeyword

public static String styleClassForKeyword(String prefix,
                                          String keyword)
Constructs a CSS class identifier from a prefix, and an ad hoc keyword. The prefix should be a valid CSS identifier in itself, of at least 2 characters length. The keyword may be any string, including the empty string. It is encoded by substituting an underscore '_' for each illegal character. (Hopefully this is only a temporary kludge, pending the configuration of proper identifiers in lieu of ad hoc keywords.)

Returns:
the component

vApplication

public VApplication vApplication()
See Also:
Component.getApplication()

vRequestCycle

public VRequestCycle vRequestCycle()
See Also:
WebPage.getWebRequestCycle(), VRequestCycle.get()

renderHead

public void renderHead(IHeaderResponse r)
Specified by:
renderHead in interface IHeaderContributor