问题描述
我知道ResponseWriter上的startElement,endElement和writeAttribute方法.我的问题是,例如,我想通过将其声明为HtmlCommandLink link = new HtmlCommandLink();
来输出h:commandLink.
I know about startElement, endElement, and writeAttribute methods on ResponseWriter. My problem is that I want to for example output a h:commandLink by declaring it like HtmlCommandLink link = new HtmlCommandLink();
.
如何在自己的组件中输出其他类似的UIComponent?我可能还想在我的组件中使用一些RichFaces ajax东西,以便希望避免从头开始.
How can I output other UIComponents like this in my own component? I might want to use some RichFaces ajax stuff in my components aswell so hoping I can avoid making it all by scratch.
我想做的是使用以下标记<myTags:commentTree>
创建自己的标记库.每个评论都有一个回复按钮,单击回复按钮后,我会在评论下方显示一个回复表单.呈现后,我想输出例如richfaces <a4j:commandButton>
组件.这必须在我自己的java标记文件中完成,该文件已被Ive称为CommentsTreeUI.java
.
What I'm trying to do is create my own tag library with the following tag <myTags:commentTree>
. Every comment have a reply button, when the reply button is clicked I render the reply form beneath the comment. Once that is rendered, I would like to output for example the richfaces <a4j:commandButton>
component. This have to be done inside my own java tag file which Ive called for CommentsTreeUI.java
.
通常我会用writer.startElement("input", myComponent); writer.writeAttribute("type", "button", null);
输出所有显示表单和按钮的元素,但是如果我能做例如startElement("a4j:commandbutton", myComponent)
,那将对我的ALOT有所帮助,因为它具有所有内置的ajax功能等.
Normally I output all my elements that display the forms and buttons with writer.startElement("input", myComponent); writer.writeAttribute("type", "button", null);
but if I could instead do for example startElement("a4j:commandbutton", myComponent)
that would help my ALOT since it has all the built in ajax features etc.
有任何线索吗?
推荐答案
此问题通过使用
HtmlCommandButton button = new HtmlCommandButton();
button.encodeAll(context);
这篇关于JSF ResponseWriter定制组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!