Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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:

Code Block
<webobject name="FirstName"/>

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

Code Block
<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.

Inline bindings allow you to embed wod attributes into your html template. For instance:

Code Block
<wo:WOConditional condition = "$inEditMode">Editing Now</wo:WOConditional>

or the "tag shortcut" style:

Code Block
<wo:if condition = "$inEditMode">Editing Now</wo:if>

This can often actually make templates easier to follow when used wisely. When bindings extend beyond two or three, it can often get confusing. One of the nice features of Wonder's inline binding implementation is that you can mix and match in a single template where it makes sense.

Another very useful feature of inline bindings is that you can represent a template with a single String value, which makes it easier to provide features like dynamic templates that load out of a database (see ERXInlineTemplate in Project Wonder).

For more extensive details on inline bindings (and helper functions, which come along with it), read the following wotips post:

Note
title"How Do I Specify Constants?"

Precede any inline binding whether keypath or constant with $ symbol. So the constant true would be condition="$true" and the constant 345 would be written like value="$345"

Activating Inline Bindings

Add these to the Properties file in your application:

Code Block
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:

Code Block
ognl.parseStandardTags=true

Handy Tips

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");

Mike Schrag's Inline Binding Shortcuts