private void renderPopup(Map model, HttpServletRequest request,
HttpServletResponse response, Execution exec, Component popTarget) throws Exception {
// Determine the path for the request dispatcher.
String dispatcherPath = prepareForRendering(request, response);
final Window popupWin = (Window) exec.createComponents(POPUP_TEMPLATE, null, null);
//store flow context information into popup window
ZKProxy.getProxy().setAttribute(exec, ZkFlowContextManager.FLOW_POPUP_WINDOW, popupWin);
ZkFlowContextManager.storeFlowContext(exec);
//Some page might be composed with Composition, so always prepare it
//Bug: If the dispatcherPath page contains zhtml <h:html> + <h:body>,
// the new created <h:body> will replace the page's _defparent. Then
// in fragment cleanup, the <h:html> is detached so the <h:body> does
// not attached to the page any more (because its parent h:html is
// detached) but the _defparent is still the <h:body>. The state of
// the page screwed up and things going crazy.
//exec.setAttribute(Composition.PARENT, popupWin);
//exec.createComponents(dispatcherPath, popupWin, null);
//keep only the fragment part
String[] fragments = (String[]) model.get(View.RENDER_FRAGMENTS_ATTRIBUTE);
if (fragments != null && fragments.length > 0) {
Component[] comps = exec.createComponents(dispatcherPath, null);
//remember flow model stored in request attributes to current Desktop
//so DelegatingVariableResolver can see it!
final Map fragmentMap = prepareFragmentMap(new HashMap(), Arrays.asList(comps));
//remove all
//popupWin.getChildren().clear();
//attach fragment only
for (int j = 0; j < fragments.length; ++j) {
final String fragment = fragments[j];
final Component fragmentComp = (Component) fragmentMap.get(fragment);
if (fragmentComp != null) {
popupWin.appendChild(fragmentComp);
}
}
//prepare a data binder for the popupWin
final AnnotateDataBinder binder = new AnnotateDataBinder(popupWin, true);
popupWin.setAttribute("binder", binder, true);
//redraw
popupWin.invalidate();
}
}