Documentation
Home
Quick overview (new)
Tutorial
Download
Installation
Javadoc

Tag Library Reference
Components Tags
Extension Tags

Printer Versions
Quick Overview (new)
Tutorial
Overview (old)

Old Documents
Overview (old)

In the right column you can find some basic examples, while in the left column you find the corresponding output result.
Output Result Sources

Basic template usage
Test with default no types
This is the header
This is a body

Specify attribute types
Test with specified types
This is the header
This is a body

Set attribute value with tag body
Test with a tag body
This header is inserted as body of tag
This is a body

Use of definition
Use of definition
This is the header
This is a body

Use of definition, overload of parameters Title parameter from previous definition is overloaded
Use of definition, overload of parameters
This is the header
This is a body

Test ignore : body isn't defined (We use another layout)
Test ignore : body isn't defined
This is the header
file '/test/testBasic.jsp'
<%@ taglib uri="/WEB-INF/components.tld" prefix="template" %>

<%-- Test tags basic behaviors 
--%>
<hr>
<strong>Basic template usage</strong>
<br>
<template:insert template="layout.jsp">
  <template:put name="title"  value="Test with default no types" />
  <template:put name="header" value="header.jsp" />
  <template:put name="body"   value="body.jsp" />
</template:insert>

<hr>
<strong>Specify attribute types</strong>
<br>
<template:insert template="layout.jsp">
  <template:put name="title"  value="Test with specified types"   type="string" />
  <template:put name="header" value="header.jsp" type="page"   />
  <template:put name="body"   value="body.jsp"   type="page"   />
</template:insert>

<hr>
<strong>Set attribute value with tag body</strong>
<br>
<template:insert template="layout.jsp">
  <template:put name="title"  value="Test with a tag body" />
  <template:put name="header" type="string">
    <strong>This header is inserted as body of tag</strong>
  </template:put>
  <template:put name="body"   value="body.jsp"/>
</template:insert>

<hr>
<strong>Use of definition</strong>
<br>
<template:definition id="templateDefinition" template="layout.jsp">
  <template:put name="title"  value="Use of definition" />
  <template:put name="header" value="header.jsp" />
  <template:put name="body"   value="body.jsp"   />
</template:definition>
<template:insert beanName="templateDefinition" />

<hr>
<strong>Use of definition, overload of parameters </strong>Title parameter
from previous definition is overloaded
<br>
<template:insert beanName="templateDefinition" >
  <template:put name="title"  value="Use of definition, overload of parameters"   type="string" />
</template:insert>

<hr>
<strong>Test ignore : body isn't defined </strong>(We use another layout)
<br>
<template:insert template="layoutTestIgnore.jsp">
  <template:put name="title"  value="Test ignore : body isn't defined" />
  <template:put name="header" value="header.jsp" />
</template:insert>

 

Example of list usage
home
documentation
file '/test/testList.jsp'
<%@ taglib uri="/WEB-INF/components.tld" prefix="comp" %>

<strong>Example of list usage</strong>
<%-- Insert a menu component.
  Menu component require two lists : one of items, and one of links.
--%>
<comp:insert component="menu.jsp" >
  <comp:put name="title" value="Test menu" />
  <comp:putList name="items">
    <comp:add value="home" />
    <comp:add>
	  <img src="<%=request.getContextPath()%>/images/struts-power.gif"
	       align="right" border="0"></comp:add>
    <comp:add value="documentation"/>
  </comp:putList>
  <comp:putList name="links">
    <comp:add value="/index.jsp"/>
    <comp:add value="/../struts-documentation"/>
    <comp:add value="/../comps-doc" type="string" />
  </comp:putList>
</comp:insert>


Insert definition defined directly in jsp page
Test definition defined in jsp page
This is the header
This is a body

Insert definition defined in factory
Test definition from factory : basic
This is the header
This is a body

Insert definition defined in factory
Test definition from factory : specify types
This is the header
This is a body

Insert definition defined in factory
Test definition from factory : Test with a tag body (to do)
This is a header
This is a body

Insert definition defined in factory : Overload title attribute
Test definition : overload attribute 'title'
This is a header
This is a body
file '/test/testDefinitions.jsp'
<%@ taglib uri="/WEB-INF/components.tld" prefix="template" %>

<%-- Test template definitions (from factory) 
--%>
<hr>
<strong>Insert definition defined directly in jsp page</strong>
<template:definition id="definition" template="/test/layout.jsp" >
  <template:put name="title"  value="Test definition defined in jsp page" />
  <template:put name="header" value="header.jsp" />
  <template:put name="body"   value="body.jsp" />
</template:definition>

<br>
<template:insert beanName="definition"/>

<hr>
<strong>Insert definition defined in factory</strong>
<br>
<template:insert definition="test.layout.test1"/>

<hr>
<strong>Insert definition defined in factory</strong>
<br>
<template:insert definition="test.layout.test2"/>

<hr>
<strong>Insert definition defined in factory</strong>
<br>
<template:insert definition="test.layout.test3"/>

<hr>
<strong>Insert definition defined in factory : Overload title attribute</strong>
<br>
<template:insert definition="test.layout.test3">
  <template:put name="title" value="Test definition : overload attribute 'title'" />
</template:insert>



Copyright © 2000, Apache Software Foundation
and S1 Corporation