You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andreas Bulling <sp...@phoenix.hadiko.de> on 2006/03/25 13:08:11 UTC
Component wraps itself
Hi all,
and here is another short question:
As I didn't get to know how to "mix" a BaseComponent derived
component with a AbstractComponent derived one (using a
component html template _and_ output some html code with
IMarkupWriter) I decided to switch to AbstractComponent completely.
I was able to change the former ognl code "page.admin" in the component
template (which checks if a admin user is logged in and displays the
component only in this single case) by calling cycle.getPage() and
casting to my custom page object (which is not portable to other
apps - if you have an idea how to fix this please let me know).
But what I wasn't able to achieve is to do a wrapping of the component
with another one in Java. My AdminPanel component included a "ShowPanel"
component to have a box printed around it.
AdminPanel:
<body jwcid="$content$">
<span jwcid="@If" condition="ognl:page.admin">
<span id="adminpanel">
<span jwcid="@ShowPanel" width="250" color="red">
...
</span>
</span>
</span>
</body>
Within AdminPanel I can output all the html markup I want but how
can I achieve to wrap all this output with a ShowPanel instance?
I tried to do
IComponent panel = getComponent("panel");
panel.addBody(this);
... markup from AdminPanel
panel.render(writer, cycle);
but this doesn't work :(
If you can't understand what I mean please reply and I will try
to explain better ;)
Thanks for your help,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Component wraps itself
Posted by Andreas Bulling <sp...@phoenix.hadiko.de>.
On 25. Mär 2006 - 15:12:01, andyhot@di.uoa.gr wrote:
| BaseComponents can have html templates.
| But you can also override their
| renderComponent(IMarkupWriter writer, IRequestCycle cycle) and:
| - output your own stuff in writer,
| - call super.renderComponent(IMarkupWriter writer, IRequestCycle cycle) to have
| the html template rendered
| - output some more of your stuff.
OK, but is it possible to define where in the template the output
is printed?
| Now, i'm not sure i understand your last question, but an AbstractComponent
| can render the html+components it encloses using
| getContainer().renderBody(writer, cycle);
Well, I will try to explain again in this case - no problem ;)
I have one component ShowPanel (derived from AbstractComponent)
which just outputs some kind of "box" around other components.
I use it for forms but also for information panels which hold
information about records etc. It has to extend AbstractComponent
because it uses some parameters (width, color, ...) to calculate
dimensions, create css classes, etc. for it's output.
As one of these information panels I want an "AdminPanel" which displays
information about the current database record displayed on the page.
As this information can contain a date for example I needed some way
to localize the raw data from the database before it gets outputted
on the page. My idea was to implement something similar to the
contribTable component where nested Block components can be used to
format columns (values in my case). This is why also AdminPanel
needs to extend AbstractComponent (at least I think so).
The "nested-Block-thing" works, but:
The "AdminPanel" also shall be wrapped in a "ShowPanel" component
described above to achieve the same look-and-feel and that's
the problem: How can I let the AdminPanel wrap itself in a
"ShowPanel" component? That means: The html output to be included
in the ShowPanel's body is created in the AdminPanel component
and this same component has to wrap itself with a ShowPanel box.
If this is weird or insane I'm looking forward to your
proposols but I don't see how to make things easier here...
Sincerly,
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Component wraps itself
Posted by an...@di.uoa.gr.
>From Andreas Bulling <sp...@phoenix.hadiko.de>:
> Hi all,
> and here is another short question:
> As I didn't get to know how to "mix" a BaseComponent derived
> component with a AbstractComponent derived one (using a
> component html template _and_ output some html code with
> IMarkupWriter) I decided to switch to AbstractComponent completely.
BaseComponents can have html templates.
But you can also override their
renderComponent(IMarkupWriter writer, IRequestCycle cycle) and:
- output your own stuff in writer,
- call super.renderComponent(IMarkupWriter writer, IRequestCycle cycle) to have
the html template rendered
- output some more of your stuff.
Now, i'm not sure i understand your last question, but an AbstractComponent
can render the html+components it encloses using
getContainer().renderBody(writer, cycle);
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org