I am doing things here in a way that is backward conceptually to tapestry. I only have one page in my app and the navigation is based on state and not page location. This is because the app navigation and structure is largely dynamic. It would seem like it shouldn't be too complicated to create a Component to do this. It would be like the WOSwitchComponent in WebObjects, but then again, I am just learning tapestry and don't know the request-response cycle here.

One reason that the approach mentioned won't work, is that I don't want to have to know the component ahead of time, otherwise adding a new option to the list will become a headache. This list is currently around 10 and it will continue to grow. Any pointers to help me make this component would be great, but if not, I'll figure something out somehow.

Thanks!

Steve


Robert Zeigler wrote:

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]


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

Reply via email to