Problems with composite components that include form

核能气质少年 提交于 2019-12-12 20:25:04

问题


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>

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>

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?

I am using mojarra 2.1.7, Java 6.0 y Tomcat 7.0


回答1:


Nesting <form> elements is illegal in HTML. As JSF is merely a HTML code generator, you can't do any magic with JSF here.

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".



来源:https://stackoverflow.com/questions/12952404/problems-with-composite-components-that-include-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!