You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Erik Hatcher <er...@ehatchersolutions.com> on 2003/12/17 22:29:15 UTC

Block inserter

Anyone know how to utilize the inserter property of Block?

I've written a very simple component that mimics RenderBlock, but has a 
domain specific property on it.  And I'd like for the block itself to 
be able to access the property from its "inserter".  I've tried 
"ognl:inserter.<propertyName>" but I get an 
ognl.NoSuchPropertyException on inserter.

Alternatively, I'm looking for ways to render blocks dynamically but 
pass it objects (rather than the block accessing page-level properties 
directly).  Suggestions?

Thanks,
	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Block inserter

Posted by Richard Lewis-Shell <rl...@mac.com>.
If your RenderBlock is given an informal parameter named "fred" that you
want the components inside your Block to be able to access, you would get
the value from such a component like so:
<component id="insertFred" type="Insert">
    <binding name="value"
expression='components.nameOfEnclosingBlock.inserter.bindings.value.object'/
>
</component>

I have some example/test pages that show this working that I can share if
you are interested (but they will not work as-is as they extend custom
unshareable code - though it would be trivial to remove those
dependencies)...

R

----- Original Message ----- 
From: "Richard Lewis-Shell" <rl...@mac.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, December 18, 2003 10:58 AM
Subject: Re: Block inserter


> RenderBlock will set the inserter property of the Block it is rendering to
> itself - are you using RenderBlock?  (now the component has been renamed,
> that property should probably be named 'renderer' now).
>
> So once you have the inserter, you can access its properties, or
bindings -
> remember that the inserter is probably the RenderBlock, so you might want
to
> pass some informal-parameters to the RenderBlock.  Which is exactly what
we
> do...
>
> R
>
> ----- Original Message ----- 
> From: "Erik Hatcher" <er...@ehatchersolutions.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Thursday, December 18, 2003 10:29 AM
> Subject: Block inserter
>
>
> > Anyone know how to utilize the inserter property of Block?
> >
> > I've written a very simple component that mimics RenderBlock, but has a
> > domain specific property on it.  And I'd like for the block itself to
> > be able to access the property from its "inserter".  I've tried
> > "ognl:inserter.<propertyName>" but I get an
> > ognl.NoSuchPropertyException on inserter.
> >
> > Alternatively, I'm looking for ways to render blocks dynamically but
> > pass it objects (rather than the block accessing page-level properties
> > directly).  Suggestions?
> >
> > Thanks,
> > Erik
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Block inserter

Posted by Richard Lewis-Shell <rl...@mac.com>.
Of course, a Block is still needed to prevent the component rendering on the
page where it is defined.  Although if the component is not specified in the
template, it will not render anyway, but Tapestry will then warn of this.

I don't think I explained the binding copying approach we use very well,
but here is a summary of the pros/cons of the two approaches I know about to
solve this.

Dynamic binding copying (we use)
+ simple to use as components being rendered elsewhere need specify no
bindings, but this means:
- cannot use required parameters <parameter ... required="true"/>, as they
will not be specified until the component renders
- expensive at render time because the informal bindings from the renderer
will be copied to the component (and its contained components) EVERY time it
renders.

Static inserter bindings (we have tested, but not implemented)
- requires complex static (ie. up-front) bindings for components being
rendered elsewhere
+ no expensive component graph traversal/binding manipulation
+ can use required parameters, as parameters are bound statically
- all parameters must be explicitly bound - cannot use unknown informal
bindings

I had thought that the complexity involved in the dynamic binding copying
approach was enough to warrant changing our application to use the static
inserter binding approach, but now that I look at the amount of code that
would need to be changed, and the inflexibility of the latter, I think I now
favour our status quo.

R

----- Original Message ----- 
From: "Richard Lewis-Shell" <rl...@mac.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, December 19, 2003 8:52 AM
Subject: Re: Block inserter


> Yeah - it is a bit of a mouthful.
>
> I had thought that this was the mechanism we used to do what you are
> wanting, but I just double checked, and it is not.  We are still using a
> custom RenderBlock-like component that copies its informal bindings to a
> particular component contained in the Block - this means those gluing the
> components together do not have to worry about such awkward expressions,
> only specifying which component in the block is the destination for the
> copied informal bindings.  We use this pattern with only a single
component
> inside the Block.  Hmmm, which makes me think the Block is itself
redundant,
> and I now wonder if our custom RenderBlock could instead Render any old
> component?  But I digress...
>
> R
>
> ----- Original Message ----- 
> From: "Erik Hatcher" <er...@ehatchersolutions.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Friday, December 19, 2003 4:05 AM
> Subject: Re: Block inserter
>
>
> > On Wednesday, December 17, 2003, at 05:19  PM, Richard Lewis-Shell
> > wrote:
> > > i think you want:
> > > <span jwcid="block@Block">
> > >    <span jwcid="@Insert"
> > > value="ognl:components.block.inserter.bindings.prop.object"/>
> > > </span>
> > >
> > > note you have to dereference the binding directly as the RenderBlock
> > > does
> > > not have a 'prop' property.
> > >
> > > i am assuming that you are rendering the block using:
> > > <span jwcid="@RenderBlock" block="ognl:some.expression.to.your.block"
> > > prop="ognl:some.value"/>
> >
> > Richard,
> >
> > Thanks for those details - it works fine.
> > components.<name>.inserter.bindings.<propertyName>.object.<subProperties
> >  > is just too crazy of an expression for me to contemplate using for
> > our current needs though :)
> >
> > I'm going to tinker with some other ideas and see what pans out.
> >
> > Although, I'm sure we could simplify that expression somehow.  It would
> > be cool if there was a simpler expression to get at informal parameters.
> >
> > Erik
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Block inserter

