[ 
https://issues.apache.org/jira/browse/TRINIDAD-1121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12881687#action_12881687
 ] 

Cedric Durmont commented on TRINIDAD-1121:
------------------------------------------

I have a (dirty) workaround for this issue (see code below).
Say I have a main page (main.xhtml), which opens a popup (pop1.xhtml), which in 
turn opens another popup (pop2.xhtml). When an item is chosen in pop2.xhtml, I 
want to return "directly" to main.xhtml (a common example is : pop1 is a 
"select item" page, pop2 is a "new item" page. When I create a new item this 
way, I want to select it directly.

I did some debugging to find a solution, and I'm not sure but maybe the problem 
comes from CoreRenderKit.returnFromDialog(), which contains these lines :
[...]
out.write("<script>");
out.write("top.close()");
out.write("</script>");
[...]
out.close();
context.responseComplete();
[...]

ReturnsListeners seem to be always called via PPR requests. But here the 
response is not an xhtml fragment, but a full html body. I think that the js 
get screwed by the response, so nothing happens, the top.close() never makes it 
to the page.

Hope this helps,
Regards,
Cedric Durmont

=== sample code ===

main.xhtml :
<tr:commandButton text="pop" id="openPop1" returnListener="#{mainBean.onReturn 
}" action="dialog:pop1" useWindow="true" />

popup1.xhtml :
<tr:commandButton text="pop2" id="openPop2" returnListener="#{pop1Bean.onReturn 
}" action="dialog:pop2" useWindow="true"/>
<tr:commandButton text="close pop1" id="closePop1" inlineStyle="display:none;" 
actionListener="#{pop1Bean.closePop1 }"/>
 
popup2.xhtml :
 
<tr:commandButton text="Close pop2">
  <tr:returnActionListener value="50"/> <!-- also works from Java with 
returnFromDialog -->
</tr:commandButton>

 
pop1Bean.java :
public void onReturn(ReturnEvent evt)
{
  result=(String) evt.getReturnValue();
  FacesContext context = FacesContext.getCurrentInstance(); 
  ExtendedRenderKitService erks = Service.getRenderKitService(context, 
ExtendedRenderKitService.class); 
  erks.addScript(context, 
"setTimeout(\"document.getElementById('closePop1').onclick();\",500);");  // a 
timeout is necessary
}

public void closePop1(ActionEvent e)
{
  RequestContext.getCurrentInstance().returnFromDialog(result, null);
}

mainBean.java :

public void onReturn(ReturnEvent evt)
{
  String returned=(String) evt.getReturnValue();
}




> Multi Dailog Close(returnFromDailog) not working with trinidad 1.2.8 
> ---------------------------------------------------------------------
>
>                 Key: TRINIDAD-1121
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1121
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>    Affects Versions:  1.0.8-core,  1.2.8-core
>         Environment: trinidad 1.2.8, Myfaces 1.2.2, Jboss 4.3 bundled with 
> JSF 1.2 Implementation
>            Reporter: Nitin Sharma
>            Priority: Blocker
>         Attachments: ChooseIntegerBean.java
>
>
> We are upgrading our application from trinidad 1.0.1 to trinidad 1.2.8 with 
> JBOSS upgrade from 4.0.5 to 4.3.o version. In this upgrade we are stuck with 
> blocker related with trinidad dialog Framework.
> Actually we have a requirement of opening multiple dialogs i.e. dialog over 
> dialog and close of topmost dialog should close all the pop up windows and 
> control should be returned to Parent page. 
> This functionality is working alright with trinidad 1.0.1 but we are still 
> not able to make it work with both trinidad 1.2.8 and trinidad 1.0.8.
> To achieve this functionality with trinidad 1.0.1 we have done following 
> things at code level,
> 1) On parent page a dialog is opened on action of commandButton using 
> "dailog:dialogName1" and having launchListener and retrunListener associated.
> 2) On the dailog opened from step 1 we have another action commandButton to 
> open the third level dialog and this commandButton is having a returnListner 
> to handle the return of the third level dailog.
> 3) On the third level dialog on click of close button a action method is 
> called which calls 
> "RequestContext.getCurrentInstance().returnFromDialog(null,null) to close the 
> dailog.
> 4) After this control is passed to the returnListener of dialog at second 
> level in which again 
> "RequestContext.getCurrentInstance().returnFromDialog(null,null) to close 
> this dailog as well and return control to Parent window.
> This same code is not working with trinidad 1.2.8 and as suggested in user 
> forum to make it work with trinidad 1.0.8 but it didn't work with it as well.
> Also I have tried the same scenario changing the trinidad 1.2.8 dialog 
> framework demo as follows,
> 1) Changed the sayHello() returnListner method in chooseIntegerBean.java to 
> call "RequestContext.getCurrentInstance().returnFromDialog(null,null)".
> 2) Due to Point 1 change instead of rendering the chooseInteger.jspx it will 
> close it and control will be returned to launchDialog.jspx from 
> simpleDialog.jspx.
> But this didn't work.
> Please let us know whether we are doing something wrong or the solution to 
> this problem as without this we cann't move forward with our upgrade.
> Please find below the link to user forum posting for this issue,
> http://www.nabble.com/parent-popup-window-is-not-closing-while-closing-child-td17608513.html#a17818219
> Thanks,
> Nitin

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to