Thanks Igor ! It looks really smart and works perfectly. I have now to
read Eelco's explanations to understand how all this is working, and try
1.2.1.
Igor Vaynberg a écrit :
> class MyImage extends WebComponent {
> private int width;
> private int height;
> private string url;
> private string text;
>
> public myimage(string id, string url, string text, int width, int
> height) {
> super(id);
> this.url=url;
> ...
> }
>
> void oncomponenttag(tag tag) {
> checkcomponenttag(tag, "img");
> tag.put("src",url);
> tag.put("alt", text);
> tag.put("width", width);
> tag.put("height", "height");
> }
> }
>
> ....
>
> add(new MyImage("img1", "foo.gif", "bar", 200, 330);
> add(new MyImage("img2", "foo2.gif", "bar2", 232, 523);
>
> -Igor
>
>
> On 7/23/06, *Eelco Hillenius* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> >
> > Among the remaining problems, is the fact that references to
> image files
> > inside the css don't work
>
> Probably all the same problem of not having them pre-registered.
> Please could you try using the version in svn (WICKET_1_2 branch), or
> download the intermediate version at
>
> http://sourceforge.net/project/showfiles.php?group_id=119783&package_id=173489&release_id=428730
>
> <http://sourceforge.net/project/showfiles.php?group_id=119783&package_id=173489&release_id=428730>
>
> ?
>
> There are many components, like the Tree, DatePicker, YUI Slider and
> Calendar etc that work with relative images like that. So far -
> besides that pre-registering - that didn't give any problems.
>
>
> > BTW, I have struggled with another problem about loading images
> dynamically
> > at run time while having to pass not only the file name but the
> width,
> > height and alt attributes. After days of experiments, I ended
> with this
> > solution :
> >
> > WebMarkupContainer wmc = new WebMarkupContainer("image0");
> > wmc.add(new AttributeModifier("src", new
> > Model("images/vd-contrebasse.png")));
> > wmc.add(new AttributeModifier("width", new Model("132")));
> > wmc.add(new AttributeModifier("height", new Model("101")));
> > wmc.add(new AttributeModifier("alt", new Model("Mains sur une
> > contrebasse")));
> > add(wmc);
> >
> > Although it works, it looks a bit like brute force ! (This
> approach also
> > work for linking to a css file, and I suppose it could work for
> setting any
> > attribute of any element, but it looks ugly ! Is there a better
> way to
> > achieve this ?
>
> Well, first off, programming will always take a few lines here and
> there. The whole trick with Wicket and it's philosophy of reusable
> components is that you hide the ugly parts in components and expose a
> nice API on them.
>
> Instead of those static models (new Model("value")), use dynamic
> models that e.g. work on properties of your component (new
> PropertyModel(this, "alt")).
>
> Furthermore, instead of using attribute modifiers, you could e.g.
> override onComponentTag body, and do your attribute modification there
> like: openTag.getAttributes().put(key, value) or in 2.0 (alpha
> currently) you can even do it int the constructor:
> getMarkupAttributes().put(key, value);
>
> Eelco
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to
> share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV>
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user