页面回调

1.主窗口出发事件调用子窗口
	function searchorganization()
	{	
			var returnTarget=window.showModalDialog("/view/jsp/com/company/erp/systemmanage/common/purview_organizationTree_show.jsp?orgId=''",window,"newwindow", "height=800,width=520,scrollbars=yes");
		
	}

2.子窗口处理数据后返回给主窗口

function retValue()
{
    var result = new Array();
    var treeobj = tree.getSelected();
	var id = treeobj.id;
    //alert(id);
	var id = map.get(id);
    if(treeobj != null && treeobj != undefined && treeobj != ""){  
  	    if( id != null && id != undefined && id != "" ){
  	    	result[0] = id.value;
  	    }
  	    else{
  	    	result[0] = null;
  	    }
        var name = treeobj.text;
        result[1] = name;
        result[2] = document.mainForm.organizationNum.value;
  		if(result != null && result != undefined && result != "")
	    {
		    //把模板信息传给主页面
		    window.dialogArguments.callBack(result);
		    //关闭窗口
		    window.close();
	    }
    }
    else{
        alert("请选择..!");
    }

 	
	return false;
}


3.子窗口调用主窗口的回调方法
在主窗口定义的方法
function callBack(returnTarget)
{
    var primaryKey;
    var retName;

    if(returnTarget != null && returnTarget != undefined && returnTarget.length > 1)
    {
        primaryKey = returnTarget[0];
        retName = returnTarget[1];
        
        	if( primaryKey == null){
       			 primaryKey = "" ;      			 
        		}
	        document.getElementById("aaa").value = primaryKey;
		    document.getElementById("000").value = retName;

	 }    

}

你可能感兴趣的:(jsp)