You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Milan Křápek <He...@seznam.cz> on 2008/10/22 12:08:42 UTC
Automatic inserting HTML code
Hi, I have probably a newbie question, but I cannot find way how to do it.
I my application I use many AjaxLinks. I always want the link to be represented by an image. The image is always the same so I want to prevent myself for writing the same code.
I made my component that extends AjaxLink. In constructor of this component I just add the image to it.
add (new Image ("myImg", new ResourceReference ("myImg")));
Now I need to automatically add the correspond HTML code
<img wicket:id="myImg" border="0" />
to the web page when I use this component.
E.G.
JAVA
.
add (new MyAjaxLink ("myLink") {
@Override
public void onClick (AjaxRequestTarget target) {
...
}
);
.
and
HTML
.
<a wicket:id="my link"> here should be the HTML code from my component </a>
.
will be rendered as
<a wicket:id="my link"> <img wicket:id="myImg" border="0" /> </a>
I know that the functionality that I ant is provided by Panel Component. But I need it when using component that extends AjaxLink not Panel. I think that one possible reason is to insert the image to my component as a Panel. But that will be very awful reason. Is there any other way how to do it??
Thank for any advice.
Milan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Automatic inserting HTML code
Posted by Igor Vaynberg <ig...@gmail.com>.
search this list for TextLink and see how it outputs text into link's body.
-igor
On Wed, Oct 22, 2008 at 3:08 AM, Milan Křápek <He...@seznam.cz> wrote:
> Hi, I have probably a newbie question, but I cannot find way how to do it.
>
> I my application I use many AjaxLinks. I always want the link to be represented by an image. The image is always the same so I want to prevent myself for writing the same code.
> I made my component that extends AjaxLink. In constructor of this component I just add the image to it.
> add (new Image ("myImg", new ResourceReference ("myImg")));
> Now I need to automatically add the correspond HTML code
> <img wicket:id="myImg" border="0" />
> to the web page when I use this component.
>
> E.G.
> JAVA
> .
> add (new MyAjaxLink ("myLink") {
> @Override
> public void onClick (AjaxRequestTarget target) {
> ...
> }
> );
> .
> and
> HTML
> .
> <a wicket:id="my link"> here should be the HTML code from my component </a>
> .
> will be rendered as
> <a wicket:id="my link"> <img wicket:id="myImg" border="0" /> </a>
>
> I know that the functionality that I ant is provided by Panel Component. But I need it when using component that extends AjaxLink not Panel. I think that one possible reason is to insert the image to my component as a Panel. But that will be very awful reason. Is there any other way how to do it??
>
> Thank for any advice.
>
> Milan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>