Mentawai provides many view tags fully integrated with the framework, which makes your JSP clean and easy. Here are some examples:
Form tags:
<mtw:form action="User.add.mtw" method="post"> Name: <mtw:input type="text" name="fullname" size="50" maxlength="60" /><br/> Group: <mtw:select name="groupId" list="groups" emptyField="true" /><br/> Username: <mtw:input type="text" name="username" size="20" maxlength="30" /><br/> Password: <mtw:input type="password" name="pass" size="20" maxlength="20" /><br/> Confirm: <mtw:input type="password" name="conf" size="20" maxlength="20" /><br/> Zip: <mtw:input type="text" name="zip" size="20" maxlength="20" /><br/> Accept term: <mtw:input type="checkbox" name="accept" value="1" /><br/> <input type="submit" value="Send Now!" /> </mtw:form>
TIP: The form tags above are smart enough to re-display their values in case of a validation error.
NOTE: Mentawai supports most of the form tags with their attributes, and you can always use the extra attribute for additional ones.
List and loop tags:
<mtw:list value="users"> My list of users: <mtw:isEmpty> You don't have anyone in your list! </mtw:isEmpty> <mtw:loop var="u"> Name: <mtw:out value="u.name"/><br/> Email: <mtw:out value="u.email"/><br/> Group: <mtw:out value="u.groupId" list="groups" /><br/> </mtw:loop> </mtw:list>
TIP: The loop tag also supports a counter attribute so you can easily display an index, toggle row colors, etc.
IF tag:
<mtw:if test="user.admim" value="true"> You are an admin! <br/> </mtw:if> <mtw:if test="user.status" value="2"> Your status is bad! Check your balance please! <br/> </mtw:if> <mtw:if test="city" value="Atlanta"> How is the weather in Atlanta? <br/> </mtw:if>
NOTE: When checking getters, Mentawai will try getAdmin(), isAdmin(), hasAdmin() in that order.
ELSE tag:
All Menta tags support the negate attribute to invert the condition being checked. That way you can easily simulate the else functionality:
<mtw:if test="user.admim" value="true"> You are an admin! <br/> </mtw:if> <mtw:if test="user.admim" value="true" negate="true"> You are NOT an admin! <br/> </mtw:if>
NOTE: All Menta Tags support the most common attributes such as class, id, style, etc. In case they are missing any attribute you can also use of the extra atrribute like this: extra="odd=pela".