No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Does Smartgwt have an Anchor widget?

    I'm porting code I've written in GWT to use Smartgwt instead. In GWT, an Anchor widget allows me to set a URL such as "" and a title suck as "Click here for Wikipedia", and then the title is shown on the panel with an underline, and if it is clicked-upon, a new browser tab is opened to the associated URL. I can't find any such feature in Smartgwt. Any hints you can provide on where to find this ability or how to emulate it will be greatly appreciated. I thought LinkItem would do it, but that just gets me as far as a being able to associate a click handler that will get called when the user presses on the link, it doesn't open a new tab and go to a specified URL. Thanks for answering my question. - Jim Waschura

    You can use a LinkItem as the only item of a DynamicForm.


      Whether I create an additional DynamicForm to put only this one LinkItem in it, or whether I just add the LinkItem to an existing Dynamic Form (which is what I was doing before), the behavior is the same. I do not launch another tab on my (Chrome) browser, and I don't go the URL which I've set in the LinkItem object using the setValue() method.

      (1) I see the Showcase example for LinkItem but this only implements a click handler than performs an SC.say() call. Notice this is not what I want to do. I don't want a pop-up dialog message. I want a separate tab to open on my browser and to go to that URL on that new tab of the browser.

      (2) In GWT, I use the following, which performs the way I want it to:

      Anchor Linkto = new Anchor();
      Linkto.setText("Click Me");

      (3) In SmartGWT, I am currently using code like this, which doesn't work, though it does display the link on the screen and you can click it and most-likely if I added a Click Handler it would call the click handler when the link was pressed:

      LinkItem Linkto = new LinkItem("title");
      Linkto.setLinkTitle("Click Me");

      DynamicForm form = new DynamicForm();

      getPortlet().addItem( form );

      (4) Do you have any example code for how to use LinkItem to open a new tab on the browser and go to a specified URL?

      Thank you, Jim Waschura


        Hi Jim,

        how about a ClickHandler with"URL", "_blank", "")?
        I have the same for some of my ListGridFields.

        Best regards


          Start by reading the docs for LinkItem. Multiple forms of activation are supported, some of which just run event handlers and some behave like a normal HTML link.


            Blama - Very promising results, Thank you. I can make this work to go to "http:\\" but I can't get this to work to go to "file:\\\c:" or "file:\\\Share" which is what my ultimate objective is. Have you use the for protocols other than http: ?

            Administrator - Thank you for your advice. Maybe I am not aware of some level of documentation that I ought to be aware of. Of course I have read the entire documentation on the LinkItem class in the Javadoc format, which is what gave me the impression this would work. The class description says:

            A form item that displays a URL. In the default read-only mode (canEdit is false) the URL is shown as a link; in editable mode the URL is shown in a textbox. The link to open is specified as the item value with FormItem.setValue() or FormItem.defaultValue. The link title defaults to the URL unlesslinkTitle is specified.

            Based on this, I followed these instructions but it didn't work. Can you tell me please, is there more documentation available for situations like this? An overview of how to use the object - not just what the interfaces are - would be helpful. Thank you again,

            Jim Waschura


              Is that intended as humor? You quoted the class description, then omitted the last sentence, which tells you what you wanted to know about what the link targets. You read only 4 of the 5 sentences then critiqued the docs?? :)

              Also, what are you expecting those file URLs to do? Cause files on the end user's machine to be opened when clicked?


                Sorry I didn't include the last sentence because setTarget() does not appear to be the API to set the URL destination. I believe the setValue() is the correct API, and I am now able to make it work if I use setValue() and assign a URL prior to adding the item to the dynamic form and adding the form to the portlet and rendering the portlet. I believe my trouble stemmed from changing the URL after the portlet had been rendered, which is something I do because the URL is dynamic and I don't know it at the moment of construction. If I use setValue("http:\\") at construction time, then when I click on the link, another tab is opened and it displays the mercury news website as I expect.

                Two issues:

                (1) Generally I don't know the URL at the moment of construction and so I'd like to change it later. Is there a way to do this, or should I remove the item and rebuild the form and portlet contents whenever I need to update the URL. - How do I change the URL after construction?

                (2) Even when I create the URL contents at construction time prior to rendering the portlet, if I use setValue( "file:///C:/" ) it doesn't open a tab or display the root folder, like the browser does if you type in this URL directly (try it). On Chrome/Windows, this displays a listing of the contents of the root folder entitled, "Index of C:". Is there anything I can do to allow the use of URL's with the "file://" protocol? I tested it with a setValue("mailto://") and that launched the gmail web site as I expected. - Is there a way to specify a URL utilizing the "file://" protocol?

                Attached is an example of what the browser shows when I use the file:// protocol and specify a folder, for example: "file://zorro/stash".

                Thank you for helping me with this.

                - Jim Waschura


                I'm working on a small device that performs electronic testing. The device has an embedded SOC running embedded Linux (Fedora) which is connected to a custom hardware design that connects to high speed (54 Gbits/sec) communications channels and tests them for errors. The device also has a solid-state disk where errors can be captured to. The Linux is running a Samba server to create a network share of the folder containing the captured files. The SOC is also running apache web server and a tomcat server and it serves the website I'm building with Smartgwt as the user interface capable of supporting multiple simultaneous clients. When first connected, the website can ask a custom hardware server running on the Linux machine for its LAN IP address using the RPC features from GWT (basically AJAX). When this information is returned, I can build a string like "file://" which I want to provide as a link on the user interface so users can click and quickly get to a browser page that shows the contents of the share. - FYI

                Click image for larger version

Name:	gui.png
Views:	26
Size:	158.9 KB
ID:	238126
                Attached Files
                Last edited by jimwaschura; 20th May 2016, 18:19.


                  1. Call setValue() again

                  2. Can't be done, disallowing this is a browser security feature. You need a system for returning that data via http


                    Originally posted by Isomorphic View Post
                    You can use a LinkItem as the only item of a DynamicForm.
                    Is there a way to get the LinkItem to show an old-school "visited" style after it's clicked? (e.g., purple font?)


                      For links that are actually ordinary links (not JavaScript / Java actions) you could define the :visited selector in CSS to define a color for a visited link.


                        Sorry, we misspoke. For links with a target other than "javascript", the link will automatically go purple if the target has been visited, just like a normal link.

                        For "javascript" links, the browser does not track whether a link is "visited" or not (since such links often represent actions). If you wanted to have a notion of a "javascript" link having been visited, you'd have to track the visited state yourself, and apply CSS to the LinkItem to make it purple.