Search code examples
tapestry

Tapestry make Select mandatory


I want to create a dropdown List with Select and I want to have a default value in it (something along the lines of "choose something").

The default I get but how do I "force" the user to choose from the select input? Should I catch it's value when I commit? Is there no cleaner way?


Solution

  • Try "validate".

    Works like this:

    <t:zone t:id="modelZone" id="modelZone">
             <t:if test="yourZoneTestVariable">
               <p>
                  <t:select t:id="selectId" model="yourModel" validate="required"/>
               </p>
             </t:if>
          </t:zone>
    

    Hope this helps you.

    More information is here (though it is hard to read for tapestry beginners): http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/corelib/components/Select.html