wheel.components
Class StandaloneComponent

java.lang.Object
  extended by wheel.components.Component
      extended by wheel.components.RenderableComponent
          extended by wheel.components.StandaloneComponent
All Implemented Interfaces:
IBuildableComponent, IContainer
Direct Known Subclasses:
ErrorPage, MockPage

public abstract class StandaloneComponent
extends RenderableComponent
implements IContainer, IBuildableComponent

Defines the contract for complex components. Complex components are components that can contain forms and can have their own resource bundles for messages. There are no limitations for complex components and they can be full-blown applications that live inside a containing Page.

Author:
Henri Frilund

Constructor Summary
  StandaloneComponent()
           
protected StandaloneComponent(Component parent, java.lang.String componentId)
           
protected StandaloneComponent(java.lang.String componentId)
           
 
Method Summary
 void _clear()
          Intended for internal use.
 java.lang.String _generateComponentId(Component component)
          Generates a componentId for the given Component.
 ComponentStore _getComponentStore()
          Intended for internal use.
 java.lang.String _getSubmitTarget()
           
 boolean _isBuilt()
           
 boolean _isRewindingForm(Form form)
          Intended for internal use.
 void _postBuildPage()
           
 void _postProcessRequest()
           
 void _render(org.xmlpull.v1.XmlSerializer serializer)
          Default implementation.
 void _setBuilt(boolean built)
           
 void _setPageRewinding(boolean rewinding)
          Intended for internal use.
 void _setSubmitTarget(java.lang.String submitTarget)
          Intended for internal use.
 void _setSubmittedForm(Form submittedForm)
          Intended for internal use.
 void afterAdd()
          A lifecycle method that is called after the component has been added to the component tree.
 void commit()
          Calling this method causes all field marked with @Value(linkTo = ...) annotation to be written to the domain objects.
 void commit(java.lang.String... fields)
          Calling this method causes all field marked with @Value(linkTo = ...) annotation and identified in the input varargs to be writtetn to the domain objects.
 StandaloneComponentConfiguration config()
           
 java.lang.String defaultTagName()
          Subclasses must implement this.
 ValidationError getError(java.lang.String componentId)
          Returns the first error for the form element in the submitted form.
 Messages getMessages()
          Returns the Messages-object giving access to localized messages.
 java.lang.String getPagePath()
          Creates a string representation that, when appended to an URL, give access to this page.
 java.lang.String getPageUrl()
           
 Form getSubmittedForm()
           
 boolean isPage()
           
 boolean isPageRewinding()
          Returns true if a form submit is rewinding on this page.
 boolean isRewinding()
          Returns true if this complex component is rewinding.
 boolean isValid(java.lang.String formElementName)
          Returns true if the form element with the given componentId is valid.
 java.util.List<ValidationError> listErrors()
          Lists all valiation errors for all form elements.
 void loadJQuery()
           
 void postBuild()
          Called after buildComponent().
 void preBuild()
          Called before buildComponent().
 void rollback()
           
 void rollback(java.lang.String... fields)
           
 void setFocus(Component component)
          Sets the browser focus.
 
Methods inherited from class wheel.components.RenderableComponent
_classReferenceFromHints, _getRenderAfterMe, _getRenderBeforeMe, _renderActions, _renderClassReferenceFromHints, _renderTagStart, _renderXhtmlAttributes, addRenderAfter, addRenderBefore, defaultDomEvent, getTagName, renderComponent, toString
 
Methods inherited from class wheel.components.Component
_applyFormat, _getAction, _getActions, _getChildren, _getForm, _getRenderableChildren, _getRenderHints, _getTopLevelComponent, _getVisibleForm, _getXhtmlAttributes, _isGeneratedId, _setComponentId, _setGeneratedId, _wrapComponentId, a, a, abbr, abbr, acronym, acronym, action, actionBinding, actionBinding, add, addFirst, address, address, area, attribute, attributes, b, b, base, bdo, big, big, blockquote, br, button, caption, checkbox, checkboxGroup, cite, cite, clasS, col, colgroup, create, dateInput, dd, dd, del, del, dfn, dfn, div, dl, dt, dt, el, em, em, encode, entity, equals, eval, fieldset, fileInput, fileInput, find, findAll, form, form, frame, frameset, get, getComponentId, getComponentName, getComponents, getEngine, getPage, getParent, h1, h1, h2, h2, h3, h3, h4, h4, h5, h5, h6, h6, hashCode, head, hidden, hr, htmlText, i, i, id, iframe, img, ins, ins, kbd, kdb, label, label, legend, legend, li, li, link, link, map, message, message, meta, multiSelect, nbsp, noframes, noscript, numberInput, numberInput, object, ol, p, p, param, placeholder, pre, pre, q, q, radio, radioGroup, rawText, remove, remove, renderHint, requestFocus, s, s, samp, samp, script, select, selectModel, small, small, span, span, strike, strike, strong, strong, style, sub, sub, submit, sup, sup, table, tbody, td, text, textarea, textInput, tfoot, th, thead, title, tr, u, u, ul, up, up, var, var, wBlock, wrapSelf
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wheel.components.IBuildableComponent
buildComponent
 

Constructor Detail

StandaloneComponent

public StandaloneComponent()

StandaloneComponent

protected StandaloneComponent(java.lang.String componentId)

StandaloneComponent

protected StandaloneComponent(Component parent,
                              java.lang.String componentId)
