DynamicBlock Part II - DynamicBlock now allows a Body

I've modified the DynamicBlock component to allow it to wrap some other content. this means that you can use DynamicBlock to do things like use a different PageBorder for different users with the same content in the middle.

RenderBlock cannot contain a body, the Block it renders can, but if I want to put the same content inside different blocks I would have to duplicate it or turn it into another component. DynamicBlock makes the process a whole lot easier.

The changes I've made to DynamicBlock allow me to declare it with a body:

<span jwcid="switchBlock"> <p> This is the body, wrapped by the switched component. I'm not sure if this should really work and what effect, if any it has on page listeners, or component paths, but it does render! </p> <p> And to prove that components can be wrapped as well, todays date is: <span jwcid="@Insert" value="ognl:script.calcTodaysDate()"/>. </p> </span>

The specification stays the same:

<component id="switchBlock" type="DynamicBlock"> <binding name="componentName" expression="selectedComponentName" /> </component>


The components rendered by DynamicBlock (names bound to the componentName parameter) must allow a body and include a RenderBody component:

<span jwcid="$content$"> <h1>1</h1> <span jwcid="@RenderBody"/> </span>

Looking at the code changes I have made to get this to work, I'm not exactly sure why it works, but it does do what I want it to do. Perhaps someone who knows the guts of the Tapestry component body rendering process better than me can review the source code and see if there are any side effects to this.

I have uploaded a modified example application and source-code.

This DynamicBlock is a little less bare-bones, I still need to figure out how to pass parameters from the DynamicBlock to the component.

See the updated example at: http://examples.mjhenderson.com/dynamicblock/app

Get the source code: dynamicblock-with-body-src.tgz