2

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

Joxeja
  • 43
  • 1
  • 5

1 Answers1

6

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Do yo know some alternate ways to process the sub-form? – Joxeja Oct 18 '12 at 15:08
  • Depends on the concrete functional requirement, but you didn't tell anything about it. One of the ways would be using ajax to partially execute the form. – BalusC Oct 18 '12 at 15:10
  • I have tried to do it. I remove the form and I use f:ajax tag, putting into the atribute execute the list of inputtext, inputhidden, ... I want to capture in the server side, but the setter function of this property don't execute. Some help? – Joxeja Oct 18 '12 at 16:20
  • As long as the functional requirement is not elaborated in detail, it's not possible to give a suitable answer. – BalusC Oct 18 '12 at 16:22