On 9/12/06, Sean Schofield <[EMAIL PROTECTED]> wrote:

This looks good.  Sorry I haven't responded sooner but I'm in another
busy patch with my day job.

What about a convenience method for cancelling the dialog as well?


Great minds think alike :-).  See DialogContext.stop().


Sean


Craig


On 9/11/06, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> On 9/11/06, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> >
> >
> >     public String checkout() {
> >
> >         // Cancel the current dialog (if any, whatever it is)
> >         FacesContext context = FacesContext.getCurrentInstance();
> >         DialogContextManager manager = (DialogContextManager)
> >           context.getApplication
().getVariableResolver().resolveVariable(
> > Constants.MANAGER_BEAN);
> >         DialogContext dcontext = (DialogContext)
> >           context.getApplication
().getVariableResolver().resolveVariable(
> > Constants.CONTEXT_BEAN);
> >         if (dcontext != null) {
> >             manager.remove(dcontext);
> >         }
> >
> >         // Programmatically start the "CheckOut" dialog and advance
> >         // it to the point where it needs to display a view
> >         dcontext = manager.create(context, "CheckOut");
> >         String viewId = dcontext.advance(context, null);
> >
> >         // Navigate to the requested view
> >         ViewHandler vh = context.getApplication ().getViewHandler();
> >         UIViewRoot view = vh.createView(context, viewId);
> >         view.setViewId(viewId);
> >         context.setViewRoot(view);
> >         context.renderResponse();
> >         return null;
> >
> >     }
> >
>
>
> OK, I've addressed the verbosity of programmatically starting a new
dialog.
> The programmatic start and navigate now collapses to:
>
>         // Create and start the "CheckOut" dialog
>         dcontext = manager.create(context, "CheckOut");
>         dcontext.start(context);
>         return null;
>
> We should consider pushing the actual navigation on an ongoing
DialogContext
> instance to inside the advance() method as well, although in practice
that
> would only simplify a bit of logic inside Dialog2NavigationHandler, not
any
> application level code.
>
> Craig
>
>

Reply via email to