2009/6/5 Inge Solvoll <inge.tapes...@gmail.com>:
> From your explanation, I think you're looking for something like this? This
> should be pretty close to working code.
>
> yourPage.tml:
> <div t:type="yourComponent">
>  <p:param1>
>   Lots of HTML here
>  </p:param1>
> </div>
>
> public class YourComponent {
> @Parameter
> private Block param1;
> }
>
> yourComponent.tml:
> <html>
> <t:delegate to="param1"/>
> </html>
>

Nearly, but not exactly. I'm looking for elastic way to decorate
(=surround by html code) internal part of component. Block passed by
parameter cannot surround anything.

I'll show exactly what i'm looking for by simple example:
Suppose, I have a component:

ComplexComponent.tml
<div>
   ...
   a lot of tags and components
   ...
           <span id="title">
               .. complex content ..
           </div>
   ...
   a lot of other tags and components
   ...
</div>

ComplexComponent is very usefull. I use it repeatedly on pages. BUT in
some cases I need "title" to be hyperlink to Tapestry page, in other
cases hyperlink to another page, sometimes external hyperlink or
"mailto:"; link. In other cases I need decorate it by border, complex
and unrealizable by only CSS. And finally, I'd like to have
possibility to define any other surrounding of title in the future,
preferably without changing ComplexComponent.

For now, I know 2 solutions:

1. Huge "if".
Disadvantage: Adding new decoration requires change of
ComplexComponent. Some of decorations can be very simple and can be
used only once. This is the best way to create rubbish component.
Reusabilty of such a component: very low.


2. Passing by parameters texts to place before and after title.
-----------------------------------------------------------------
ComplexComponent.tml
<div>
   ...
   a lot of tags and components
   ...
           <t:outputRaw value="beforeTitle"/>
           <span id="title">
               .. complex content ..
           </div>
           <t:outputRaw value="afterTitle"/>
   ...
   a lot of other tags and components
   ...
</div>
----------------------------------------------------
ComplexComponent.java

...
@Parameter @Property String beforeTitle;
@Parameter @Property String afterTitle;
----------------------------------------------------
Page.tml
...
<t:complexComponent
      beforeTitle="literal:<a href='...'>"
      afterTitle="</a>" />
...
-----------------------------------------------------------------

Awful!!! Disgusting!!!
And components (eg PageLink) cannot be used to render hyperlink. :(


Do you have any better solutions?

Regards
Lukasz

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to