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>
error
[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".
Updated
<h:form id="from1">
<h:inputText=......
<h:outputText=....
<p:commandButton id="submit" actionlistener="#{bean.method}" value="submit" update=":form1"/>
</h:form>
There are two mistakes:
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"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With