This tag is also like message tag which is also used to show all messages at one place for the components. Two layouts are supported for generated messages, table and list. If layout is not specified then it takes list layout and all messages are displayed in a line. We can use different CSS styles and class with different type of messages on different severity. We can change the format of the message string.
Code Description :
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%> <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>t:messages example</title>
<style type="text/css">
<!--
body{
background-color:#fff2f2;
margin-top:30;
}
-->
</style>
</head>
<body ><center>
<f:view>
<h:form id="form1" >
<h:panelGrid id="pg" columns="2"
style="background-color:#66CCFF;">
<t:outputLabel id="ol1" for="UserName"
value="User Name" style="font-weight:bold"/>
<t:inputText id="UserName" required="true"/>
<t:outputLabel id="ol2" for="Password"
value="Password" style="font-weight:bold"/>
<t:inputSecret id="Password" required="true"/>
<t:outputText value=" "/>
<h:panelGroup>
<t:messages layout="table"/>
</h:panelGroup>
<t:outputText value=" "/>
<t:commandButton id="btnSubmit" value="Submit"
action="welcome"
style="border-color:#000000;font-weight:bold"/>
</h:panelGrid>
</h:form>
</f:view>
</center></body>
</html>
|
Rendered Output : If the use leaves fields blank then all the messages are displayed at one place like in the figure below :

Html Source Code :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>t:messages example</title>
<style type="text/css">
<!--
body{
background-color:#fff2f2;
margin-top:30;
}
-->
</style>
</head>
<body ><center>
<form id="form1" name="form1" method="post"
action="/tomahawk_tags/pages/messages.jsf"
enctype="application/x-www-form-urlencoded">
<table id="form1:pg" style="background-color:#66CCFF;">
<tbody><tr><td><label id="form1:ol1" style="font-weight:bold"
for="form1:UserName">User Name</label></td><td>
<input id="form1:UserName" name="form1:UserName"
type="text" value="" /></td></tr>
<tr><td><label id="form1:ol2" style="font-weight:bold"
for="form1:Password">Password</label></td><td>
<input type="password" id="form1:Password"
name="form1:Password" /></td></tr>
<tr><td> </td><td></td></tr>
<tr><td> </td><td><input id="form1:btnSubmit"
name="form1:btnSubmit" type="submit" value="Submit"
onclick="if(typeof window.clearFormHiddenParams_
form1!='undefined')
{clearFormHiddenParams_form1('form1');}"
style="border-color:#000000;font-weight:bold" /></td></tr>
</tbody></table>
<input type="hidden" name="form1_SUBMIT" value="1" />
<input type="hidden" name="form1:_link_hidden_" />
<input type="hidden" name="form1:_idcl" />
<script type="text/javascript"><!--
function clear_form1()
{
clearFormHiddenParams_form1('form1');
}
function clearFormHiddenParams_form1(currFormName)
{
var f = document.forms['form1'];
f.elements['form1:_link_hidden_'].value='';
f.elements['form1:_idcl'].value='';
f.target='';
}
clearFormHiddenParams_form1();
//--></script><input type="hidden" name="javax.faces.ViewState"
id="javax.faces.ViewState" value="rO0ABXVyABNbTGphdmEubGFuZy5PYmpl
Y3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAEzcHQAEy9wYWdlcy9tZXNzYWdlcy5qc3A=" />
</form>
</center><!-- MYFACES JAVASCRIPT --> </body> </html> |
This tag contains attributes given below :
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Tomahawk messages tag
Post your Comment