Class WireframeBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.behavior.AbstractAjaxBehavior
-
- org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
-
- org.hippoecm.frontend.plugins.yui.AbstractYuiAjaxBehavior
-
- org.hippoecm.frontend.plugins.yui.layout.WireframeBehavior
-
- All Implemented Interfaces:
Serializable
,org.apache.wicket.IComponentAwareEventSink
,org.apache.wicket.IRequestListener
,org.apache.wicket.markup.html.IComponentAwareHeaderContributor
,org.apache.wicket.util.io.IClusterable
,IWireframe
public class WireframeBehavior extends AbstractYuiAjaxBehavior implements IWireframe
The WireframeBehavior allows you to create cross-browser application layouts based on the YUI Layout Manager. A layout or wireframe is a structured block containing five layout units: top, right, bottom, left and center. The center unit is always present and fills up the space not occupied by it's neighboring units. Units can be resized (within configurable boundaries) or have a fixed width/height and can be configured to render scrollbars if needed. A wireframe can either be added to the body-element and take up the full viewport, or be added to an existing element with custom width and height constraints. In both cases a resize of the viewport will cause the wireframe to resize itself within the new given boundaries.
Wireframes can be nested as well, both render and resize events will be fired by the nearest ancestor unit, which will provide the new available width and height values.
Every wireframe and unit corresponds with a body element in the DOM. This element is identified by it's id attribute which should be known at render time and is stored, together with all other settings, inside the
WireframeSettings
object. During the renderHead phase, this behavior will register a new wireframe with it's configuration object on the client using a JSON serialized version of theWireframeSettings
, which will than be instantiated and rendered on either window.load or after Wicket has finished processing the Ajax response.When a wireframe is rendered, it will create a new node structure inside it's body-element. It will than move the elements representing the units into their new container elements. For example, our wireframe's root element is identified by id 'root' and contains two units: top and center.
After the wireframe has rendered it will look something like (this is a slimmed down version of the real deal for the sake of readability)
<div id="root" class="yui-layout"> <div class="yui-layout-doc"> <div class="yui-layout-unit yui-layout-unit-top"> .. <div id="top">[ Top ]</div> .. </div> <div class="yui-layout-unit yui-layout-unit-center"> .. <div id="center">[ Center ]</div> .. </div> </div> </div>
As stated before, the id's of the wireframe's root element and all of it's units body elements, should be known at render time. If our application only contains one single wireframe with two static unit, we can hard-code the id values into the accompanying .html file and
WireframeSettings
. But, as we are working in a composite environment, we want our wireframes to be re-usable, without having to worry about id clashes on the client. To accompany this, we created theYuiId
, which allows us to do just that. SeeYuiId
for more about that.When a wireframe is nested inside another wireframe, YUI demands that the child wireframe knows the id value of it's parent wireframe at render time. Because of this, a wireframe will look up it's ancestors graph for a class implementing the
IWireframe
and, if found, retrieve and store the parent id.Another feature of the wireframe behavior is to dynamically find child components that contain a
UnitBehavior
and register them in theWireframeSettings
. This way, aRenderService
can add extension points for units, and know nothing about them except their position until render time.To integrate the YUI layouts into Wicket, we have added a clientside manager component that handles the lifecycle, rendering and resizing behavior of the wireframes. For more info see /api/src/main/java/org/hippoecm/frontend/plugins/yui/inc/hippo/281/layoutmanager/layoutmanager-debug.js
- See Also:
WireframeSettings
,YuiId
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description WireframeBehavior(WireframeSettings settings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHeaderContribution(IYuiContext context)
Override this method to get access to the IYuiContextvoid
collapseAll()
void
expandDefault()
If no unit has been expanded and a default expanded unit has been configured, it will be expanded.org.apache.wicket.markup.head.HeaderItem
getHeaderItem()
protected IWireframe
getParentWireframe()
YuiId
getYuiId()
Return the root id of this wireframeboolean
hasExpandableUnit()
boolean
isRendered()
protected void
onExpandDefault()
protected void
onRenderHead(org.apache.wicket.markup.head.IHeaderResponse response)
protected void
onToggle(boolean expand, String position)
protected void
onToggleFromClient(String position, boolean expand)
void
render(org.apache.wicket.ajax.AjaxRequestTarget target)
void
resize(org.apache.wicket.ajax.AjaxRequestTarget target)
Resize the wireframe, e.g.protected void
respond(org.apache.wicket.ajax.AjaxRequestTarget target)
boolean
toggle(String position)
-
Methods inherited from class org.hippoecm.frontend.plugins.yui.AbstractYuiAjaxBehavior
renderHead, updateAjaxAttributes, updateAjaxSettings
-
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onBind, onMethodMismatch, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes
-
Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbind
-
Methods inherited from class org.apache.wicket.behavior.Behavior
beforeRender, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTag
-
-
-
-
Constructor Detail
-
WireframeBehavior
public WireframeBehavior(WireframeSettings settings)
-
-
Method Detail
-
getYuiId
public YuiId getYuiId()
Description copied from interface:IWireframe
Return the root id of this wireframe- Specified by:
getYuiId
in interfaceIWireframe
- Returns:
- the root
YuiId
of this wireframe
-
isRendered
public boolean isRendered()
- Specified by:
isRendered
in interfaceIWireframe
-
render
public void render(org.apache.wicket.ajax.AjaxRequestTarget target)
- Specified by:
render
in interfaceIWireframe
-
addHeaderContribution
public void addHeaderContribution(IYuiContext context)
Description copied from class:AbstractYuiAjaxBehavior
Override this method to get access to the IYuiContext- Overrides:
addHeaderContribution
in classAbstractYuiAjaxBehavior
- Parameters:
context
- The IYuiContext this behavior can use to register YUI-modules and the likes.
-
onRenderHead
protected void onRenderHead(org.apache.wicket.markup.head.IHeaderResponse response)
- Overrides:
onRenderHead
in classAbstractYuiAjaxBehavior
-
resize
public void resize(org.apache.wicket.ajax.AjaxRequestTarget target)
Description copied from interface:IWireframe
Resize the wireframe, e.g. when it has become visible.- Specified by:
resize
in interfaceIWireframe
-
getParentWireframe
protected IWireframe getParentWireframe()
-
getHeaderItem
public org.apache.wicket.markup.head.HeaderItem getHeaderItem()
- Specified by:
getHeaderItem
in interfaceIWireframe
-
respond
protected void respond(org.apache.wicket.ajax.AjaxRequestTarget target)
- Specified by:
respond
in classorg.apache.wicket.ajax.AbstractDefaultAjaxBehavior
-
onToggleFromClient
protected void onToggleFromClient(String position, boolean expand)
-
toggle
public boolean toggle(String position)
-
onToggle
protected void onToggle(boolean expand, String position)
-
collapseAll
public void collapseAll()
-
expandDefault
public void expandDefault()
If no unit has been expanded and a default expanded unit has been configured, it will be expanded.
-
onExpandDefault
protected void onExpandDefault()
-
hasExpandableUnit
public boolean hasExpandableUnit()
-
-