[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="#" οnclick='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;
}
發佈了9 篇原創文章 · 獲贊 0 · 訪問量 1559
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章