you could try to implement this as a behavior:
public class RicoCorner extends AbstractBehavior {
private Component component;
@Override
public void renderHead(IHeaderResponse response) {
// add the javascript libraries to the header
response.renderJavascriptReference(new
JavascriptResourceReference(
RicoCorner.class, "RICOSCRIPT.js"));
}
@Override
public void bind(Component component) {
super.bind(component);
if (this.component != null)
throw new IllegalStateException(
"cannot bind behavior to more than one component");
this.component = component;
this.component.setOutputMarkupId(true);
}
@Override
public void onRendered(Component component) {
super.onRendered(component);
JavascriptUtils.writeJavascript(component.getResponse(),
String.format("Rico.Corner.round('%s');", component
.getMarkupId()));
}
}
then just add the RicoCorner to the component you want to decorate.
not really the way you wanted to go (borders...), but maybe this is also a
suitable solution.
hth,
gerolf
On 7/2/07, Erik Dreyer <[EMAIL PROTECTED]> wrote:
Hi,
Thanks in advance for the help as I wrap my mind around Wicket.
I'm trying to create a Border component that, using the openRico js
library ( www.openrico.org), will output JS that will be called on load to
round its own borders.
Basically Rico works like this:
<div id="divWithRoundedCorners">... stuff goes here ...</div>
<script> Rico.Corner.round("divWithRoundedCorners");</script>
When that is rendered, Rico will round the corners of the named DIV.
So, I'm trying to figure out how to create a Border component that has the
ability to create dynamic JavaScript containing the element ID of
a div defined within the Border. Something like this:
RoundedCornerBorder.html (pseudocode):
<wicket:border>
<div id="thisIsDynamic"> <!-- How do I generate and obtain this at
runtime without getting exception (see below)? -->
<wicket:body/>
</div>
<scipt>Rico.Corner.round("divWithRoundedCorners");</script> <!-- Again,
I need the ID of the dynamic DIV to make this work -->
</wicket:border>
I am open to any suggestions as to an efficient solution.
My goal is to be able to use this border multiple times on the same page.
I've had trouble with my attempts because
when trying to call Component.getMarkupId(), I get an exception with the
following message:
WicketMessage: This component is not (yet) coupled to a page. It has to be able
to find the page it is supposed to operate in before you can call this method
(Component#getMarkupId)
Thanks,
Erik
-------------------------------------------------------------------------
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
Wicket-user@lists.sourceforge.net
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
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user