if this is a use case for *each* request, I suggest using a PhaseListener.
for a special page, take a look at Shale's ViewController.
that has a init() method to do some things *before* the page is rendered.

mixing jsp/jsf is not really a good/maintainalbe thing ;)

On 8/26/06, Mikhail Grushinskiy <[EMAIL PROTECTED]> wrote:
How to clean up bean from session when using facelets? I need to remove bean
if the request contains cleanupFlag parameter.
When I used JSP I did it with this small java scriptlet at the begining of
the page.

<jsp: directive.page

import="javax.faces.context.FacesContext,javax.faces.component.UIViewRoot,javax.faces.application.ViewHandler"
  contentType="text/html;charset=iso-8859-1"
  buffer="64kb"/>
   <jsp:scriptlet>
        if(request.getParameter("cleanupFlag") != null) {

FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("formBean");
{
          // recreate view
          FacesContext facesContext = FacesContext.getCurrentInstance();

facesContext.getApplication().createValueBinding("#{formBeanId}").setValue(facesContext,
null);
         ViewHandler viewHandler =
facesContext.getApplication().getViewHandler();
         UIViewRoot newRoot = viewHandler.createView(facesContext,
facesContext.getViewRoot().getViewId());
         facesContext.setViewRoot (newRoot);
         }
       }
 </jsp:scriptlet>

Thanks, --MG





--
Matthias Wessendorf

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Reply via email to