0

In this case it is working ok, upload file without problem (before I edited web.xml adding a filter and faces-confing adding dependency):

<h:form id="form1">
    <p:messages id="messages" showDetail="true" autoUpdate="true" />
    <p:panel header="Iniciar sesión" style="width:300px;height:150px;">


        <h:panelGrid columns="2" id="matchGrid">
            <h:outputLabel for="pwd1" value="Usuario: *" />
            <p:inputText id="pwd1" value="#{loginMB.usuario}" label="usuario"
                required="true" />

            <h:outputLabel for="pwd2" value="Clave: *" />
            <p:password id="pwd2" value="#{loginMB.clave}" label="clave"
                required="true" />
        </h:panelGrid>

        <p:commandButton id="saveButton" action="#{loginMB.login}"
            update="matchGrid" value="Entrar" />
    </p:panel>
</h:form>

<h:form enctype="multipart/form-data">

    <p:messages showDetail="true" />

    <p:fileUpload value="#{contratosMB.fileContrato}" mode="simple" />

    <p:commandButton value="Submit" ajax="false"
        actionListener="#{contratosMB.upload}" />

</h:form>

But when I put it inside the other form it doesn't work, why?

<h:form id="form3sd">
    <h:form id="form1">
        <p:messages id="messages" showDetail="true" autoUpdate="true" />
        <p:panel header="Iniciar sesión" style="width:300px;height:150px;">


            <h:panelGrid columns="2" id="matchGrid">
                <h:outputLabel for="pwd1" value="Usuario: *" />
                <p:inputText id="pwd1" value="#{loginMB.usuario}" label="usuario"
                    required="true" />

                <h:outputLabel for="pwd2" value="Clave: *" />
                <p:password id="pwd2" value="#{loginMB.clave}" label="clave"
                    required="true" />
            </h:panelGrid>

            <p:commandButton id="saveButton" action="#{loginMB.login}"
                update="matchGrid" value="Entrar" />
        </p:panel>
    </h:form>

    <h:form enctype="multipart/form-data">

        <p:messages showDetail="true" />

        <p:fileUpload value="#{contratosMB.fileContrato}" mode="simple" />

        <p:commandButton value="Submit" ajax="false"
            actionListener="#{contratosMB.upload}" />

    </h:form>
</h:form>
blo0p3r
  • 6,392
  • 7
  • 47
  • 67
meyquel
  • 1,944
  • 4
  • 21
  • 39
  • 1
    You can't include a form inside another form.Nesting forms in HTML I'd invalid.Remove ``.Your first approach only rt he right approach. – SRy Mar 08 '13 at 15:18

1 Answers1

2

You cannot be nesting forms in JSF. It is invalid to do so in HTML, and therefore is invalid in JSF since it is converted to HTML.

Whether you remove your "master" form, you you do not have inner forms and have 2 forms on your site.

See also

Community
  • 1
  • 1
blo0p3r
  • 6,392
  • 7
  • 47
  • 67