I don't understand why you want to override renderComponent to
conditionally render individual wrapped components. Indeed since you
have based your component on BaseComponent, by definition there could
be *anything* in the body and thus it would not make sense to expect a
particular comp to exist in there.
The expression you supply to a @Conditional can invoke any old check
you like, as simple or complex as needed.
If the check you need to do is a "once per render" you can do it in a
pageRenderListener and cache the result in property that is pulled by
the expression in the @Conditional.
If its not a "once per render" put the check in a method and call the
method using the expression. The check method could take parms from
the expression: ongl:doCheck(something, somethingElse) or it could be
a no arg method that is smart enough to gather it's required data from
other properties and return the result of the check.
ognl:doCheck()
Geoff
On 8/19/05, Waimun Yeow <[EMAIL PROTECTED]> wrote:
> Hi Geoff,
>
> Supposedly, the condition is a bit complex that requires logic checking be
> done programmatically via code, eg. some business rules and database access
> to reach a decision on whether <PageLink A> should be rendered. Then, how
> should I code it in the renderComponent() body? What I am suggesting to do is
> have writer.begin("li") and then getComponent and render, finally
> writer.end(). But if this is the case, the static tags and content in the
> component template would be meaningless since I am producing it from
> writer.begin().
>
> Any advise? I am not facing this scenario now, but I think I would be in this
> situation in the nearby future.
>
> Tks.
>
> --
> waimun
>
> On 8/19/05, Geoff Longman <[EMAIL PROTECTED]> wrote:
> > No need to mess with renderComponent as there is a handy prebuilt
> > component for such tasks...
> >
> > PageLink A will render if someExpression evaluates to true (or any non
> > null value).
> >
> > <li>
> > <span jwcid="@Conditional" condition="ognl:someExpression">
> > <PageLink A>
> > </span>
> > <PageLink B></li>
> >
> > Geoff
> >
> > On 8/19/05, Waimun Yeow <[EMAIL PROTECTED]> wrote:
> > > Thank you so much!
> > >
> > > I have another question related to super.renderComponent. It's actually
> > > not a problem in my application right now, but I am anticipating that the
> > > following scenario might occur some time later:
> > >
> > > Let's suppose:
> > >
> > > 1) there are two PageLink components defined in the component spec
> > >
> > > 2) in the component template, we have <li><PageLink A><PageLink B></li>
> > >
> > > Therefore, a call to super.renderComponent will render all these tags. If
> > > I wanted to add a logic that selectively render <PageLink A> and also the
> > > enclosing <li> tag, I would getComponent for <PageLink A> and invoke
> > > render(). But what about the <li> or the other static stuff (if exists)
> > > in the component template?
> > >
> > > What would be a correct way of doing this?
> > >
> > > Thanks again.
> > >
> > > --
> > > waimun
> > >
> > > On 8/19/05, Geoff Longman <[EMAIL PROTECTED]> wrote:
> > > > override renderComponent, do your checks, then call
> > > > super.renderComponent
> > > >
> > > > Geoff
> > > >
> > > > On 8/18/05, Waimun Yeow <[EMAIL PROTECTED]> wrote:
> > > > > Hi,
> > > > >
> > > > > I am subclassing BaseComponent, and in the class renderComponent()
> > > > > method, I would like to render the contents of the component's
> > > > > template
> > > > > after some logic checks are performed and determined that the
> > > > > component
> > > > > should render.
> > > > >
> > > > > How do I do that? I tried to use render() method but I get
> > > > > stackoverflow exception.
> > > > >
> > > > > Please advise.
> > > > >
> > > > > Thanks.
> > > > >
> > > > > --
> > > > > waimun
> > > > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
The Spindle guy. http://spindle.sf.net
Get help with Spindle:
http://lists.sourceforge.net/mailman/listinfo/spindle-user
Announcement Feed:
http://www.jroller.com/rss/glongman?catname=/Announcements
Feature Updates: http://spindle.sf.net/updates
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]