myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Kaiser" <>
Subject How to add inline javascript in application phase?
Date Tue, 27 Mar 2007 11:18:13 GMT

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("'");


        javaScriptText.append("', 'popupWindow', 'dependent=yes,
menubar=no, toolbar=no');");

        AddResource addResource =

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!


Carsten Kaiser
Principal Consultant
Mobile: +49 (0)170 5270206

Valtech GmbH
Werner-Heisenberg-Straße 2
63263 Neu-Isenburg

Phone: +49 (0)6102 88468-0
Fax: +49 (0)6102 88468-28

Geschäftsführer: Ingo Kriescher
Amtsgericht Düsseldorf HRB48672

View raw message