TechnoBuzz

A Techno Blog, mainly about Java

View

View – renders the content of the model – access data from model and decide how to present it – forward user input to controller.

Tiles provides a framework for defining and dynamically populating page layouts.

The JSP file will define a template with placeholders where the content should go.

When the JSP file is invoked, it replaces the place holders with content creating a page
which is an instance of the layout.

Enabling the Tiles plugin:
Administrator\webApplication\WEB-INF\struts-config.xml:
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property value="/WEB-INF/tiles-defs.xml" property="definitions-config" />
     <set-property value="0" property="definitions-debug" />
     <set-property value="0" property="definitions-parser-details" />
     <set-property value="false" property="definitions-parser-validate" />
</plug-in>

Administrator\webApplication\WEB-INF\web.xml:
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>

A Tiles definition specifies the layout for a piece of content.

Tiles can insert into a JSP using the definition name which consists of:

  • name or identifier
  • set of attributes associated with the definition
  • a layout JSP name (instance file name of the given definition and attributes)

Using the Tiles Tag libray in JSP file:

<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

<tiles:insert> –  Inserts a tiles definition or attribute into a JSP page.
   Note: the attribute ‘template’ is deprecated (1.2)
         It is replaced by the attribute ‘page’ .
                 <tiles:insert template="/templates/Header.jsp" >

<tiles:put>    –  Defines an attribute (or parameter) for a definition.
   Note: the attribute ‘name’ specifies the name of the attribute
          <tiles:put name="page_title" direct="true">
          <bean:message key="head.title.prefix"/>
          <bean:message key="title.profile.create1"/>
            </tiles:put>

Using the Bean Tag libray in JSP file:

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<bean:define>    –  Defines a variable to be associated with a bean property
 
          <bean:define  id="codeText" name="securityListForm"
                              type="java.lang.String" property="code"
                              scope="request"></bean:define>
<bean:message>    –  Display a text replacement string associated with an identifier (prop file)
 
          <bean:message key="head.title.prefix"/>
                            
<bean:write>    –  Display a bean properties value (name can be bean name or bean variable defined for jsp)

           <bean:write name="CodeListForm" property="code" />

Using the logic Tag libray in JSP file:

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<logic:iterate>    –  Iterate over a list

<logic:iterate id="codes"              indexId="index"
                  name="securityListForm" property="list"
                  scope="request"
                  type="org.CodeBean"
   >

</logic:iterate:>

 

<logic:greaterThan>    –  execute logic if condition met

                 <bean:size id="listSize" name="listForm" property="list"/>
                 <logic:greaterThan name="listSize" value="0">
                 </logic:greaterThan>

 

<logic:equal>    –  execute logic if condition met

              <logic:equal name="securityListForm" property="tabNumber" value="20">
                 </logic:equal>

Using the HTML Tag libray in JSP file:

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:form>    –  form definition

<html:text >

<html:submit>

<html:select>

<html:option>

<html:multibox>

<html:cancel>

<html:options>

Not Empty Tag

Advertisements

May 18, 2005 - Posted by | Struts

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: