自定义jsf组件,包括带回退的页面

时间:2011-02-09 16:48:46

标签: jsf facelets

我遇到了一个我构建的相当基本的自定义组件(使用JSF1.2和facelets) 它与常规的ui:include相同,但是如果无法找到包含文件,它会呈现自己的子节点(如ui:include中的异常的instread)。

以下是我的TagHandler中apply()函数的代码: 查看plaincopy到clipboardprint?

if (path == null || path.length() == 0) {  
       log.debug("Path is empty or 0: src=" + src + ";path=" + path);  
       included = false;  
   } else {  
       VariableMapper orig = ctx.getVariableMapper();  
       ctx.setVariableMapper(new VariableMapperWrapper(orig));  
       try {  
           this.nextHandler.apply(ctx, null);  
           ctx.includeFacelet(parent, path);  
       } catch (java.io.FileNotFoundException ex) {  
           log.debug("Failed to include page: " + ex.getMessage());  
           included = false;  
       } finally {  
           ctx.setVariableMapper(orig);  
       }  
   }  

   if (!included) {  
       // The includepage was not included, so we render the child tags as a fallback  
       this.nextHandler.apply(ctx, parent);  
   }  
   if (path == null || path.length() == 0) {  
       log.debug("Path is empty or 0: src=" + src + ";path=" + path);  
       included = false;  
   } else {  
       VariableMapper orig = ctx.getVariableMapper();  
       ctx.setVariableMapper(new VariableMapperWrapper(orig));  
       try {  
           this.nextHandler.apply(ctx, null);  
           ctx.includeFacelet(parent, path);  
       } catch (java.io.FileNotFoundException ex) {  
           log.debug("Failed to include page: " + ex.getMessage());  
           included = false;  
       } finally {  
           ctx.setVariableMapper(orig);  
       }  
   }  

   if (!included) {  
       // The includepage was not included, so we render the child tags as a fallback  
       this.nextHandler.apply(ctx, parent);  
   }  

问题是,代码在“this.nextHandler.apply(ctx,null)上失败,说”父UIComponent为null。 当我确保标签没有任何子标签时,它不会给我一个错误......

周围有专家谁知道我做错了什么? 非常感谢提前!

0 个答案:

没有答案