Posted by Richard Lewis-Shell <rl...@mac.com>.
Yeah - it is a bit of a mouthful.

I had thought that this was the mechanism we used to do what you are
wanting, but I just double checked, and it is not.  We are still using a
custom RenderBlock-like component that copies its informal bindings to a
particular component contained in the Block - this means those gluing the
components together do not have to worry about such awkward expressions,
only specifying which component in the block is the destination for the
copied informal bindings.  We use this pattern with only a single component
inside the Block.  Hmmm, which makes me think the Block is itself redundant,
and I now wonder if our custom RenderBlock could instead Render any old
component?  But I digress...

R

----- Original Message ----- 
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, December 19, 2003 4:05 AM
Subject: Re: Block inserter


> On Wednesday, December 17, 2003, at 05:19  PM, Richard Lewis-Shell
> wrote:
> > i think you want:
> > <span jwcid="block@Block">
> >    <span jwcid="@Insert"
> > value="ognl:components.block.inserter.bindings.prop.object"/>
> > </span>
> >
> > note you have to dereference the binding directly as the RenderBlock
> > does
> > not have a 'prop' property.
> >
> > i am assuming that you are rendering the block using:
> > <span jwcid="@RenderBlock" block="ognl:some.expression.to.your.block"
> > prop="ognl:some.value"/>
>
> Richard,
>
> Thanks for those details - it works fine.
> components.<name>.inserter.bindings.<propertyName>.object.<subProperties
>  > is just too crazy of an expression for me to contemplate using for
> our current needs though :)
>
> I'm going to tinker with some other ideas and see what pans out.
>
> Although, I'm sure we could simplify that expression somehow.  It would
> be cool if there was a simpler expression to get at informal parameters.
>
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Block inserter

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Wednesday, December 17, 2003, at 05:19  PM, Richard Lewis-Shell  
wrote:
> i think you want:
> <span jwcid="block@Block">
>    <span jwcid="@Insert"
> value="ognl:components.block.inserter.bindings.prop.object"/>
> </span>
>
> note you have to dereference the binding directly as the RenderBlock  
> does
> not have a 'prop' property.
>
> i am assuming that you are rendering the block using:
> <span jwcid="@RenderBlock" block="ognl:some.expression.to.your.block"
> prop="ognl:some.value"/>

Richard,

Thanks for those details - it works fine.   
components.<name>.inserter.bindings.<propertyName>.object.<subProperties 
 > is just too crazy of an expression for me to contemplate using for  
our current needs though :)

I'm going to tinker with some other ideas and see what pans out.

Although, I'm sure we could simplify that expression somehow.  It would  
be cool if there was a simpler expression to get at informal parameters.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Block inserter

Posted by Richard Lewis-Shell <rl...@mac.com>.
i think you want:
<span jwcid="block@Block">
   <span jwcid="@Insert"
value="ognl:components.block.inserter.bindings.prop.object"/>
</span>

note you have to dereference the binding directly as the RenderBlock does
not have a 'prop' property.

i am assuming that you are rendering the block using:
<span jwcid="@RenderBlock" block="ognl:some.expression.to.your.block"
prop="ognl:some.value"/>

R

----- Original Message ----- 
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, December 18, 2003 11:11 AM
Subject: Re: Block inserter


> On Wednesday, December 17, 2003, at 04:58  PM, Richard Lewis-Shell
> wrote:
> > So once you have the inserter, you can access its properties, or
> > bindings -
> > remember that the inserter is probably the RenderBlock, so you might
> > want to
> > pass some informal-parameters to the RenderBlock.  Which is exactly
> > what we
> > do...
>
> Could you share an example of how you do this?
>
> I was doing something like this:
>
> <span jwcid="block@Block">
>    <span jwcid="@Insert" value="ognl:inserter.prop"/>
> </span>
>
> But it wasn't happy about "inserter".
>
> Thanks,
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Block inserter

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Wednesday, December 17, 2003, at 04:58  PM, Richard Lewis-Shell 
wrote:
> So once you have the inserter, you can access its properties, or 
> bindings -
> remember that the inserter is probably the RenderBlock, so you might 
> want to
> pass some informal-parameters to the RenderBlock.  Which is exactly 
> what we
> do...

Could you share an example of how you do this?

I was doing something like this:

<span jwcid="block@Block">
   <span jwcid="@Insert" value="ognl:inserter.prop"/>
</span>

But it wasn't happy about "inserter".

Thanks,
	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Block inserter

Posted by Richard Lewis-Shell <rl...@mac.com>.
RenderBlock will set the inserter property of the Block it is rendering to
itself - are you using RenderBlock?  (now the component has been renamed,
that property should probably be named 'renderer' now).

So once you have the inserter, you can access its properties, or bindings -
remember that the inserter is probably the RenderBlock, so you might want to
pass some informal-parameters to the RenderBlock.  Which is exactly what we
do...

R

----- Original Message ----- 
From: "Erik Hatcher" <er...@ehatchersolutions.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, December 18, 2003 10:29 AM
Subject: Block inserter


> Anyone know how to utilize the inserter property of Block?
>
> I've written a very simple component that mimics RenderBlock, but has a
> domain specific property on it.  And I'd like for the block itself to
> be able to access the property from its "inserter".  I've tried
> "ognl:inserter.<propertyName>" but I get an
> ognl.NoSuchPropertyException on inserter.
>
> Alternatively, I'm looking for ways to render blocks dynamically but
> pass it objects (rather than the block accessing page-level properties
> directly).  Suggestions?
>
> Thanks,
> Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org