You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by avchavan <av...@yahoo.co.in> on 2015/04/07 07:06:44 UTC

anchor tag for a dynamic text

Hi, i would like to know if its possible to have a clickable link for a
dynamic text.

I have tried by using the anchor tag with some wicket id and adding an
onclick behavior to it, i could see the text with link on my screen but the
onclick call of t he link was never triggered.
What could possibly be the issue?

i did something like this:
Message in the properties file --> 123= Here's the link!! 
i used this wicket id and added it to the page and attached an onclick
behavior to this.
I have checked t he firebug console but there was no onclick call made for
the link's click.

Thanks.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/anchor-tag-for-a-dynamic-text-tp4670190.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: anchor tag for a dynamic text

Posted by avchavan <av...@yahoo.co.in>.
Yes, more or less on this line only.
But not exactly like this as the link's position in the text would depend on
the message and the message would be fetched from the properties file, so
its going to be dynamic.


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/anchor-tag-for-a-dynamic-text-tp4670190p4670211.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: anchor tag for a dynamic text

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

I am still not sure that I understand you but here is my take:

you need something like:
prefixLabel = new Label("prefix", "Hey!!!");
link = new Link(...) {...}.setBody(Model.of(" Click Here "));
suffixLabel = new Label("suffix", "now");
someParent.add(prefixLabel, link, suffixLabel);

On Tue, Apr 7, 2015 at 1:30 PM, avchavan <av...@yahoo.co.in> wrote:

> Hi Martin,
>
> String someTextMessage = "Hey!!!  Click Here  now.";
> Lable message = new Lable("messageLable", someTextMessage);
> message.setEscapeModelStrings(true);
> Link printLink = new Link("printLink") {
>         @Override
>         public void onClick() {
>            System.out.println("inside onClick");
>         }
>     };
> this.add(printLink);
> this.add(message);
>
> What i want is to have a link inside the text message that i would like to
> display.
> And the error message can change based on different conditions.
> So i could have two messages, one given above and another one where i would
> have another text with Link.
>
> I hope i am more clear now.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/anchor-tag-for-a-dynamic-text-tp4670190p4670201.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: anchor tag for a dynamic text

Posted by avchavan <av...@yahoo.co.in>.
Hi Martin,

String someTextMessage = "Hey!!!  Click Here  now.";
Lable message = new Lable("messageLable", someTextMessage);
message.setEscapeModelStrings(true);
Link printLink = new Link("printLink") {
        @Override
        public void onClick() {
           System.out.println("inside onClick");
        }
    };
this.add(printLink);
this.add(message);

What i want is to have a link inside the text message that i would like to
display.
And the error message can change based on different conditions.
So i could have two messages, one given above and another one where i would
have another text with Link.

I hope i am more clear now.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/anchor-tag-for-a-dynamic-text-tp4670190p4670201.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: anchor tag for a dynamic text

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Sorry but your question is not very clear.
Please try to explain the problem again and give us exact copy of your code.
"Click here" text could not be generated from the code snippet you have
provided.

Martin Grigorov
Freelancer, available for hire!
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Apr 7, 2015 at 12:39 PM, avchavan <av...@yahoo.co.in>
wrote:

> Actual text message is something like this:
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/anchor-tag-for-a-dynamic-text-tp4670190p4670199.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: anchor tag for a dynamic text

Posted by avchavan <av...@yahoo.co.in>.
Actual text message is something like this:


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/anchor-tag-for-a-dynamic-text-tp4670190p4670199.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: anchor tag for a dynamic text

Posted by avchavan <av...@yahoo.co.in>.
i did something like this: Message in the properties file --> 123= Here's the
link!! 

//get message from properties file
String someTextMessage = getMessage(123);
Lable message = new Lable("messageLable", someTextMessage);
message.setEscapeModelStrings(true);
Link printLink = new Link("printLink") {
        @Override
        public void onClick() {
           System.out.println("inside onClick");
        }
    };
this.add(printLink);

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/anchor-tag-for-a-dynamic-text-tp4670190p4670196.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: anchor tag for a dynamic text

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You need a Link component that is a parent of a Label component.
The Label should use a IModel<String> that produces dynamic String for each
render of the Label.

Show us some code so we can tell you what is wrong in your version.

Martin Grigorov
Freelancer, available for hire!
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Apr 7, 2015 at 8:06 AM, avchavan <av...@yahoo.co.in> wrote:

> Hi, i would like to know if its possible to have a clickable link for a
> dynamic text.
>
> I have tried by using the anchor tag with some wicket id and adding an
> onclick behavior to it, i could see the text with link on my screen but the
> onclick call of t he link was never triggered.
> What could possibly be the issue?
>
> i did something like this:
> Message in the properties file --> 123= Here's the link!!
> i used this wicket id and added it to the page and attached an onclick
> behavior to this.
> I have checked t he firebug console but there was no onclick call made for
> the link's click.
>
> Thanks.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/anchor-tag-for-a-dynamic-text-tp4670190.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>