Search code examples
formstapestry

display 2nd form depending on 1st form result


I have two form in the same Tapestry page's:

First one is composed of :

  • select
  • submit button.

If there is a valid result I display it.

Otherwise I want to display the 2nd form wich is composed of :

  • 4 textfields
  • 1 submit button

So the 2nd must not be displayed first time, but only in case of empty result from the 1st one.


Solution

  • First off: Please share what you have tried so far.

    Second: You can do this in a number of ways. The easiest is just to use a

    <form>
      <t:if test="showFirstForm">
         ....your 1st form content ....
        <p:else>
             ....your 2nd form content ....
        <p:else>
      </t:if>
    </form>
    

    You might also like to have a look at the FormFragment for ajax controlled dynamic form content using triggers to redraw.