-
6 Feb 2013 2:46 AM #1
Unanswered: creating hyperlink in gxt
Unanswered: creating hyperlink in gxt
Can any one help me to create a hyperlink in the alertmessage (Part of alert message needs to act as hyperlink)
The alert message also dynamically change.
Vijay
-
6 Feb 2013 12:39 PM #2
Are you talking about the browser alert dialog? This can only display text, not html. If you are talking about one of the GXT Dialog or MessageBox classes, this may be possible
What have you tried? Dialog extends from window, so you can put any widgets in there at all. Alternatively, MessageBox (which extends from Dialog), adds the ability to set a string message (which renders as html right now).
-
7 Feb 2013 3:36 AM #3
Creating Hyperlink
Creating Hyperlink
Thanks for your response.
I have tried with GXT Dialog. The Dialog contains Text. The text message is something like"........person .......".
I have to replace the person with some id value which i can get dyanmically and that id should be hyperlink and on click of the id will open a new tab in my application.
Vijay
-
7 Feb 2013 9:46 AM #4
I think what you're saying is that you want to perform an action (in this case display a dialog) when the user clicks on some text that's STYLED like a hyperlink.
If so, you can use GWT's HTML widget and call addClickHandler(...) on the instance.
-
8 Feb 2013 8:04 AM #5
Creating Hyperlink
Creating Hyperlink
How to concatenate the HTML widget and string.
ex : "The person 100457 not Qualified "
In the above message 100457 needs to act as hyperlink and needs to open a editor in the application.
If i use widget i can create a hyperlink. but while creating the above message .
"The person + widget.getText() + not qualified ".
The above will conctenate. but on click is not working. Because the widget.getText() give the text not the real widget. onClick will work only on widget. not widget string.
String length will also change dynamically and the person id will appear anywhere in the String.
Vijay
-
8 Feb 2013 10:40 AM #6
Correct. HTML.getText() returns a java.lang.String which does not have event handlers.
Probably the best way to go about doing this would be to create an XTemplate:
And in your event handler:Code:interface MessageTemplate extends XTemplates { @XTemplate("The person <span class="person" style="cursor: pointer; color: blue; text-decoration: underline;">{person}</span> is not qualified.") SafeHtml getNotQualifiedMessage(String person); }
Construct your template viaCode:XElement target = event.getNativeEvent().getEventTarget().cast(); if (target.hasClassName("person")) { // do your click handler routine stuff. }I've not checked this for syntax so I apologize in advance if something's amiss. Now for some notes:Code:GWT.create(MessageTemplate.class)
- If you think you're going to have other messages in your application like this I would create a reusable widget and pass in your click handler to this new widget via the ctor.
- If you find that you want to style additional text in your application to make it "look" like a hyperlink, then I would create a reusable CssResource and ClientBundle and pass that into your XTemplate.


Reply With Quote