|
View:
New views
14 Messages
—
Rating Filter:
Alert me
|
|
|
How to make img src in a component's template resolve to the image files in the package?Say I have my component in a package "com.mycompany.component"
== MyCmponent.java: class MyComponent extends Panel ... == MyComponent.html: <html xmlns:wicket> <body> <wicket:panel> <img wicket:id="open" src="/resources/com.mycompany.component.MyComponent/open.png"/> </wicket:panel> </body> </html> I don't want to hard code "/resources/com.mycompany.component.MyComponent/open.png" in the template and just have <img src="open.png" .../>. Is there someway to work out the prefix "/resources/com.mycompany.component.MyComponent/" and fix up src attribute in code? |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?On Sun, Mar 30, 2008 at 7:45 PM, Matthew Young <ginyeah@...> wrote:
> ... > I don't want to hard code > "/resources/com.mycompany.component.MyComponent/open.png" in the template > and just have <img src="open.png" .../>. Is there someway to work out the > prefix "/resources/com.mycompany.component.MyComponent/" and fix up src > attribute in code? If you are in a Component you can call Component#urlFor(). If not in a Component, you can call: RequestCycle.get()#urlFor(); You can use the form that takes a ResourceReference for the image. HTH, Enrique --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?Use wicket:link tags around the image
-igor On 3/30/08, Enrique Rodriguez <enriquer9@...> wrote: > On Sun, Mar 30, 2008 at 7:45 PM, Matthew Young <ginyeah@...> wrote: > > ... > > I don't want to hard code > > "/resources/com.mycompany.component.MyComponent/open.png" in the template > > and just have <img src="open.png" .../>. Is there someway to work out > the > > prefix "/resources/com.mycompany.component.MyComponent/" and fix up src > > attribute in code? > > If you are in a Component you can call Component#urlFor(). > > If not in a Component, you can call: > > RequestCycle.get()#urlFor(); > > You can use the form that takes a ResourceReference for the image. > > HTH, > > Enrique > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?So I did this:
<html xmlns:wicket> <body> <wicket:panel> <wicket:link><img wicket:id="open" src="open.png"/></wicket:link> </wicket:panel> </body> </html> the src attr doesn't change, it stays as "open.png" and not change to "/resources/com.mycompany.component.MyComponent/open.png" On Sun, Mar 30, 2008 at 8:37 PM, <igor.vaynberg@...> wrote: > Use wicket:link tags around the image > > -igor > > On 3/30/08, Enrique Rodriguez <enriquer9@...> wrote: > > On Sun, Mar 30, 2008 at 7:45 PM, Matthew Young <ginyeah@...> > wrote: > > > ... > > > I don't want to hard code > > > "/resources/com.mycompany.component.MyComponent/open.png" in the > template > > > and just have <img src="open.png" .../>. Is there someway to work out > > the > > > prefix "/resources/com.mycompany.component.MyComponent/" and fix up > src > > > attribute in code? > > > > If you are in a Component you can call Component#urlFor(). > > > > If not in a Component, you can call: > > > > RequestCycle.get()#urlFor(); > > > > You can use the form that takes a ResourceReference for the image. > > > > HTH, > > > > Enrique > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@... > > For additional commands, e-mail: users-help@... > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?thats because you have a wicket:id there. wicket:link doesnt touch
components afaik -igor On Sun, Mar 30, 2008 at 8:57 PM, Matthew Young <ginyeah@...> wrote: > So I did this: > > > <html xmlns:wicket> > <body> > <wicket:panel> > <wicket:link><img wicket:id="open" src="open.png"/></wicket:link> > </wicket:panel> > </body> > </html> > > the src attr doesn't change, it stays as "open.png" and not change to > > "/resources/com.mycompany.component.MyComponent/open.png" > > > > On Sun, Mar 30, 2008 at 8:37 PM, <igor.vaynberg@...> wrote: > > > Use wicket:link tags around the image > > > > -igor > > > > On 3/30/08, Enrique Rodriguez <enriquer9@...> wrote: > > > On Sun, Mar 30, 2008 at 7:45 PM, Matthew Young <ginyeah@...> > > wrote: > > > > ... > > > > I don't want to hard code > > > > "/resources/com.mycompany.component.MyComponent/open.png" in the > > template > > > > and just have <img src="open.png" .../>. Is there someway to work out > > > the > > > > prefix "/resources/com.mycompany.component.MyComponent/" and fix up > > src > > > > attribute in code? > > > > > > If you are in a Component you can call Component#urlFor(). > > > > > > If not in a Component, you can call: > > > > > > RequestCycle.get()#urlFor(); > > > > > > You can use the form that takes a ResourceReference for the image. > > > > > > HTH, > > > > > > Enrique > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscribe@... > > > For additional commands, e-mail: users-help@... > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@... > > For additional commands, e-mail: users-help@... > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?>wicket:link doesnt touch components afaik
:((((( I need it to be a component. My code is basically this: add(new WebMarkupContainer("img")); Can I do something like this: add(new WebMarkupContainer("img") { @Override protected void onComponentTag(final ComponentTag tag) { super.onComponentTag(tag); tag.put("src", GIVE-ME-YOU-LOCATION-PLEASE + tag.getString("src")); } }); where "GIVE-ME-YOU-LOCATION-PLEASE" is some method to get "/resources/com.mycompany.component.MyComponent/"? On Sun, Mar 30, 2008 at 9:05 PM, Igor Vaynberg <igor.vaynberg@...> wrote: > thats because you have a wicket:id there. wicket:link doesnt touch > components afaik > > -igor > > > On Sun, Mar 30, 2008 at 8:57 PM, Matthew Young <ginyeah@...> wrote: > > So I did this: > > > > > > <html xmlns:wicket> > > <body> > > <wicket:panel> > > <wicket:link><img wicket:id="open" src="open.png"/></wicket:link> > > </wicket:panel> > > </body> > > </html> > > > > the src attr doesn't change, it stays as "open.png" and not change to > > > > "/resources/com.mycompany.component.MyComponent/open.png" > > > > > > > > On Sun, Mar 30, 2008 at 8:37 PM, <igor.vaynberg@...> wrote: > > > > > Use wicket:link tags around the image > > > > > > -igor > > > > > > On 3/30/08, Enrique Rodriguez <enriquer9@...> wrote: > > > > On Sun, Mar 30, 2008 at 7:45 PM, Matthew Young <ginyeah@...> > > > wrote: > > > > > ... > > > > > I don't want to hard code > > > > > "/resources/com.mycompany.component.MyComponent/open.png" in the > > > template > > > > > and just have <img src="open.png" .../>. Is there someway to work > out > > > > the > > > > > prefix "/resources/com.mycompany.component.MyComponent/" and fix > up > > > src > > > > > attribute in code? > > > > > > > > If you are in a Component you can call Component#urlFor(). > > > > > > > > If not in a Component, you can call: > > > > > > > > RequestCycle.get()#urlFor(); > > > > > > > > You can use the form that takes a ResourceReference for the image. > > > > > > > > HTH, > > > > > > > > Enrique > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: users-unsubscribe@... > > > > For additional commands, e-mail: users-help@... > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscribe@... > > > For additional commands, e-mail: users-help@... > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?urlfor(new ResourceReference(MyComponent.class, "image.png"));
-igor On Sun, Mar 30, 2008 at 9:28 PM, Matthew Young <ginyeah@...> wrote: > >wicket:link doesnt touch components afaik > > :((((( I need it to be a component. My code is basically this: > > add(new WebMarkupContainer("img")); > > Can I do something like this: > > add(new WebMarkupContainer("img") { > > @Override protected void onComponentTag(final ComponentTag tag) > { > super.onComponentTag(tag); > tag.put("src", GIVE-ME-YOU-LOCATION-PLEASE + tag.getString("src")); > } > > }); > > where "GIVE-ME-YOU-LOCATION-PLEASE" is some method to get > "/resources/com.mycompany.component.MyComponent/"? > > On Sun, Mar 30, 2008 at 9:05 PM, Igor Vaynberg <igor.vaynberg@...> > > > wrote: > > > thats because you have a wicket:id there. wicket:link doesnt touch > > components afaik > > > > -igor > > > > > > On Sun, Mar 30, 2008 at 8:57 PM, Matthew Young <ginyeah@...> wrote: > > > So I did this: > > > > > > > > > <html xmlns:wicket> > > > <body> > > > <wicket:panel> > > > <wicket:link><img wicket:id="open" src="open.png"/></wicket:link> > > > </wicket:panel> > > > </body> > > > </html> > > > > > > the src attr doesn't change, it stays as "open.png" and not change to > > > > > > "/resources/com.mycompany.component.MyComponent/open.png" > > > > > > > > > > > > On Sun, Mar 30, 2008 at 8:37 PM, <igor.vaynberg@...> wrote: > > > > > > > Use wicket:link tags around the image > > > > > > > > -igor > > > > > > > > On 3/30/08, Enrique Rodriguez <enriquer9@...> wrote: > > > > > On Sun, Mar 30, 2008 at 7:45 PM, Matthew Young <ginyeah@...> > > > > wrote: > > > > > > ... > > > > > > I don't want to hard code > > > > > > "/resources/com.mycompany.component.MyComponent/open.png" in the > > > > template > > > > > > and just have <img src="open.png" .../>. Is there someway to work > > out > > > > > the > > > > > > prefix "/resources/com.mycompany.component.MyComponent/" and fix > > up > > > > src > > > > > > attribute in code? > > > > > > > > > > If you are in a Component you can call Component#urlFor(). > > > > > > > > > > If not in a Component, you can call: > > > > > > > > > > RequestCycle.get()#urlFor(); > > > > > > > > > > You can use the form that takes a ResourceReference for the image. > > > > > > > > > > HTH, > > > > > > > > > > Enrique > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: users-unsubscribe@... > > > > > For additional commands, e-mail: users-help@... > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: users-unsubscribe@... > > > > For additional commands, e-mail: users-help@... > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@... > > For additional commands, e-mail: users-help@... > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?>urlfor(new ResourceReference(MyComponent.class, "image.png"));
Alright! That works. And Enrique, now I understand what you were telling me. Thanks. Igor, I made this little thing: public class PackageImage extends WebComponent { private static final long serialVersionUID = 1L; private Class<?> location; public PackageImage(String id, Class<?> location) { super(id); this.location = location; } @Override protected void onComponentTag(final ComponentTag tag) { checkComponentTag(tag, "img"); super.onComponentTag(tag); tag.put("src", urlFor(new ResourceReference(location, tag.getString ("src").toString()))); } } So that I can have in MyComponent.html: <img wicket:id="img" src="open.png"/> <-- just the image file name --> and in MyComponent.java: add(new PackageImage("img", MyComponent.class)); And this gets the src fixed up to point to the image file. I think it could be useful in general. Should Wicket have one built-in? On Sun, Mar 30, 2008 at 9:33 PM, Igor Vaynberg <igor.vaynberg@...> wrote: > urlfor(new ResourceReference(MyComponent.class, "image.png")); > > -igor > > > On Sun, Mar 30, 2008 at 9:28 PM, Matthew Young <ginyeah@...> wrote: > > >wicket:link doesnt touch components afaik > > > > :((((( I need it to be a component. My code is basically this: > > > > add(new WebMarkupContainer("img")); > > > > Can I do something like this: > > > > add(new WebMarkupContainer("img") { > > > > @Override protected void onComponentTag(final ComponentTag tag) > > { > > super.onComponentTag(tag); > > tag.put("src", GIVE-ME-YOU-LOCATION-PLEASE + tag.getString > ("src")); > > } > > > > }); > > > > where "GIVE-ME-YOU-LOCATION-PLEASE" is some method to get > > "/resources/com.mycompany.component.MyComponent/"? > > > > On Sun, Mar 30, 2008 at 9:05 PM, Igor Vaynberg <igor.vaynberg@... > > > > > > > > wrote: > > > > > thats because you have a wicket:id there. wicket:link doesnt touch > > > components afaik > > > > > > -igor > > > > > > > > > On Sun, Mar 30, 2008 at 8:57 PM, Matthew Young <ginyeah@...> > wrote: > > > > So I did this: > > > > > > > > > > > > <html xmlns:wicket> > > > > <body> > > > > <wicket:panel> > > > > <wicket:link><img wicket:id="open" src="open.png > "/></wicket:link> > > > > </wicket:panel> > > > > </body> > > > > </html> > > > > > > > > the src attr doesn't change, it stays as "open.png" and not change > to > > > > > > > > "/resources/com.mycompany.component.MyComponent/open.png" > > > > > > > > > > > > > > > > On Sun, Mar 30, 2008 at 8:37 PM, <igor.vaynberg@...> wrote: > > > > > > > > > Use wicket:link tags around the image > > > > > > > > > > -igor > > > > > > > > > > On 3/30/08, Enrique Rodriguez <enriquer9@...> wrote: > > > > > > On Sun, Mar 30, 2008 at 7:45 PM, Matthew Young < > ginyeah@...> > > > > > wrote: > > > > > > > ... > > > > > > > I don't want to hard code > > > > > > > "/resources/com.mycompany.component.MyComponent/open.png" in > the > > > > > template > > > > > > > and just have <img src="open.png" .../>. Is there someway to > work > > > out > > > > > > the > > > > > > > prefix "/resources/com.mycompany.component.MyComponent/" and > fix > > > up > > > > > src > > > > > > > attribute in code? > > > > > > > > > > > > If you are in a Component you can call Component#urlFor(). > > > > > > > > > > > > If not in a Component, you can call: > > > > > > > > > > > > RequestCycle.get()#urlFor(); > > > > > > > > > > > > You can use the form that takes a ResourceReference for the > image. > > > > > > > > > > > > HTH, > > > > > > > > > > > > Enrique > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > To unsubscribe, e-mail: users-unsubscribe@... > > > > > > For additional commands, e-mail: users-help@... > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: users-unsubscribe@... > > > > > For additional commands, e-mail: users-help@... > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscribe@... > > > For additional commands, e-mail: users-help@... > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?so if that is all it does why does it need to be a component?
also you shouldnt keep references to Class objects in your components, app server will have trouble restarting the app when it tries to unload it...so keep the class name instead as far as having something like this by default in wicket, and this is my personal opinion, your class only has 2-3 lines of code that actually do anything, so i would say it is trivial. i can come up with at least 10 trivial classes that have to do with images off the top of my head, if we put them all into wicket it will get very cluttered very quickly. so i would say, no, it takes 10 minutes to write one. -igor On Sun, Mar 30, 2008 at 11:06 PM, Matthew Young <ginyeah@...> wrote: > >urlfor(new ResourceReference(MyComponent.class, "image.png")); > > Alright! That works. > > And Enrique, now I understand what you were telling me. Thanks. > > > Igor, I made this little thing: > > public class PackageImage extends WebComponent { > private static final long serialVersionUID = 1L; > private Class<?> location; > > public PackageImage(String id, Class<?> location) { > super(id); > this.location = location; > > } > > @Override protected void onComponentTag(final ComponentTag tag) { > checkComponentTag(tag, "img"); > super.onComponentTag(tag); > tag.put("src", urlFor(new ResourceReference(location, tag.getString > ("src").toString()))); > } > > } > > > So that I can have in MyComponent.html: > > <img wicket:id="img" src="open.png"/> <-- just the image file > name --> > > and in MyComponent.java: > > add(new PackageImage("img", MyComponent.class)); > > And this gets the src fixed up to point to the image file. I think it could > be useful in general. Should Wicket have one built-in? > > > > On Sun, Mar 30, 2008 at 9:33 PM, Igor Vaynberg <igor.vaynberg@...> > > > wrote: > > > urlfor(new ResourceReference(MyComponent.class, "image.png")); > > > > -igor > > > > > > On Sun, Mar 30, 2008 at 9:28 PM, Matthew Young <ginyeah@...> wrote: > > > >wicket:link doesnt touch components afaik > > > > > > :((((( I need it to be a component. My code is basically this: > > > > > > add(new WebMarkupContainer("img")); > > > > > > Can I do something like this: > > > > > > add(new WebMarkupContainer("img") { > > > > > > @Override protected void onComponentTag(final ComponentTag tag) > > > { > > > super.onComponentTag(tag); > > > tag.put("src", GIVE-ME-YOU-LOCATION-PLEASE + tag.getString > > ("src")); > > > } > > > > > > }); > > > > > > where "GIVE-ME-YOU-LOCATION-PLEASE" is some method to get > > > "/resources/com.mycompany.component.MyComponent/"? > > > > > > On Sun, Mar 30, 2008 at 9:05 PM, Igor Vaynberg <igor.vaynberg@... > > > > > > > > > > > > wrote: > > > > > > > thats because you have a wicket:id there. wicket:link doesnt touch > > > > components afaik > > > > > > > > -igor > > > > > > > > > > > > On Sun, Mar 30, 2008 at 8:57 PM, Matthew Young <ginyeah@...> > > wrote: > > > > > So I did this: > > > > > > > > > > > > > > > <html xmlns:wicket> > > > > > <body> > > > > > <wicket:panel> > > > > > <wicket:link><img wicket:id="open" src="open.png > > "/></wicket:link> > > > > > </wicket:panel> > > > > > </body> > > > > > </html> > > > > > > > > > > the src attr doesn't change, it stays as "open.png" and not change > > to > > > > > > > > > > "/resources/com.mycompany.component.MyComponent/open.png" > > > > > > > > > > > > > > > > > > > > On Sun, Mar 30, 2008 at 8:37 PM, <igor.vaynberg@...> wrote: > > > > > > > > > > > Use wicket:link tags around the image > > > > > > > > > > > > -igor > > > > > > > > > > > > On 3/30/08, Enrique Rodriguez <enriquer9@...> wrote: > > > > > > > On Sun, Mar 30, 2008 at 7:45 PM, Matthew Young < > > ginyeah@...> > > > > > > wrote: > > > > > > > > ... > > > > > > > > I don't want to hard code > > > > > > > > "/resources/com.mycompany.component.MyComponent/open.png" in > > the > > > > > > template > > > > > > > > and just have <img src="open.png" .../>. Is there someway to > > work > > > > out > > > > > > > the > > > > > > > > prefix "/resources/com.mycompany.component.MyComponent/" and > > fix > > > > up > > > > > > src > > > > > > > > attribute in code? > > > > > > > > > > > > > > If you are in a Component you can call Component#urlFor(). > > > > > > > > > > > > > > If not in a Component, you can call: > > > > > > > > > > > > > > RequestCycle.get()#urlFor(); > > > > > > > > > > > > > > You can use the form that takes a ResourceReference for the > > image. > > > > > > > > > > > > > > HTH, > > > > > > > > > > > > > > Enrique > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > To unsubscribe, e-mail: users-unsubscribe@... > > > > > > > For additional commands, e-mail: users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > To unsubscribe, e-mail: users-unsubscribe@... > > > > > > For additional commands, e-mail: users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: users-unsubscribe@... > > > > For additional commands, e-mail: users-help@... > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@... > > For additional commands, e-mail: users-help@... > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?On Mon, Mar 31, 2008 at 12:28 AM, Matthew Young <ginyeah@...> wrote:
> >wicket:link doesnt touch components afaik > > :((((( I need it to be a component. My code is basically this: > > add(new WebMarkupContainer("img")); Why do you need it to be a component? Are you controlling the visibility of it via code? --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?To Igor and James:
>so if that is all it does why does it need to be a component? >Why do you need it to be a component? Are you controlling the >visibility of it via code? #1, I need to add(IBehavior) to the img's to make change to their class attribute, so I need them to be a component. #2, I don't like img src attributes in template like this: src="resources/com.mycompany.component.MyComponent/open.png" src="resources/com.mycompany.component.MyComponent/close.png" src="resources/com.mycompany.component.MyComponent/north.png" src="resources/com.mycompany.component.MyComponent/sourth.png" etc This would break if I re-name the component or move it to a different package. It would be better if they are: src="open.png" src="close.png" src="north.png" src="sourth.png" etc and change the src attribute to full paths in code. The little PackageImage class solve this use case. >so i would say, no, it takes 10 minutes to write one I completely agree it's very trivial to create.... after getting help here :) Still I commit error by holding on to Class reference (thanks for pointing out). If there is such class built-in, then no chance for such error and this use case is taken care of. >i can come up with at least 10 trivial classes that have to do with images off the top of my head Well, this is the thing: you know Wicket inside out. Stuffs that are trivial for you may not be so trivial to regular Wicket user. But I totally understand your reluctance to add stuff to Wicket. It's like adding key words to Java, the answer is almost always "no". So if not adding these "little trivial" stuff, a wiki showing all the "little image" use cases would be great. Anyway, I am not happy with my little PackageImage class. I want to allow application to override the image files to have different look and only fallback to the built-in images, just like localization. How can this be done? On Mon, Mar 31, 2008 at 4:35 AM, James Carman <james@...> wrote: > On Mon, Mar 31, 2008 at 12:28 AM, Matthew Young <ginyeah@...> wrote: > > >wicket:link doesnt touch components afaik > > > > :((((( I need it to be a component. My code is basically this: > > > > add(new WebMarkupContainer("img")); > > Why do you need it to be a component? Are you controlling the > visibility of it via code? > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?Whats wrong with
/resources/images/xxx.jpg On 3/31/08, Matthew Young <ginyeah@...> wrote: > To Igor and James: > > >so if that is all it does why does it need to be a component? > > >Why do you need it to be a component? Are you controlling the > >visibility of it via code? > > #1, I need to add(IBehavior) to the img's to make change to their class > attribute, so I need them to be a component. > > #2, I don't like img src attributes in template like this: > > src="resources/com.mycompany.component.MyComponent/open.png" > src="resources/com.mycompany.component.MyComponent/close.png" > src="resources/com.mycompany.component.MyComponent/north.png" > src="resources/com.mycompany.component.MyComponent/sourth.png" > etc > > This would break if I re-name the component or move it to a different > package. It would be better if they are: > > src="open.png" > src="close.png" > src="north.png" > src="sourth.png" > etc > > and change the src attribute to full paths in code. The little PackageImage > class solve this use case. > > >so i would say, no, it takes 10 minutes to write one > > I completely agree it's very trivial to create.... after getting help here > :) Still I commit error by holding on to Class reference (thanks for > pointing out). If there is such class built-in, then no chance for such > error and this use case is taken care of. > > >i can come up with at least 10 trivial classes that have to do with images > off the top of my head > > Well, this is the thing: you know Wicket inside out. Stuffs that are trivial > for you may not be so trivial to regular Wicket user. But I totally > understand your reluctance to add stuff to Wicket. It's like adding key > words to Java, the answer is almost always "no". So if not adding these > "little trivial" stuff, a wiki showing all the "little image" use cases > would be great. > > Anyway, I am not happy with my little PackageImage class. I want to allow > application to override the image files to have different look and only > fallback to the built-in images, just like localization. How can this be > done? > > On Mon, Mar 31, 2008 at 4:35 AM, James Carman <james@...> > wrote: > > > On Mon, Mar 31, 2008 at 12:28 AM, Matthew Young <ginyeah@...> wrote: > > > >wicket:link doesnt touch components afaik > > > > > > :((((( I need it to be a component. My code is basically this: > > > > > > add(new WebMarkupContainer("img")); > > > > Why do you need it to be a component? Are you controlling the > > visibility of it via code? > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@... > > For additional commands, e-mail: users-help@... > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?On Mon, Mar 31, 2008 at 11:44 AM, Matthew Young <ginyeah@...> wrote:
> > src="resources/com.mycompany.component.MyComponent/open.png" or just <wicket:link><img src="open.png"/></wicket:link> > >so i would say, no, it takes 10 minutes to write one > > I completely agree it's very trivial to create.... after getting help here > :) Still I commit error by holding on to Class reference (thanks for > pointing out). If there is such class built-in, then no chance for such > error and this use case is taken care of. so you make the same error in some other component you write. this is just something you have to be aware of. > Well, this is the thing: you know Wicket inside out. Stuffs that are trivial > for you may not be so trivial to regular Wicket user. But I totally > understand your reluctance to add stuff to Wicket. It's like adding key > words to Java, the answer is almost always "no". So if not adding these > "little trivial" stuff, a wiki showing all the "little image" use cases > would be great. what you have done you could have done after reading wicket in action, or some other book. resource handling is something framework specific, so you have to invest a little learning time. > Anyway, I am not happy with my little PackageImage class. I want to allow > application to override the image files to have different look and only > fallback to the built-in images, just like localization. How can this be > done? src=getstring("somekey",null,"defaultvalue"); -igor > > On Mon, Mar 31, 2008 at 4:35 AM, James Carman <james@...> > wrote: > > > > > On Mon, Mar 31, 2008 at 12:28 AM, Matthew Young <ginyeah@...> wrote: > > > >wicket:link doesnt touch components afaik > > > > > > :((((( I need it to be a component. My code is basically this: > > > > > > add(new WebMarkupContainer("img")); > > > > Why do you need it to be a component? Are you controlling the > > visibility of it via code? > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@... > > For additional commands, e-mail: users-help@... > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: How to make img src in a component's template resolve to the image files in the package?Errr, or you could use the Image component, with a standard package
resource? Regards, Alastair On Mon, Mar 31, 2008 at 8:26 PM, Igor Vaynberg <igor.vaynberg@...> wrote: > On Mon, Mar 31, 2008 at 11:44 AM, Matthew Young <ginyeah@...> wrote: > > > > src="resources/com.mycompany.component.MyComponent/open.png" > > or just <wicket:link><img src="open.png"/></wicket:link> > > > >so i would say, no, it takes 10 minutes to write one > > > > I completely agree it's very trivial to create.... after getting help > here > > :) Still I commit error by holding on to Class reference (thanks for > > pointing out). If there is such class built-in, then no chance for > such > > error and this use case is taken care of. > > so you make the same error in some other component you write. this is > just something you have to be aware of. > > > Well, this is the thing: you know Wicket inside out. Stuffs that are > trivial > > for you may not be so trivial to regular Wicket user. But I totally > > understand your reluctance to add stuff to Wicket. It's like adding > key > > words to Java, the answer is almost always "no". So if not adding > these > > "little trivial" stuff, a wiki showing all the "little image" use cases > > would be great. > > what you have done you could have done after reading wicket in action, > or some other book. resource handling is something framework specific, > so you have to invest a little learning time. > > > Anyway, I am not happy with my little PackageImage class. I want to > allow > > application to override the image files to have different look and only > > fallback to the built-in images, just like localization. How can this > be > > done? > > src=getstring("somekey",null,"defaultvalue"); > > -igor > > > > > On Mon, Mar 31, 2008 at 4:35 AM, James Carman < > james@...> > > wrote: > > > > > > > > > On Mon, Mar 31, 2008 at 12:28 AM, Matthew Young <ginyeah@...> > wrote: > > > > >wicket:link doesnt touch components afaik > > > > > > > > :((((( I need it to be a component. My code is basically this: > > > > > > > > add(new WebMarkupContainer("img")); > > > > > > Why do you need it to be a component? Are you controlling the > > > visibility of it via code? > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: users-unsubscribe@... > > > For additional commands, e-mail: users-help@... > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > |
| Free embeddable forum powered by Nabble | Forum Help |