从命令按钮调用另一个表格 [英] Call another form from the command button

查看:99
本文介绍了从命令按钮调用另一个表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我提交表单时,它应该调用另一个表单,以便我可以呈现它.我使用了primefaces,并且希望它能像下面这样工作.但这引发了错误.

When I submit a form it should call another form so that I can render it. I use primefaces and I want it to work something like below. But it is throwing an error.

<h:form id="from1">
<h:inputText=......
<h:outputText=....
<p:commandButton id="submit" actionlistener="#{bean.method}" value="submit" process="form2"/>

<h:form id="form2">
<h:outoutText value="it is working" render="#{bean.boolean}" />
</h:form>

错误

[Faces Servlet]] (http--127.0.0.1-8080-2) Servlet.service() for servlet Faces Servlet threw exception: javax.faces.FacesException: Cannot find component with identifier "form2" referenced from "form1_submit".

已更新

<h:form id="from1">
    <h:inputText=......
    <h:outputText=....
    <p:commandButton id="submit" actionlistener="#{bean.method}" value="submit" update=":form1"/>
</h:form>

推荐答案

有两个错误:

  • Relative component client IDs are releative to the closest parent UINamingContainer component (which is in your case thus the <h:form id="form1">). The client ID "form2" does not exist anywhere within the context of "form1". You need to use an absolute client ID instead, prefixed with the naming container separator character which defaults to :. This will search for components from the view root on.

process=":form2"

  • 您不能通过提交一种表单来处理另一种表单.根本没有提交您需要处理的所有字段(请注意,这不是JSF限制,而是HTML限制).只需将您需要处理的字段用与提交时相同的形式括起来即可.

  • You cannot process another from by a submit of one form. All of the fields which you need to be processed are not been submitted at all (note that this is not a JSF limitation, but a HTML limitation). Just enclose the fields which you need to process in the very same form as you need to submit.

    这篇关于从命令按钮调用另一个表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