Tomahawk div tag

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.

Tomahawk div tag

Tomahawk div tag

        

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 :

  • id : This is the value which is used to uniquely identify the component within the closest container like form or subview. The main thing to remember is that its value must be a static value.
  • binding : This attribute is used to specify the property of the backing bean with which this component instance is to be bound.
  • rendered : Its default value is true. If  this attribute is set to true then this component is presented in the page to the user. If false, then this component is not rendered.
  • forceId : This is a boolean attribute with default value false. If this attribute is set to true, the tag is forced to render the id for the component exactly as mentioned in the id attribute of the tag. The benefit of this attribute is that we can reference component by id in the javascript. If we don't use this attribute with the true value then the id for the component is presented in different format.
  • forceIdIndex : This is a boolean attribute with default value true. If this value is true then the the component displays the index number in its id value if the component is in a list. If this attribute is set to false then this component will not append index number as suffix . If forcrId is set to false then its value is ignored.
  • enabledOnUserRole : If the current user has one of the roles listed in the enabledOnUserRole attribute then enabling or disabling of the component is decided on the base of "disabled" attribute. If disabled attribute is set to true then component is disabled otherwise enabled. If the user is not in the above list then the component is rendered disabled.
  • visibleOnUserRole : If the current user has one of the roles listed in the visibleOnUserRole attribute then processing of the component is decided on the base of "rendered" attribute. If the rendered attribute is set to true then component is not rendered otherwise displayed  on the page. On the other hand if the current user is not in the above list then the component is not processed.
  • style : This attribute is used to set the style definition for the component.
  • StyleClass : This attribute is used to set the CSS class to be applied to the component.