Re: Dynamically generating an img tag
Thanks Jeremy, Jonathan and Jan. Jan, I've tried your suggestion and it works as expected... :-) Still, Jeremy is right when he defends a cleaner solution. I'll try his suggestion as well. The Wicket API for Google Charts seems very interesting, Jonathan. I'm already using charts4j to encode the chart... It's an interesting project, too. Please see: http://code.google.com/p/charts4j/ Best regards, Cristina Jeremy Thomerson-5 wrote: > > Or use a WebMarkupContainer and an AttributeModifier. Wrap this in your > own > class so you're not writing HTML in your Java code. Then your links are > actually in your HTML (except the SRC which gets generated in code) and > your > designers can stylize the links etc. Much better IMHO. > > [...] > -- View this message in context: http://www.nabble.com/Dynamically-generating-an-img-tag-tp21190259p21199079.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Dynamically generating an img tag
Or use a WebMarkupContainer and an AttributeModifier. Wrap this in your own class so you're not writing HTML in your Java code. Then your links are actually in your HTML (except the SRC which gets generated in code) and your designers can stylize the links etc. Much better IMHO. Something like: public class MyLink extends WebMarkupContainer { private static final long serialVersionUID = 1L; public MyLink(String id, IModel model) { super(id); add(new AttributeModifier("src", true, model)); } } In your HTML: your text It doesn't abuse Label this way, and is much more in line with the standard Wicket way. -- Jeremy Thomerson http://www.wickettraining.com On Sun, Dec 28, 2008 at 12:07 AM, Jan Kriesten wrote: > > Hi Cristina, > > > Java: > > > > // prefix and sufix hold the start and end of the img tag > > String imgTag = prefix + getImgURL() + sufix; > > add(new Label("imgDisplay", imgTag)); > > try: > > add(new Label("imgDisplay", imgTag).setEscapeModelStrings(false)); > > Best regards, --- Jan. > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: Dynamically generating an img tag
you might also look at this: http://www.codecommit.com/blog/java/a-wicket-api-for-google-charts Cristina wrote: > > Hi, > > I'm trying to generate an img tag pointing to a Google chart at > http://chart.apis.google.com/. I'm getting the chart URL as a string and I > need to generate the img tag in order to display it as an image. > > I'm trying to use a Label, like: > > HTML: > > img tag goes here > > Java: > > // prefix and sufix hold the start and end of the img tag > String imgTag = prefix + getImgURL() + sufix; > add(new Label("imgDisplay", imgTag)); > > Problem is, < > and " are not interpreted as markup delimiters, but as > normal characters, so all I've got is the URL displayed as a literal where > the image should be displayed. > > Is there a simple way to do something like this? > > Thanks so much, > > Cristina > > -- View this message in context: http://www.nabble.com/Dynamically-generating-an-img-tag-tp21190259p21190506.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Dynamically generating an img tag
Hi Cristina, > Java: > > // prefix and sufix hold the start and end of the img tag > String imgTag = prefix + getImgURL() + sufix; > add(new Label("imgDisplay", imgTag)); try: add(new Label("imgDisplay", imgTag).setEscapeModelStrings(false)); Best regards, --- Jan. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org