As Ben Dotte pointed out already, the "tapestry" way of doing this is to
use block/render block. The nice thing about this approach is that the
blocks you define don't even have to be on the same page as the render
block (although if you start defining blocks on other pages, avoid using
page render listeners to initialize variables for those blocks).

You can even pass parameters on; you can put the parameters into the
render block as informal parameters, and get at them via the "inserter"
 property of the block.

So..

in the .html:

<span jwcid="area"/>

In the .jwc:

<component id="area" type="RenderBlock">
  <binding name="block" expression="theBlock"/>
  <binding name="foo" expression="bar"/>
</component>

.java:

  public Block getTheBlock() {
    return getRequestCycle()
            .getPage("blockpagex").getComponent("blockx");
  }


Then, on blockpagex, you might have:
<div jwcid="[EMAIL PROTECTED]">
  <!-- render some stuff -->
  <!-- note that the expression path I've got here is off the top of
       my head, and you'd want to double check it for accuracy. :) -->
  <span jwcid="@Insert" value="ognl:components.blockx.inserter.foo"/>
</div>

Robert

Stephen Todd wrote:
> I'm trying to specify which component to use dynamically, but I think
> what I want to do is outside of conventions. I wanted to do something
> like the following.
> 
> in the .html
> 
> <span jwcid="area"/>
> 
> in the .jwc
> 
> <component id="area" type="ognl:componentType"/>
> 
> and in the .java
> 
> public String getComponentType() {
>    // some code
>    return "@" + componentType; // ie. MyCoolArea
> }
> 
> (This isn't the real code)
> 
> I know I could just line up a bunch of if's but that seems wrong and
> inefficient. I know in the example above that it is trying to find
> 'componentType' in the namespace 'ognl', but I really just want to pass
> a string to specifiy the component.
> 
> Thanks,
> 
> Steve
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to