This tag is used create compound component that is used to layout other components. This tag renders html table with specified no. of columns. Children of this element are rendered in cells of the columns of the table. This tag helps to construct the table which can automatically arrange the elements in cells of the table of specified columns. Suppose, we have specified no. of columns to 3 and we have taken 5 elements then these elements will get automatically arranged in two rows (3 elements in 3 columns consecutively in the the first row and other 2 in the second row in the same manner. So last two elements will be visible in two columns and third will be blank. For more stylish and customized appearance CSS can be used. By default the no. of columns is "1". The no. of rows is decided by the no. of elements to display in the specified no. of columns.
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:panelGrid example</title>
<style type="text/css">
<!--
body{
margin-top:30;
}
.highlight { background-color: #A8D1E8; color:#000000;}
.TableRow1 {
background-color: #D0E6E0;
}
.TableRow2 {
background-color: #E8F7F1;
}
.TableColumn {
text-align: center
}
.TableClass {
font-family : verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000000;
padding: 2;
border-style: solid;
border-width: 2px;
}
.TableHeader {
color: #000000;
background-color: #F1F1F1;
padding: 3;
text-align: center;
border: none;
}
.TableFooter {
background-color: #F1F1F1;
}
-->
</style>
</head>
<body ><center>
<f:view>
<h:form id="form1" >
<t:panelGrid id="dt1" bgcolor="#F1F1F1" columns="2" border="10"
cellpadding="5" cellspacing="3" dir="LTR" frame="hsides"
rules="all" summary="This is a JSF code to create panelGrid."
rowClasses="TableRow1,TableRow2" columnClasses="TableColumn"
styleClass="TableClass" headerClass="TableHeader"
footerClass="TableFooter" >
<f:facet name="header">
<h:outputText value="Customer Profile" />
</f:facet>
<t:panelGroup >
<t:panelGrid columns="2" style="color:green;">
<f:facet name="header">
<h:outputText value="Personal Information"
style="color:#006699;"/>
</f:facet>
<t:outputText value="Name"></t:outputText>
<t:inputText onmouseover="this.className='highlight'"
onmouseout="this.className='normal'"/>
<t:outputText value="Contact Number"
onmouseover="this.className='highlight1'"
onmouseout="this.className='normal'">
</t:outputText>
<t:inputText onmouseover="this.className='highlight'"
onmouseout="this.className='normal'"/>
</t:panelGrid>
</t:panelGroup>
<t:panelGroup >
<t:panelGrid columns="2" style="color:green;">|
<f:facet name="header">
<h:outputText value="Educational Information"
style="color:#006699;"/>
</f:facet>
<t:outputText value="Certificate Name" ></t:outputText>
<t:inputText onmouseover="this.className='highlight'"
onmouseout="this.className='normal'"/>
<t:outputText value="Year"></t:outputText>
<t:inputText onmouseover="this.className='highlight'"
onmouseout="this.className='normal'"/>
</t:panelGrid>
</t:panelGroup>
<t:panelGroup colspan="2" >
<t:panelGrid columns="4" width="100%"
style="color:green;">
<f:facet name="header">
<h:outputText value="Achievements & Awards"
style="color:#006699;"/>
</f:facet>
<t:outputText value="Name"></t:outputText>
<t:inputText onmouseover="this.className='highlight'"
onmouseout="this.className='normal'"/>
<t:outputText value="Year"></t:outputText>
<t:inputText onmouseover="this.className='highlight'"
onmouseout="this.className='normal'"/>
<t:outputText value="Name"></t:outputText>
<t:inputText onmouseover="this.className='highlight'"
onmouseout="this.className='normal'"/>
<t:outputText value="Year"></t:outputText>
<t:inputText onmouseover="this.className='highlight'"
onmouseout="this.className='normal'"/>
</t:panelGrid>
</t:panelGroup>
<f:facet name="footer">
<h:outputText value="** Your information will be kept secret." />
</f:facet>
</t:panelGrid><br><br>
</h:form>
</f:view>
</center></body>
</html>
|
Rendered Output :

Html Source Code :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>t:panelGrid example</title>
<style type="text/css">
<!--
body{
margin-top:30;
}
.highlight { background-color: #A8D1E8; color:#000000;}
.TableRow1 {
background-color: #D0E6E0;
}
.TableRow2 {
background-color: #E8F7F1;
}
.TableColumn {
text-align: center
}
.TableClass {
font-family : verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 13px;
color: #000000;
padding: 2;
border-style: solid;
border-width: 2px;
}
.TableHeader {
color: #000000;
background-color: #F1F1F1;
padding: 3;
text-align: center;
border: none;
}
.TableFooter {
background-color: #F1F1F1;
}
-->
</style>
</head>
<body ><center>
<form id="form1" name="form1" method="post"
action="/tomahawk_tags/pages/panelGrid.jsf"
enctype="application/x-www-form-urlencoded">
<table id="form1:dt1" bgcolor="#F1F1F1" border="10"
cellpadding="5" cellspacing="3" frame="hsides"
rules="all" summary="This is a JSF code to create panelGrid."
dir="LTR" class="TableClass">
<thead><tr><th class="TableHeader" scope="colgroup" colspan="2">
Customer Profile
</th></tr></thead>
<tfoot><tr><td class="TableFooter" colspan="2">
** Your information will be kept secret.
</td></tr></tfoot><tbody><tr class="TableRow1">
<td class="TableColumn"><table style="color:green;">
<thead><tr><th scope="colgroup" colspan="2">
<span style="color:#006699;">Personal Information</span>
</th></tr></thead><tbody><tr><td>Name</td><td>
<input id="form1:_idJsp5" name="form1:_idJsp5" type="text"
value="" onmouseover="this.className='highlight'"
onmouseout="this.className='normal'" /></td></tr>
<tr><td><span onmouseover="this.className='highlight1'"
onmouseout="this.className='normal'">Contact Number</span></td>
<td><input id="form1:_idJsp7" name="form1:_idJsp7" type="text"
value="" onmouseover="this.className='highlight'"
onmouseout="this.className='normal'" /></td></tr>
</tbody></table></td><td><table style="color:green;">
<thead><tr><th scope="colgroup" colspan="2">
<span style="color:#006699;">Educational Information</span>
</th></tr></thead><tbody><tr><td>Certificate Name</td><td>
<input id="form1:_idJsp12" name="form1:_idJsp12" type="text"
value="" onmouseover="this.className='highlight'"
onmouseout="this.className='normal'" /></td></tr>
<tr><td>Year</td><td><input id="form1:_idJsp14"
name="form1:_idJsp14" type="text" value=""
onmouseover="this.className='highlight'"
onmouseout="this.className='normal'" /></td></tr>
</tbody></table></td></tr>
<tr class="TableRow2"><td class="TableColumn"
colspan="2"><table width="100%" style="color:green;">
<thead><tr><th scope="colgroup" colspan="4">
<span style="color:#006699;">Achievements & Awards</span>
</th></tr></thead><tbody><tr><td>Name</td><td>
<input id="form1:_idJsp19" name="form1:_idJsp19" type="text"
value="" onmouseover="this.className='highlight'"
onmouseout="this.className='normal'" /></td><td>Year</td>
<td><input id="form1:_idJsp21" name="form1:_idJsp21"
type="text" value="" onmouseover="this.className='highlight'"
onmouseout="this.className='normal'" /></td></tr>
<tr><td>Name</td><td><input id="form1:_idJsp23"
name="form1:_idJsp23" type="text" value=""
onmouseover="this.className='highlight'"
onmouseout="this.className='normal'" /></td><td>Year</td>
<td><input id="form1:_idJsp25" name="form1:_idJsp25"
type="text" value="" onmouseover="this.className='highlight'"
onmouseout="this.className='normal'" /></td></tr>
</tbody></table></td></tr>
</tbody></table><br><br>
<input type="hidden" name="form1_SUBMIT"
value="1" /><input type="hidden" name="javax.faces.ViewState"
id="javax.faces.ViewState" value="rO0ABXVyABNbTGphdmEubGFuZy5PYmp
lY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAExcHQAFC9wYWdlcy9wYW5lbEdyaWQuanNw" />
</form>
</center><!-- MYFACES JAVASCRIPT -->
</body>
</html>
This tag contains attributes given below :
- none No side, Default Value
- above Top side only
- below Bottom side only
- hsides Top and bottom sides only
- vsides Right and left sides only
- lhs Left hand side only
- rhs Right hand side only
- box All four sides
- border All four sides
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 panelGrid tag
Post your Comment