If it were me, I'd look at having a meta-refresh tag submit a normal action.
The action would check the status of the background process, and
either return the "in progress" page again or return the "action
completed" page.

You shouldn't need to anything strange like try to short-circult the
JSF lifecycle or manually construct a response.

On 2/8/07, Mikael Andersson <[EMAIL PROTECTED]> wrote:
Looking for some more suggestions :), I would prefer not to use ajax since
it is quite a simple page.

I have tried some more (hacky) stuff which didn't work either :( :

The below changed the location URL, but don't load the page?? Any ideas.

public static void programmaticForward2( final String viewId ) throws
IOException{
        FacesContext faces = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse)
faces.getExternalContext().getResponse();

        response.setContentType("text/html");
        response.setHeader("Location", "http://localhost:8080/dss "
+viewId);

        faces.responseComplete();
        response.getOutputStream().flush();
        response.getOutputStream().close();

}

The below didn't do anything?

public static void programmaticForward3( final String viewId ) throws
IOException{
        FacesContext faces = FacesContext.getCurrentInstance();
        HttpServletResponse response = (HttpServletResponse)
faces.getExternalContext().getResponse();
        HttpServletRequest request =
(HttpServletRequest)faces.getExternalContext().getRequest();

        PrintWriter out = response.getWriter();

        response.setContentType("text/html");
        response.sendRedirect("http://"; +request.getServerName() +":"
+request.getServerPort() +"/dss" +viewId);

        faces.responseComplete();
        out.flush();
        out.close();

}

Cheers,
 Mike no.2



On 07/02/07, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
> Here's an ajax solution for a progress bar:
>
>
http://weblogs.java.net/blog/edburns/archive/2005/05/ajaxian_faces_p.html
>
https://blueprints.dev.java.net/bpcatalog/ee5/ajax/usingAJAXwithoutJSF.html
>
> Seems like there should be a way to solve this without ajax, though.
> Maybe using a meta refresh.
>
>
> On 2/7/07, Mikael Andersson < [EMAIL PROTECTED]> wrote:
> > Hi,
> > I have an action which performs a length operation, I'd like to get the
> > browser to redisplay the page while the process keeps running on the
server.
> >
> > I wonder how I perform a programmatic forward which in an action method,
> > which causes the browser to re-render the page while the action method
is
> > still running.
> >
> > Is there a way of doing this without spawning a new Thread?
> >
> > I made the following futile attempt :
> >
> > Managed bean:
> >
> > public String longishRunningAction(){
> >
> >   try{
> >     NavigationUtil.programmaticForward
> > ("/report/index.xhtml");
> >   }
> >   catch(Exception e){}
> >
> >   doLongishRunningOperation();
> >
> >   return null;
> > }
> >
> >
> > Some of the stuff in here were added just to see if the made a
difference,
> > they didn't :)
> >
> > public class NavigationUtil {
> >
> >     /**
> >      * Force a forward programmatically
> >      *
> >      * @param viewId the viewId to forward to, ex. /report/index.xhtml
> >      * @throws ServletException
> >      * @throws IOException
> >      */
> >     public static void programmaticForward( final String viewId ) throws
> > ServletException, IOException{
> >
> >         ExternalContext eCtx =
> > FacesContext.getCurrentInstance().getExternalContext();
> >         HttpServletRequest request =
> > (HttpServletRequest)eCtx.getRequest();
> >         HttpServletResponse response =
> > (HttpServletResponse)eCtx.getResponse();
> >         RequestDispatcher dispatcher = request.getRequestDispatcher(
viewId
> > );
> >
> >         dispatcher.forward(request,response);
> >
> >         FacesContext.getCurrentInstance().responseComplete();
> >
> >         response.getOutputStream().flush();
> >         response.getOutputStream().close();
> >
> >     }
> >
> > }
> >
> >
>


Reply via email to