public class WireframeBehavior extends AbstractYuiAjaxBehavior implements IWireframe
A layout or wireframe is a structured block containing five layout units, top, right, bottom, left and center (see http://developer.yahoo.com/yui/layout/#wireframe). 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 (a JSON serialized version of the WireframeSettings
on the client, 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, representing the new wireframe and it's units. It will than move the elements representing the units into their new container elements.
For example: (our wireframe root element is identified by id 'root' and contains two units: top[id='top'] and
center[id='center'])
<div id="root">
<div id="top">[ Top ]</div>
<div id="center">[ Center ]</div>
</div>
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>
In the above example, the dots are actual elements added by YUI used for handling size, scrollbars, borders, etc.
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. They are stored inside the WireframeSettings
object which is serialized to JSON and registered
on the client.
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 the YuiId
, which allows us to do just that. See YuiId
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, retrieves and stores the parent id.
Another feature of the wireframe behavior is to dynamically find child components that contain a UnitBehavior
and register them in the WireframeSettings
. This way, a RenderService
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 of the wireframe structure.
For more info see the comments in
hippo-ecm-addon-yui/src/main/java/org/hippoecm/frontend/plugins/yui/inc/hippo/2.7.0/layoutmanager/layoutmanager-debug.js
WireframeSettings
,
YuiId
,
Serialized FormConstructor and Description |
---|
WireframeBehavior(WireframeSettings settings) |
Modifier and Type | Method and Description |
---|---|
void |
addHeaderContribution(IYuiContext context)
Override this method to get access to the IYuiContext
|
void |
collapseAll() |
void |
detach(org.apache.wicket.Component component) |
void |
expandDefault() |
YuiId |
getYuiId()
Return the root id of this wireframe
|
boolean |
hasExpandableUnit() |
protected void |
onExpandDefault() |
void |
onRenderHead(org.apache.wicket.markup.html.IHeaderResponse response) |
protected void |
onToggle(boolean expand,
String position) |
protected void |
onToggleFromClient(String position,
boolean expand) |
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) |
boolean |
toggle(String position,
org.apache.wicket.ajax.AjaxRequestTarget target)
Deprecated.
|
getCallbackFunction, getCallbackParameters, renderHead, updateAjaxSettings
findIndicatorId, generateCallbackScript, getAjaxCallDecorator, getCallbackScript, getCallbackScript, getChannelName, getFailureScript, getPreconditionScript, getSuccessScript, onBind, onRequest, throttleScript
bind, getCallbackUrl, getCallbackUrl, getComponent, getImplementationId, getStatelessHint, onComponentRendered, onComponentTag, onComponentTag, onRendered, onRenderHeadContribution, onRenderHeadInitContribution
public WireframeBehavior(WireframeSettings settings)
public YuiId getYuiId()
IWireframe
getYuiId
in interface IWireframe
YuiId
of this wireframepublic void detach(org.apache.wicket.Component component)
detach
in interface org.apache.wicket.behavior.IBehavior
detach
in class org.apache.wicket.behavior.AbstractBehavior
public void addHeaderContribution(IYuiContext context)
AbstractYuiAjaxBehavior
addHeaderContribution
in class AbstractYuiAjaxBehavior
context
- The IYuiContext this behavior can use to register YUI-modules and the likes.public void resize(org.apache.wicket.ajax.AjaxRequestTarget target)
IWireframe
resize
in interface IWireframe
public void onRenderHead(org.apache.wicket.markup.html.IHeaderResponse response)
onRenderHead
in class AbstractYuiAjaxBehavior
protected void respond(org.apache.wicket.ajax.AjaxRequestTarget target)
respond
in class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
protected void onToggleFromClient(String position, boolean expand)
@Deprecated public boolean toggle(String position, org.apache.wicket.ajax.AjaxRequestTarget target)
public boolean toggle(String position)
protected void onToggle(boolean expand, String position)
public void collapseAll()
public void expandDefault()
protected void onExpandDefault()
public boolean hasExpandableUnit()
Copyright © 2007-2013 Hippo B.V. (http://www.onehippo.com). All Rights Reserved.