[英]JSF2.0: How to write h:form in MyComponent in Java?
I'm writing a JSF2.0-component as a Java class and Renderer class and so on. 我正在编写一个JSF2.0组件作为Java类和Renderer类等等。 I can't write parts of the output in the xhtml like
我不能在xhtml中编写部分输出
<h:outputText ... />
because the elements are generated dynamically. 因为元素是动态生成的。
So I get the message "The button/link/text component needs to have a Form in its ancestry. Please add .". 所以我收到消息“按钮/链接/文本组件需要在其祖先中有一个表单。请添加。”。 Below you can see how I currently render a form.
您可以在下面看到我目前如何呈现表单。 Is this correct too?
这也是正确的吗? Or should change something to make the warning dissappear?
或者应该改变一些东西以使警告消失?
private void encodeForm(Element elem) throws IOException { //ResponsWriter writer writer.startElement("form", form); encodeChildren(elem); writer.endElement("form"); }
Thanks for any help! 谢谢你的帮助!
Is this correct too?
这也是正确的吗? Or should change something to make the warning dissappear?
或者应该改变一些东西以使警告消失?
Your best bet would be to just remove the code you've shown and ask the users of said component to place it inside a form. 您最好的选择是删除您显示的代码,并要求所述组件的用户将其放在表单中。
At any length, what you're doing is writing markup for a form. 在任何情况下,您正在做的是为表单编写标记。 This is something else than actually putting a form component in the tree.
这不是实际将表单组件放在树中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.