Announcement

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

    How to pass parameters from one window to other window.

    I have a tree and I added a context menu. When I click on one of the MenuItem it should open up the new Window. I need to pass the node name to the new window.


    Can we do this using Smart GWT ? If so Please show some pointers to implement this feature ?

    Thanks in advance for the help.

    #2
    Please Reply

    Hi Sanjiv,

    Can Smart GWT Support this feature ? Is there any alternatives ? Please reply.

    Thanks in advance
    Sridhar

    Comment


      #3
      What window are you talking about? In GWT, you don't pass parameters to another window (unless you're talking about a browser window as opposed to the Window class).

      Simply store the variable representing the node name, and make it accessible to the Window instance you're opening. This might be in the form of a member variable accessible to the Window instance or as an argument to pass to the method responsible to show the window. This is vanilla Java programming and not related to SmartGWT.

      Comment


        #4
        New Browser Window

        Thanks for the quick reply. I have a requirement that ..

        If I select a node and click I should open a new browser window. I need to pass the node and parent node details to the new browser window.

        I am creating a window using window.open(url, target, features ).

        Comment


          #5
          So for the URL simply add ?paramName=paramValue.

          Comment


            #6
            How to get the url param value

            How can we retrieve the url param value in the new browser window ? Any sample code ?

            Comment


              #7
              Try google.

              Comment


                #8
                I am using this class that I created:

                Code:
                import java.util.HashMap;
                
                public class UrlParams {
                	
                	private static UrlParams instance = null;
                	
                	public static UrlParams getInstance() {
                		if (instance == null) {
                			instance = new UrlParams();
                		}
                		return instance;
                	}
                
                	private HashMap<String, String> paramettersMap;
                	
                	private UrlParams() {
                		paramettersMap = _getParamettersMap();
                	}
                
                	public HashMap<String, String> getParamettersMap() {
                		return paramettersMap;
                	}
                	
                	private HashMap<String, String> _getParamettersMap() {
                		HashMap<String, String> map = new HashMap<String, String>();
                		String param = getNativeParamString();
                		if (param != "") {
                			//remover o '?' da string
                			param = param.substring(1);
                			String[] values = param.split("&");
                			for (int i = 0; i < values.length; i++) {
                				String[] value = values[i].split("=");
                				map.put(value[0], value[1]);
                			}
                		}
                		return map;
                	}
                	
                	private native String getNativeParamString() /*-{
                    	return $wnd.location.search;
                	}-*/;
                
                }
                It gives an hashmap with the parametters...

                Comment


                  #9
                  Url Param

                  we can get the url parameter using Window.Location.getParameter("paramName")

                  Comment

                  Working...
                  X