日期:2014-05-17  浏览次数:20469 次

Use the <f:verbatim> tag for nested HTML.
Use the <f:verbatim> tag for nested HTML.

在写JSF代码时,发现老是有以下的异常报出:
Component with id '_idJsp7' (org.apache.myfaces.taglib.html.HtmlPanelGroupTag tag) and path : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/calculator.jsp][Class: javax.faces.component.html.HtmlPanelGroup,Id: _idJsp7]}renders it's children, but has embedded JSP or HTML code. Use the <f:verbatim> tag for nested HTML. For comments use <%/* */%> style JSP comments instead of <!-- --> style HTML comments.

当时真是一看到红色的异常血压也就蹭蹭地上升,也就没能静下心来看看这些异常是什么意思,就条件反射地Google一下.可Google出来的又全都是英文,磕磕绊绊地看了会就放下心了.

现在心情好些再来看这个问题时,发现它远没有想像中那么可怕.人家异常里也说的很清楚.就是在写jsf页面时,有些JSF组件(如grid_panel)里是不能嵌套HTML代码了.若想硬往里写就只得用<f:verbatim> tag了.

http://gceclub.sun.com.cn/prodtech/javatools/jscreator/reference/docs/help/ui_elements/palette/jsf-val-conv/f_verbatim.html给的链接里有如下描述:
?? ?此高级组件是一个定制 <f:verbatim/> 标记,用于将 HTML 元素添加到某些组件中,并使 HTML 元素具有这些组件的行为。将 HTML 标记包装在 <f:verbatim/> 标记中,使其具有 JavaServer Faces 组件的行为,这样便解决了同时包含 JavaServer Faces 组件和 HTML 元素的页中出现的一些问题。

  • 标记组件更易于用来将 HTML 标记添加到 JSP 页面。
??? ?? 这样又顺着想起了另一个问题:现在这样是在JSP中用JSF时出的问题,那若用faclet是不是不会有这个问题了呢?若没有这个异常报出,那么这个异常也就是有JSF生命周期里的Render阶段报出啦?
1 楼 yuchang314 2009-05-08  
[img][/img]
引用