Call another form using the command button

When I submit a form, it must call another form so that I can display it. I use primitives and I want it to work as shown below. But this is a mistake.

XHTML

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

Update

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

There are two errors:

  • UINamingContainer ( <h:form id="form1">). "form2" "form1". , , :. .

    process=":form2"
    
  • . , , ( , JSF, HTML). , , , , .

+12

p: remoteCommand JS onclick .

+4

All Articles