包含形式的复合组件存在的问题 [英] Problems with composite components that include form
问题描述
我正在编写一个复合组件,例如复杂的输入文本,它需要一个完整的表单(它将显示一个搜索表单,并且一个结果列表供用户选择其中之一).
I am writing one composite component like a complex inputtext, that requiere a complete form (it will show a search form and one list of results for the user selects one of them).
<composite:implementation>
<div id="#{cc.clientId}" class="#{cc.attrs.styleClass}">
<h:inputText id="txtIdentificador" ...>
<h:graphicImage id="imgIdentificador" ...>
<h:inputText id="txtDescripcion" ...>
<h:form id="formF2ItemWidget">
...
</h:form>
</div>
</composite:implementation>
从逻辑上讲,我想使用其他形式,但是这样做时会遇到问题.例如
Logically, I would like to use into other form, but I have problems when I do it. e.g.
<h:form id="formOuter" >
<h:outputLabel value="Texto1" />
<trkal:itemwidget id="txtTexto1">
...
</h:form>
生成的HTML没有内部表单(formF2ItemWidget),仅具有id = formOuter的表单.但是在下面的示例中:
The HTML generated hasn't the inner form (formF2ItemWidget), it only has the form with id=formOuter. But in the below example:
<h:form id="formOuter" >
<h:outputLabel value="Texto1" />
<trkal:itemwidget id="txtTexto1">
<h:outputLabel value="Texto2" />
<trkal:itemwidget id="txtTexto2">
...
</h:form>
txtTexto1的表单不存在,但是txtTexto2的表单存在.为什么?
The form for txtTexto1 don't exist, but the form for txtTexto2 exists. Why?
如何编写包含表单的复合组件,而不会出现此问题?
How can I write a composite component that include a form without this problem?
我正在使用mojarra 2.1.7,Java 6.0和Tomcat 7.0
I am using mojarra 2.1.7, Java 6.0 y Tomcat 7.0
推荐答案
嵌套<form>
元素在HTML中是非法的.由于JSF只是HTML代码生成器,因此您无法在此处使用JSF进行任何魔术操作.
Nesting <form>
elements is illegal in HTML. As JSF is merely a HTML code generator, you can't do any magic with JSF here.
不要也将<h:form>
组件嵌套在JSF中.从组合中删除该<h:form>
,并寻找处理子表单"的替代方法.
Just don't nest <h:form>
components in JSF as well. Remove that <h:form>
from the composite and look for alternate ways to process the "sub-form".
这篇关于包含形式的复合组件存在的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!