【问题标题】:primefaces 3.5 fileuploauder form dont work inside other formprimefaces 3.5 fileuploauder 表单在其他表单中不起作用
【发布时间】:2013-03-08 15:14:36
【问题描述】:

在这种情况下它工作正常,上传文件没有问题(在我编辑 web.xml 添加过滤器和 faces-confing 添加依赖项之前):

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

【问题讨论】:

  • 你不能在另一个表单中包含一个表单。在 HTML 中嵌套表单我是无效的。删除&lt;h: form=form 3sd&gt;。你的第一种方法只有正确的方法。

标签: jsf-2 primefaces


【解决方案1】:

您不能在 JSF 中嵌套表单。在 HTML 中这样做是无效的,因此在 JSF 中是无效的,因为它被转换为 HTML。

无论您是否删除“主”表单,您都没有内部表单,并且您的网站上有 2 个表单。

另见

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 2013-03-07
    • 1970-01-01
    • 1970-01-01
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多