0 Replies Latest reply on Jun 12, 2007 2:30 PM by dajevtic

    JSPs and Facelets in one seam application?

    dajevtic

      Hi! Is it possible to run a seam application with jsp and facelet support?

      I've tried using my own ViewHandler (a modified version used to work months ago)
      however this doesn't work anymore:

      Before (used to work in seam 1.1):

      public class JspAndFaceletViewHandler extends FaceletPortletViewHandler {
      
       private static final Log log = LogFactory.getLog(JspAndFaceletViewHandler.class);
      
       private SeamViewHandler seamViewHandler = null;
      
       private static final String FaceletSuffixConfigParameter = "javax.faces.DEFAULT_SUFFIX";
      
       private String faceletSuffix = null;
      
       /**
       * @param arg0
       */
       public JspAndFaceletViewHandler(ViewHandler arg0) {
       super(arg0);
       seamViewHandler = new SeamViewHandler(arg0);
       }
      
       /* (non-Javadoc)
       * @see javax.faces.application.ViewHandler#renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)
       */
       public void renderView(FacesContext arg0, UIViewRoot arg1)
       throws IOException, FacesException {
       if ((faceletSuffix != null) && (arg1.getViewId().endsWith(faceletSuffix))) {
       super.renderView(arg0, arg1);
       } else {
       seamViewHandler.renderView(arg0, arg1);
       }
       }
      
       @Override
       public UIViewRoot createView(FacesContext arg0, String arg1) {
      
       if (faceletSuffix == null) {
       faceletSuffix = arg0.getExternalContext().getInitParameter(FaceletSuffixConfigParameter);
       }
      
       if ((faceletSuffix != null) && (arg1.endsWith(faceletSuffix))) {
       return super.createView(arg0, arg1);
       } else {
       return seamViewHandler.createView(arg0, arg1);
       }
       }
      
      }
      


      Now tried this (but only little luck):
      public class JspAndFaceletViewHandler extends ViewHandlerWrapper {
      
       private static final Log log = LogFactory.getLog(JspAndFaceletViewHandler.class);
      
       private FaceletViewHandler faceletViewHandler = null;
      
       private ViewHandler wrapped = null;
      
       private static final String FaceletSuffixConfigParameter = "lmg.faces.DEFAULT_SUFFIX";
      
       private String faceletSuffix = null;
      
       /**
       * @param arg0
       */
       public JspAndFaceletViewHandler(ViewHandler arg0) {
       wrapped = arg0;
       faceletViewHandler = new FaceletViewHandler(arg0);
       }
      
       /* (non-Javadoc)
       * @see javax.faces.application.ViewHandler#renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)
       */
       public void renderView(FacesContext arg0, UIViewRoot arg1)
       throws IOException, FacesException {
      
       log.info("view is " + arg1 + " " + arg1.getViewId());
      
       if ((faceletSuffix != null) && (arg1.getViewId().endsWith(faceletSuffix))) {
       faceletViewHandler.renderView(arg0, arg1);
       } else {
       getWrapped().renderView(arg0, arg1);
       }
       }
      
       @Override
       public UIViewRoot createView(FacesContext arg0, String arg1) {
      
       log.info("create view " + arg1);
      
       if (faceletSuffix == null) {
       faceletSuffix = arg0.getExternalContext().getInitParameter(FaceletSuffixConfigParameter);
       }
      
       if ((faceletSuffix != null) && (arg1.endsWith(faceletSuffix))) {
       return faceletViewHandler.createView(arg0, arg1);
       } else {
       return getWrapped().createView(arg0, arg1);
       }
       }
      
       @Override
       protected ViewHandler getWrapped() {
       return wrapped;
       }
      
       @Override
       public String calculateRenderKitId(FacesContext arg0) {
       // TODO Auto-generated method stub
       return super.calculateRenderKitId(arg0);
       }
      
      
      }
      

      Pages are shown correctly but as soon as I try an ajax or regular action, request fails without stack trace.

      My goal (question) is:
      I have an old application with hundreds of JSPs. Using seam-gen I created a stub application of the existing database and I use Facelets in those. However we want to be able to run both (the existing JSPs and the new facelets) while slowly porting the JSPs to Facelets.
      Is there any way to get both running in one app?