Java JSF 1.2 startElement和writeAttribute解释

Java JSF 1.2 startElement和writeAttribute解释,java,jsf,jsf-1.2,Java,Jsf,Jsf 1.2,我有机会为我的项目编写一些自定义渲染器,效果非常好。但是,我对ResponseWriter方法中的一些参数有些困惑。文档没有很好地解释这一点,所以我希望常驻的JSF专家能够更好地解释这一点。具体而言: public abstract void startElement(java.lang.String name, javax.faces.component.UIComponent component)

我有机会为我的项目编写一些自定义渲染器,效果非常好。但是,我对ResponseWriter方法中的一些参数有些困惑。文档没有很好地解释这一点,所以我希望常驻的JSF专家能够更好地解释这一点。具体而言:

public abstract void startElement(java.lang.String name,
                              javax.faces.component.UIComponent component)
                       throws java.io.IOException

Parameters:
    name - Name of the element to be started
    component - The UIComponent (if any) to which this element corresponds 
第二个参数实际上是做什么的?无论我在渲染器中传递“null”还是“this”,似乎都可以正常工作

与writeAttribute类似:

public abstract void writeAttribute(java.lang.String name,
                                java.lang.Object value,
                                java.lang.String property)
                         throws java.io.IOException

Parameters:
    name - Attribute name to be added
    value - Attribute value to be added
    property - Name of the property or attribute (if any) of the UIComponent associated with the containing element, to which this generated attribute corresponds 
为什么响应编写者需要知道支持属性?同样,如果我在编写class属性时传递null或“styleClass”,它似乎可以正常工作


好奇的人想知道,我的google fu在这一点上失败了…

标准的Mojarra实现对他们没有任何作用。
startElement()
组件
参数和
writeAttribute()
属性
参数被完全忽略

但是,可以提供自定义响应编写器。对于一些实际实现,了解响应编写器中的原始
UIComponent
和/或相关
UIComponent
属性是完全有意义的


尽管JSF2.0是有针对性的,但这将是一个很好的例子。
startElement()
在允许/写入一些特定的HTML5属性之前,通过几个
instanceof
检查来确定
UIComponent
的类型。

据我所知,这些主要是为了调试目的,可能是为了一些奇怪的
ResponseWriter
实现。标准版当然不在乎,我通常只通过
null
,不麻烦。是的,我看过你非常好的html5ResponseWriter,并在你的博客上对此发表了评论。我们越早升级到WAS 8和JSF2.0越好!