[Tapestry 4.1.1] Popup child window

I thought it's supposed to be pretty easy before I tried to implement.

The requirement is like this: when a link on the parent window is clicked, a child window pops up and after a series of processes, a child window value will be returned to the parent window.

Since the child window involves pretty much server side access, pure javascript won't suffice.

First of all, here's how I build the link to the child window:

html:

<a jwcid="@Any" href="#" onclick='ognl:getPopupLink()'>
  Find
</a>


java:

public String getExternalURI(Object params) {
	    
    IEngineService service =
        getEngine().getInfrastructure()
            .getServiceMap().getService(Tapestry.EXTERNAL_SERVICE);
		
    ILink uri = service.getLink(true, params);
    return uri.getURL();
}

public String getPopupLink() {
		
    return "openPopup('" + 
        getExternalURI(new ExternalServiceParameter(
            _newPageName))
        + "')";
}


Here's how 'openPopup' defines:

function openPopup(uri) {
  childWindow=open(uri,'popupFinder',
    'resizable=yes,width=400,height=600');
  if (childWindow.opener == null) childWindow.opener = self;
}


I need to provide a function in the parent window to update the field when the child window is done:

function updateFieldFromChild(value) {
  document.getElementById('fieldId').value = value;
}


Here's how to invoke the parent window method to pass the value:

function updateParent(value) {
  window.opener.updateFieldFromChild(value);
  window.close();
  return false;
}

你可能感兴趣的:(JavaScript,html,Access,UP,tapestry)