Modern Binding Styles

Version 11.1 by chuckhill on 2007/05/11 17:38

The WOComponent Editor in WOLips adds support for extensions to the bindings and different binding styles than what WebObjects Builder supported.  It is important to note the difference between development time and run time.  At development time, bindings are restricted by the editor (WebObjects Builder or WOComponent Editor).  At runtime, bindings are evaluated by the WebObjects parser.  The parser is much more flexible than what WebObjects Builder generated and it can also be replaced (as Project Wonder does).

Extensions to Standard Bindings

These formats are support by the WOComponent Editor and the WebObjects run-time parser but not by WebObjects Builder?

All in one tag:

<webobject name="FirstName"/>

Name on closing tag (useful for conditionals and repetitions that wrap a lot of content:


<webobject name="EmployeeRepetition">
    ...
    ...
    ...
</webobject name="EmployeeRepetition">

This style can make larger pages much easier to maintain. 

WOOGNL / Inline Bindings

These formats are only supported by the WOComponent Editor and the Wonder run-time parser.  You need to be using Project Wonder to be using these.

Can someone provide some good examples?

Activating Inline Bindings

Add these to the Properties file in your application:


ognl.active = true
ognl.helperFunctions=true
ognl.inlineBindings=true

If you want to be able to use this with the standard HTML tags (e.g. <img src="$dynamicPath" /> you have to add this as well:


ognl.parseStandardTags=true

Handy Tipds

Tip 1: Use <wo:not condition = "$isEditable"> instead of a negated if.  wo:not is implemented as a TagProcessor in wonder that turns into (WOConditional, negate = true, condition = whatever).

Tip 2: while <wo:whatever> is implemented in the validator as a "loose" namespace (that is, <wo:if> can be closed by </wo>), you get better error checking if you close your <wo:whatever> with </wo:whatever>.  Basically a </wo> can close any <wo:whatever>, but a </wo:somethingElse> can't.  So if you have <wo:if></wo:not> that would be an error, but <wo:if></wo> would not, so you potentially miss a family of mistakes.

Tip 3: It is possible to write: <img src="$imagePath" /> now. With ognl.parseStandardTags=true, the parser will convert that to a WOGenericContainer and pull the imagePath dynamically.

Short Names in Inline Bindings

WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOString", "string");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOString", "str");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("ERXElse", "else");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOConditional", "if");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOConditional", "condition");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOConditional", "conditional");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOHyperlink", "link");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WORepetition", "loop");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOTextField", "textfield");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOCheckBox", "checkbox");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOHiddenField", "hidden");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOPopUpButton", "select");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WORadioButton", "radio");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOPasswordField", "password");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOFileUpload", "upload");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOText", "text");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOForm", "form");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("WOSubmitButton", "submit");
WOHelperFunctionHTMLTemplateParser.registerTagShortcut("ERXLocalizedString", "localized");
WOHelperFunctionHTMLTemplateParser.registerTagProcessorForElementType(new NotTagProcessor(), "not");

WonderShortCuts.png