Method Detail

config

public StandaloneComponentConfiguration config()
Overrides:
config in class RenderableComponent

isRewinding

public boolean isRewinding()
Returns true if this complex component is rewinding. Rewinding means that a form submit has been recieved and the component tree has been built once so that values from the submit were possible to bind. When the binding is done, the component tree is built again, this time in rewind-mode. You should use this method whenever you want to append validation messages or change the structure of the component in any way depending on the results of the form submit.

Returns:

getMessages

public Messages getMessages()
Returns the Messages-object giving access to localized messages. Localized messages can be added to any complex component by creating .properties file to the same package as the class file and with the same name as the component class.

Returns:

isValid

public boolean isValid(java.lang.String formElementName)
Returns true if the form element with the given componentId is valid. Internally this method checks first if the component is rewinding. If not, will return true.

Parameters:
formElementName - The component ID of the form element.
Returns:

listErrors

public java.util.List<ValidationError> listErrors()
Lists all valiation errors for all form elements. Internally checks if the component is rewinding. If not, will return an empty list.

Returns:

getError

public ValidationError getError(java.lang.String componentId)
Returns the first error for the form element in the submitted form. If the field is valid or doesn't exist, returns null.

Parameters:
componentId -
Returns:

defaultTagName

public java.lang.String defaultTagName()
Description copied from class: RenderableComponent
Subclasses must implement this. If no xhtml tagname can be resolved from rendering hints, will default to value returned by this method.

Specified by:
defaultTagName in class RenderableComponent
Returns:

commit

public void commit()
Calling this method causes all field marked with @Value(linkTo = ...) annotation to be written to the domain objects.


commit

public void commit(java.lang.String... fields)
Calling this method causes all field marked with @Value(linkTo = ...) annotation and identified in the input varargs to be writtetn to the domain objects.

Parameters:
fields - Names of the fields to commit.

rollback

public void rollback()

rollback

public void rollback(java.lang.String... fields)

preBuild

public void preBuild()
Description copied from interface: IBuildableComponent
Called before buildComponent().

Specified by:
preBuild in interface IBuildableComponent

postBuild

public void postBuild()
Description copied from interface: IBuildableComponent
Called after buildComponent(). Useful for cleaning up resources after buildComponent() and possibly doing some modifications on the component tree before rendering.

Specified by:
postBuild in interface IBuildableComponent

_isBuilt

public boolean _isBuilt()
Specified by:
_isBuilt in interface IBuildableComponent

_setBuilt

public void _setBuilt(boolean built)
Specified by:
_setBuilt in interface IBuildableComponent

afterAdd

public void afterAdd()
Description copied from class: Component
A lifecycle method that is called after the component has been added to the component tree. When overriding this method, always call super.afterAdd();!!

Overrides:
afterAdd in class Component

_render

public void _render(org.xmlpull.v1.XmlSerializer serializer)
             throws java.io.IOException
Description copied from class: RenderableComponent
Default implementation. Handles render before/after logic. Will first figure out the xhtml tag to use from rendering hints, then delegates to renderComponent(). Subclasses should override renderComponent() rather than this method.

Overrides:
_render in class RenderableComponent
Throws:
java.io.IOException

_postProcessRequest

public void _postProcessRequest()

_postBuildPage

public void _postBuildPage()

_generateComponentId

public java.lang.String _generateComponentId(Component component)
Generates a componentId for the given Component.

Parameters:
component - Component to generate componentId for.
Returns:
Component short classname + "_" + integer count of the component type on this page. Example_ Label_4.

getPagePath

public java.lang.String getPagePath()
Creates a string representation that, when appended to an URL, give access to this page.

Returns:
The full classname where basePackageForPages is removed and .'s are replaced with /'s. Example com.foo.bar.TestPage -> bar/TestPage (where basePackageForPages = com.foo).

isPageRewinding

public boolean isPageRewinding()
Returns true if a form submit is rewinding on this page.

Returns:

_setPageRewinding

public void _setPageRewinding(boolean rewinding)
Intended for internal use.

Parameters:
rewinding -

_isRewindingForm

public boolean _isRewindingForm(Form form)
Intended for internal use.

Parameters:
form -
Returns:
True if the page is rewinding the given form.

_getComponentStore

public ComponentStore _getComponentStore()
Intended for internal use.

Returns:

getPageUrl

public java.lang.String getPageUrl()
Returns:
The complete URL for this page, including scheme, engine name, port, context path and servlet path.

_clear

public void _clear()
Intended for internal use.

Overrides:
_clear in class RenderableComponent

getSubmittedForm

public Form getSubmittedForm()
Returns:
The form that was submitted to this page.
Throws:
WheelException - if no form was submitted.

_setSubmittedForm

public void _setSubmittedForm(Form submittedForm)
Intended for internal use.

Parameters:
submittedForm -

_getSubmitTarget

public java.lang.String _getSubmitTarget()
Returns:
componentId for the StandaloneComponent that is the reciever of the submitted form.

_setSubmitTarget

public void _setSubmitTarget(java.lang.String submitTarget)
Intended for internal use.

Parameters:
submitTarget -

setFocus

public void setFocus(Component component)
Sets the browser focus. Will cause the page to render a javascript fragment like this:
document.getElementById('componentId').focus();


loadJQuery

public void loadJQuery()

isPage

public boolean isPage()


Copyright © 2007-2008. All Rights Reserved.