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 the WireframeSettings
, 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 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, 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 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 behavior of the wireframes. For more info see /api/src/main/java/org/hippoecm/frontend/plugins/yui/inc/hippo/281/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 |
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 wireframe
|
boolean |
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) |
boolean |
toggle(String position,
org.apache.wicket.ajax.AjaxRequestTarget target)
Deprecated.
|
renderHead, updateAjaxAttributes, updateAjaxSettings
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, getChannel, getFailureScript, getPreconditionScript, getSuccessScript, onBind, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbind
public WireframeBehavior(WireframeSettings settings)
public YuiId getYuiId()
IWireframe
getYuiId
in interface IWireframe
YuiId
of this wireframepublic boolean isRendered()
isRendered
in interface IWireframe
public void render(org.apache.wicket.ajax.AjaxRequestTarget target)
render
in interface IWireframe
public void addHeaderContribution(IYuiContext context)
AbstractYuiAjaxBehavior
addHeaderContribution
in class AbstractYuiAjaxBehavior
context
- The IYuiContext this behavior can use to register YUI-modules and the likes.protected void onRenderHead(org.apache.wicket.markup.head.IHeaderResponse response)
onRenderHead
in class AbstractYuiAjaxBehavior
public void resize(org.apache.wicket.ajax.AjaxRequestTarget target)
IWireframe
resize
in interface IWireframe
protected IWireframe getParentWireframe()
public org.apache.wicket.markup.head.HeaderItem getHeaderItem()
getHeaderItem
in interface IWireframe
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–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.