This tag is used to places an html div around its children. So instead of using html div tag we can use JSF tomahawk's own div tag. In this example, div tag uses style class "divStyle" that will be effective on the particular area of captured by div tag.
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:div example</title>
<style type="text/css">
<!--
.divStyle {
text-align: right;
background-color: #D0E6E0;
padding: 3;
font-weight:bold;
}
-->
</style>
</head>
<body >
<f:view>
<h:form id="form1" >
<t:div id="div1" styleClass="divStyle">
<t:commandLink value="HOME" action="welcome"/> |
<t:commandLink value="CONTACT" action="welcome"/> |
<t:commandLink value="ABOUT" action="welcome"/>
</t:div>
</h:form>
</f:view>
</body>
</html>
|
Rendered Output :

Html Source Code :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>t:div example</title>
<style type="text/css">
<!--
.divStyle {
text-align: right;
background-color: #D0E6E0;
padding: 3;
font-weight:bold;
}
-->
</style>
</head>
<body >
<form id="form1" name="form1" method="post"
action="/tomahawk_tags/pages/div.jsf"
enctype="application/x-www-form-urlencoded">
<div id="form1:div1" class="divStyle">
<script type="text/javascript">
<!-- function oamSetHiddenInput(formname, name, value)
{
var form = document.forms[formname];
if(typeof form.elements[name]=='undefined')
{
var newInput = document.createElement('input');
newInput.setAttribute('type','hidden');
newInput.setAttribute('name',name);
newInput.setAttribute('value',value);
form.appendChild(newInput);
}
else
{
form.elements[name].value=value;
}
}
function oamClearHiddenInput(formname, name, value)
{
var form = document.forms[formname];
if(typeof form.elements[name]!='undefined')
{
form.elements[name].value=null;
}
}
function oamSubmitForm(formName, linkId, target, params)
{
var clearFn = 'clearFormHiddenParams_'+
formName.replace(/-/g, '\$:').replace(/:/g,'_');
if(typeof eval('window.'+clearFn)!='undefined')
{
eval('window.'+clearFn+'(formName)');
}
var oldTarget = '';
if((typeof target!='undefined') && target != null)
{
oldTarget=document.forms[formName].target;
document.forms[formName].target=target;
}
if((typeof params!='undefined') && params != null)
{
for(var i=0; i<params.length; i++)
{
oamSetHiddenInput(formName,params[i][0], params[i][1]);
}
}
oamSetHiddenInput(formName,formName +':'+'_idcl',linkId);
if(document.forms[formName].onsubmit)
{
var result=document.forms[formName].onsubmit();
if((typeof result=='undefined')||result)
{
document.forms[formName].submit();
}
}
else
{
document.forms[formName].submit();
}
if(oldTarget==null) oldTarget='';
document.forms[formName].target=oldTarget;
if((typeof params!='undefined') && params != null)
{
for(var i=0; i<params.length; i++)
{
oamClearHiddenInput(formName,params[i][0], params[i][1]);
}
}
oamClearHiddenInput(formName,formName +':'+'_idcl',linkId);
return false;
}
//--></script><a href="#" onclick="return oamSubmitForm
('form1','form1:_idJsp0');" id="form1:_idJsp0">HOME</a> |
<a href="#" onclick="return oamSubmitForm('form1','form1:_idJsp1');"
id="form1:_idJsp1">CONTACT</a> | <a href="#" onclick="return
oamSubmitForm('form1','form1:_idJsp2');" id="form1:_idJsp2">
ABOUT</a></div>
<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="rO0ABXVyABNbTGphdmEubGFuZy5P
YmplY3Q7kM5YnxBzKWwCAAB4cAAAAANzcgBHb3JnLmFwYWNoZS5teWZhY2VzLm
FwcGxpY2F0aW9uLlRyZWVTdHJ1Y3R1cmVNYW5hZ2VyJFRyZWVTdHJ1Y3RDb21w
b25lbnRGWRfYnEr2z........
......." /></form>
<!-- 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 div tag
Post your Comment