Hello Simon, Thank you for your thoughts. When I interpreted the description stated on http://wiki.apache.org/myfaces/JavascriptOpenNewWindow correctly , I would expect this inline javascript code to appear in the 'onload' event of the body tag on the resulting page, so that the popup is rendered as soon as the page is loaded by the browser. So for me the code fragment does not look like an example for a custom renderer class, but maybe I misunderstood it.
Nevertheless your suggestion is a feasible workaround to solve my problem. But I'm still interested in getting some statement concerning the description on the Wiki page referenced above. Regards, CAK -- Carsten Kaiser Principal Consultant mailto:[EMAIL PROTECTED] Mobile: +49 (0)170 5270206 Valtech GmbH Werner-Heisenberg-Straße 2 63263 Neu-Isenburg Germany Phone: +49 (0)6102 88468-0 Fax: +49 (0)6102 88468-28 http://www.valtech.de Geschäftsführer: Ingo Kriescher Amtsgericht Düsseldorf HRB48672 -----Ursprüngliche Nachricht----- Von: Simon Kitching [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 27. März 2007 21:58 An: MyFaces Discussion Betreff: Re: How to add inline javascript in application phase? Carsten Kaiser wrote: > Hello, > > > > I'm facing the following problem: > > I have an action, in which I want to trigger a popup window, in case the > triggered background job failed. According to the MyFaces Wiki > > this can be achieved by > > > > FacesContext context = getFacesContext(); > > ViewHandler viewHandler = getApplication().getViewHandler(); > > String actionUrl = viewHandler.getActionURL(context, a_viewId); > > StringBuffer javaScriptText = *new* > StringBuffer("window.open('"); > > javaScriptText.append(actionUrl); > > javaScriptText.append("', 'popupWindow', 'dependent=yes, > menubar=no, toolbar=no');"); > > AddResource addResource = > AddResourceFactory./getInstance/(context); > > addResource.addInlineScriptAtPosition(context, > AddResource./HEADER_BEGIN/, javaScriptText.toString()); > > > > Unfortunately the ResponseWriter is not yet set on the FacesContext > during this phase, so a NPE occurs when adding the inline script code > > like in the last code line shown above. As far as I figured out the > response writer is setup/initialized in the render response phase. So > how could > > this code ever worked? Trying to create a response writer manually just > messed up the whole view... (Later works for the AJAX stuff, but I > > guess, that is because the normal response isn't rendered in this case!) > > > > Any hints welcome! I don't understand what you're trying to achieve here. It doesn't make any sense to output javascript "inline" during the invoke-application phase; where would you expect the javascript to appear in the resulting page?? What is wrong with doing the following? <t:div style="display:hidden" rendered="#{bean.popupWanted}"> <script type="text/javascript"> // your code to pop up the window </script> </t:div> where method getPopupWanted returns true if the background job failed. I expect the code fragment you display above is meant to be used by custom Renderer classes, not backing beans. Regards, Simon

