Cool, that looks sensical to me. I like how I don't have to actually
have the stars in my html file. But one thing - the isEnabled() method
does not exist in the AbstractBehavior class. But I think the
following will work:
label.add(new AbstractBehavior() {
@Override public void onRendered(Component component) {
if (starIsVisible) {
Response response = component.getResponse();
response.write("<span id='foo' class='bar'>*</span>");
}
}
});
On 5/31/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> Lowell,
>
> Sorry for my bad answers today, I was doing too many things at the
> same time, and now that I re-read your use case I think I understand
> better what you want.
>
> If I'm correct, you want to decorate a label with a star, and use some
> css class or id with that star and have the ability to turn the star
> off or on depending on a condition.
>
> Disregard the rest of the thread, because indeed Labels (or any
> component replacing their bodies) don't allow nested components. Your
> best choice is to use a behavior:
>
> label.add(new AbstractBehavior() {
>
> @Override
> public boolean isEnabled(Component component) {
> return myCondition();
> }
>
> @Override
> public void onRendered(Component component) {
> Response response = component.getResponse();
> response.write("<span id='foo' class='bar'>*</span>");
> }
> });
>
> The behavior writes directly to the response (after the component
> itself is rendered) and the visibility can be steered using isEnabled.
>
> Do note that if it wasn't for the fact that you're trying to decorate
> labels, you could have used Borders instead of a behavior. Not to say
> that this is better, just be aware of the alternative (in case you are
> annotating markupcontainers).
>
> Hope this helps,
>
> Eelco
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user