#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Accessing parent window from child window?


    I have a main window named worklistManager.jsp.
    worklistManager.jsp has a pop up window named processManager.jsp.
    Again, processManager.jsp has another pop up window, named eventLog.jsp.
    Once again eventLog.jsp has a pop up window named eventUsers.jsp.

    eventUsers.jsp has a dojox/grid/DataGrid and a button. After selecting a particular row in the grid, then clicking the button, it has to place the value into the textbox of eventLog.jsp after closing eventUsers.jsp.

    So far, I have tried the script below to accomplish this, but it's not working as I hoped.

    Code:
    <script type="text/javascript">
            function getEventLogUserSelect(){
             if(dijit.byId('dynamiceventusergridCWUSER')){
             var selctedItem = dijit.byId('dynamiceventusergridCWUSER').selection.getSelected();
                     if(selctedItem.length){
                      dojo.forEach(selctedItem, function(selectedItem){
                      if(selectedItem !== null){
                      dojo.forEach(dijit.byId('dynamiceventusergridCWUSER').store.getAttributes(selectedItem), function(attribute){
                      var value = dijit.byId('dynamiceventusergridCWUSER').store.getValues(selectedItem, attribute);
                      if(attribute == "USERID"){
                      window.opener.SetValue(value);
                      window.close();
                      }
                      
                      });
                      }
                      });
                      //alert("grid row selected");
                     }else{
                      alert("grid row not selected");
                     }
             }
                    if(gbshowgridFlag==false){
                     alert("grid not loaded");
                    }
            }
            function SetValue(val){
                    var txt = document.getElementById('CWPROCESSEVENTLOG.USER_ID');
                    txt.value = val;
                    
             }
            </script>
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,119
    Rep Power
    119
    Look into HTML5 Web Storage; specifically sessionStorage. This will allow you to send variables, though session data, across multiply windows.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    26
    Rep Power
    0
    Originally Posted by BobbyRachel
    ...So far, I have tried the script below to accomplish this, but it's not working as I hoped...
    Another solution you might try would be to have another look at your SetValue() function. When you run this script, what are you getting in the console?

    javascript Code:
    window.opener.SetValue(value);


    Seems odd. What if you called the function directly, without the window.opener in getEventLogUserSelect()?

    javascript Code:
    if(attribute == "USERID"){
        SetValue(value);
    }


    Then, do all of your window.opener operations in the SetValue() function:

    javascript Code:
    function SetValue(val){
        var txt = window.opener.document.getElementById('CWPROCESSEVENTLOG.USER_ID');
        txt.value = val;
        window.close();
    }


    Of course I could be way off base here. Let us know how it goes.

    - Null
    Last edited by null.if.ied; February 12th, 2013 at 01:30 PM. Reason: Removed empty lines from code.

IMN logo majestic logo threadwatch logo seochat tools logo