Sorry, missed that - but found the issue - stop passing your link the label
- the link is trying to replace it's body with your label rather than the
markup you wrote.  Do this:

ExternalLink link = new ExternalLink("bankURL", lender.getWebsite());
StaticImage image = new StaticImage("bank", "images/logos/" +
lender.getImageSrc(), lender.getLender());
link.add(image);
add(link);


-- 
Jeremy Thomerson
http://www.wickettraining.com



>> ExternalLink link = new ExternalLink("bankURL",
>> lender.getLenderWebsite(),
>> lender.getLender());
>>  StaticImage image = new StaticImage("bank", "images/logos/" +
>> lender.getImageSrc(), lender.getLender());
>>  link.add(image);
>>  add(link);

On Tue, Feb 24, 2009 at 7:00 PM, novotny <[email protected]> wrote:

>
>
> Hi
>
> I am using import org.apache.wicket.markup.html.link.ExternalLink;
>
> in my import but I do have a custom StaticImage class:
>
> public class StaticImage extends WebComponent {
>
>    private String url;
>    private String alt;
>
>    public StaticImage(String id, String url, String alt) {
>        super(id);
>        this.url = url;
>        this.alt = alt;
>    }
>
>    protected void onComponentTag(ComponentTag tag) {
>        super.onComponentTag(tag);
>        checkComponentTag(tag, "img");
>        tag.put("src", url);
>        tag.put("alt", alt);
>    }
>
> }
>
> Thanks again, Jason
>
>
> Jeremy Thomerson-5 wrote:
> >
> > Wait - I just realized that your "ExternalLink" class is custom.  That's
> > the
> > culprit.  Show us the code.
> >
> > On Tue, Feb 24, 2009 at 6:15 PM, novotny <[email protected]> wrote:
> >
> >>
> >> Thanks, however I still get the same error:
> >>
> >> WicketMessage: Expected close tag for '&lt;a wicket:id="bankURL"
> href="#"
> >> target="_new"&gt;' Possible attempt to embed component(s) '&lt;img
> >> wicket:id="bank" alt="" class="pic"/&gt;' in the body of this component
> >> which discards its body
> >>
> >> and my code looks like:
> >>
> >> ExternalLink link = new ExternalLink("bankURL",
> >> lender.getLenderWebsite(),
> >> lender.getLender());
> >>  StaticImage image = new StaticImage("bank", "images/logos/" +
> >> lender.getImageSrc(), lender.getLender());
> >>  link.add(image);
> >>  add(link);
> >>
> >> Thanks, Jason
> >>
> >>
> >>
> >> Jeremy Thomerson-5 wrote:
> >> >
> >> > I think your problem is that in your long add() call, you are actually
> >> > adding the image to your outer container rather than the link.  The
> >> code
> >> > is
> >> > formatted poorly in the email.  Try this:
> >> >
> >> > ExternalLink link = new ExternalLink(......)
> >> > link.add(new StaticImage(......))
> >> > add(link);
> >> >
> >> > On Tue, Feb 24, 2009 at 6:03 PM, novotny <[email protected]>
> >> wrote:
> >> >
> >> >>
> >> >>
> >> >> That's exactly what I tried and I get
> >> >>
> >> >> WicketMessage: Expected close tag for '&lt;a wicket:id="bankURL"
> >> href="#"
> >> >> target="_new"&gt;' Possible attempt to embed component(s) '&lt;img
> >> >> wicket:id="bank" alt="" class="pic"/&gt;' in the body of this
> >> component
> >> >> which discards its body
> >> >>
> >> >> here's my java
> >> >> add(new ExternalLink("bankURL", lender.getLenderWebsite(),
> >> >> lender.getLender()).add(new StaticImage("bank", "images/logos/" +
> >> >> lender.getImageSrc(), lender.getLender())));
> >> >>
> >> >>
> >> >> and my html:
> >> >> &lt;a wicket:id="bankURL" href="#" target="_new"&gt;somewhere&lt;img
> >> >> wicket:id="bank" alt="" class="pic"/&gt;&lt;/a&gt;
> >> >>
> >> >> Thanks, Jason
> >> >>
> >> >>
> >> >> igor.vaynberg wrote:
> >> >> >
> >> >> > the bottom of that page shows you how to embed an external image
> >> into
> >> >> > an external link.
> >> >> >
> >> >> > -igor
> >> >> >
> >> >> > On Tue, Feb 24, 2009 at 3:24 PM, novotny <[email protected]>
> >> >> wrote:
> >> >> >>
> >> >> >> Hi all,
> >> >> >>
> >> >> >> Apologies for such a  simple question but I couldn't find
> >> anything--
> >> >> the
> >> >> >> closet was
> >> >> >> http://cwiki.apache.org/WICKET/how-to-load-an-external-image.html
> >> >> >> but it just didn't work for me.
> >> >> >>
> >> >> >> Here's the html I want:
> >> >> >>
> >> >> >> &lt;a href="http://www.gohere.com"&gt;&lt;img
> >> >> >> src="images/logo.gif"&gt;&lt;/a&gt;
> >> >> >>
> >> >> >> I tried to do something like ExternalLink("link",
> >> >> >> "http://www.gohere.com";,
> >> >> >> "&lt;img src=\"images/logos/" + lender.getImageSrc() + "\"/&gt;");
> >> but
> >> >> it
> >> >> >> escaped the img I tried to pass in as a label.
> >> >> >>
> >> >> >> Thanks a bunch!
> >> >> >>
> >> >> >> Jason
> >> >> >> --
> >> >> >> View this message in context:
> >> >> >>
> >> >>
> >>
> http://www.nabble.com/external-image-inside-link-tp22193027p22193027.html
> >> >> >> Sent from the Wicket - User mailing list archive at Nabble.com.
> >> >> >>
> >> >> >>
> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> To unsubscribe, e-mail: [email protected]
> >> >> >> For additional commands, e-mail: [email protected]
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> ---------------------------------------------------------------------
> >> >> > To unsubscribe, e-mail: [email protected]
> >> >> > For additional commands, e-mail: [email protected]
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/external-image-inside-link-tp22193027p22193550.html
> >> >> Sent from the Wicket - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: [email protected]
> >> >> For additional commands, e-mail: [email protected]
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Jeremy Thomerson
> >> > http://www.wickettraining.com
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/external-image-inside-link-tp22193027p22193714.html
> >> Sent from the Wicket - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
> >
> >
> > --
> > Jeremy Thomerson
> > http://www.wickettraining.com
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/external-image-inside-link-tp22193027p22194164.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to