Using Resource to provide background attribute to td-tag?

2007-09-25 Thread wfaler

Hi,
I want to use a ResourceReference (or something comparable) to set the
background-attribute of a td-cell with an image on my classpath.
How do I achieve this?
It is quite straightforward for images, but it gets trickier with
background-images to other html elements..

/ Wille
-- 
View this message in context: 
http://www.nabble.com/Using-Resource-to-provide-background-attribute-to-td-tag--tf4515517.html#a12879415
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using Resource to provide background attribute to td-tag?

2007-09-25 Thread Gerolf Seitz
hi,
i'd say either:
myTd.add(new AttributeModifier(style, true, background-image:url( +
RequestCycle.urlFor(myImage) + );));
// use an AttributeAppender if you want to preserve an existing style
attribute

or override onComponentTag of myTd and put it in the tag like:
tag.put(style, background-image:url( + RequestCycle.urlFor(myImage) +
););

there maybe even other ways though (like interpolating a css file with the
url and rendering it in the head)

hth,
  gerolf

On 9/25/07, wfaler [EMAIL PROTECTED] wrote:


 Hi,
 I want to use a ResourceReference (or something comparable) to set the
 background-attribute of a td-cell with an image on my classpath.
 How do I achieve this?
 It is quite straightforward for images, but it gets trickier with
 background-images to other html elements..

 / Wille
 --
 View this message in context:
 http://www.nabble.com/Using-Resource-to-provide-background-attribute-to-td-tag--tf4515517.html#a12879415
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: Using Resource to provide background attribute to td-tag?

2007-09-25 Thread Al Maw

wfaler wrote:

Hi,
I want to use a ResourceReference (or something comparable) to set the
background-attribute of a td-cell with an image on my classpath.
How do I achieve this?
It is quite straightforward for images, but it gets trickier with
background-images to other html elements..


If you object to style attributes on your HTML tags, then you can do 
this by writing stuff out to the head of your page.


private static final ResourceReference IMAGE = /* ... */;
...
final Component component = /* ... */;
page.add(new AbstractBehavior() {
public void renderHead(IHeaderResponse response) {
String url = urlFor(IMAGE);

String foo = style\n;
foo += # + component.getMarkupId() +  {\n;
foo += background-image: url( + url )\n;;
foo += }\n;
foo += /style;
response.renderString(foo);
}
});

Should work. ;-)

Regards,

Al

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using Resource to provide background attribute to td-tag?

2007-09-25 Thread Gerolf Seitz
On 9/25/07, wfaler [EMAIL PROTECTED] wrote:

 I want to use a ResourceReference (or something comparable)


apparently, the words in parenthesis are sometimes more important than the
rest, so yes: keep it simple...

  gerolf