1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    10
    Vote Rating
    0
    vijayvijay is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Answers
    109
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    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).

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    10
    Vote Rating
    0
    vijayvijay is on a distinguished road

      0  

    Default 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

  4. #4
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Feb 2013
    Posts
    10
    Vote Rating
    0
    vijayvijay is on a distinguished road

      0  

    Default 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

  6. #6
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    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:

    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);
    }
    And in your event handler:

    Code:
    XElement target = event.getNativeEvent().getEventTarget().cast();
    if (target.hasClassName("person"))
    {
      // do your click handler routine stuff.
    }
    Construct your template via
    Code:
    GWT.create(MessageTemplate.class)
    I've not checked this for syntax so I apologize in advance if something's amiss. Now for some notes:
    • 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.
    Let me know how this works.

Thread Participants: 2