tiles mechanisms - is reproduced

Interface layout has been exploring a number of techniques found in TILES framework these days, looked at it and wrote a DEMO, integration with the JSF framework TILES. Out to share, please pointing 12.

Tiles framework provides a template mechanism, it will be the layout and content separation of duties. Allows you to first create the template, and then dynamically at run-time content into the layout. If you want under the internationalization, user preferences to customize your site, or simply to change the visual sense (which will happen sooner or later each site), you will find that the template is a powerful mechanism. Tiles framework has the following characteristics:

1 dynamically build and load the page

2 Screen Definition

3 support the tile and layout reuse

4 support the international

5 multi-channel

6 template capacity

Today, just wrote a basic function, implements a layout. Page header, page body, footer. Follow-up will continue to publish.

A write page header, page body, footer, three JSP files

1 `header.jsp

<% @ Page language = "java" contentType = "text / html; charset = gb2312"
pageEncoding = "gb2312"%>
<% @ Taglib uri = "http://java.sun.com/jsf/html" prefix = "h"%>
<% @ Taglib uri = "http://java.sun.com/jsf/core" prefix = "f"%>

<! DOCTYPE html PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title> Insert title here </ title>
</ Head>
<body>
<h:outputText value=" This is the page header section "> </ h: outputText>
</ Body>
</ Html>

2 body.jsp

<% @ Page language = "java" contentType = "text / html; charset = gb2312"
pageEncoding = "gb2312"%>
<% @ Taglib uri = "http://java.sun.com/jsf/html" prefix = "h"%>
<% @ Taglib uri = "http://java.sun.com/jsf/core" prefix = "f"%>

<! DOCTYPE html PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title> Insert title here </ title>
</ Head>
<body>
<h:outputText value=" This is the content section "> </ h: outputText>
</ Body>
</ Html>

3 `footer.jsp

<% @ Page language = "java" contentType = "text / html; charset = gb2312"
pageEncoding = "gb2312"%>
<% @ Taglib uri = "http://java.sun.com/jsf/html" prefix = "h"%>
<% @ Taglib uri = "http://java.sun.com/jsf/core" prefix = "f"%>

<! DOCTYPE html PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title> Insert title here </ title>
</ Head>
<body>
<h:outputText value=" This is part of the bottom of the tank "> </ h: outputText>
</ Body>
</ Html>

Second, the preparation of tiles profile tiles.xml;

<! DOCTYPE tiles-definitions PUBLIC
"- / / Apache Software Foundation / / DTD Tiles Configuration / / EN"
"Http://jakarta.apache.org/struts/dtds/tiles-config.dtd">
<tiles-definitions>
<definition name="hbflayout" path="/jsp/tiles/hbflayout.jsp">
<put name="header" value="/jsp/tiles/header.jsp" />
<put name="body" value="/jsp/tiles/body.jsp" />
<put name="footer" value="/jsp/tiles/footer.jsp"/>
</ Definition>
</ Tiles-definitions>

3 files in WEB.XML to increase TILES description:

<? Xml version = "1.0" encoding = "UTF-8"?>
<Web-app xmlns = "http://java.sun.com/xml/ns/javaee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" version = "2.5" xsi : schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name> javax.faces.CONFIG_FILES </ param-name>
<param-value> / WEB-INF/faces-config.xml </ param-value>
</ Context-param>
<filter>
<filter-name> encodingFilter </ filter-name>
<filter-class> filter.EncodingFilter </ filter-class>
<init-param>
<param-name> encoding </ param-name>
<param-value> GBK </ param-value>
</ Init-param>
<init-param>
<param-name> encodingShow </ param-name>
<param-value> true </ param-value>
</ Init-param>
</ Filter>
<filter-mapping>
<filter-name> encodingFilter </ filter-name>
<url-pattern> / * </ url-pattern>
</ Filter-mapping>
<servlet>
<servlet-name> Faces Servlet </ servlet-name>
<servlet-class> javax.faces.webapp.FacesServlet </ servlet-class>
<load-on-startup> 0 </ load-on-startup>
</ Servlet>
<servlet>
<servlet-name> TilesServet </ servlet-name>
<servlet-class> org.apache.struts.tiles.TilesServlet </ servlet-class>
<init-param>
<param-name> definitions-config </ param-name>
<param-value> / WEB-INF/tiles.xml </ param-value>
</ Init-param>
<init-param>
<param-name> definitions-parser-validate </ param-name>
<param-value> true </ param-value>
</ Init-param>
<load-on-startup> 2 </ load-on-startup>
</ Servlet>
<servlet-mapping>
<servlet-name> Faces Servlet </ servlet-name>
<url-pattern> *. faces </ url-pattern>
</ Servlet-mapping>
<welcome-file-list>
<welcome-file> index.jsp </ welcome-file>
</ Welcome-file-list>
</ Web-app>

The preparation of the layout template file hbflayout.jsp 4

<% @ Page language = "java" contentType = "text / html; charset = gb2312"
pageEncoding = "gb2312"%>
<% @ Taglib uri = "http://java.sun.com/jsf/html" prefix = "h"%>
<% @ Taglib uri = "http://java.sun.com/jsf/core" prefix = "f"%>
<% @ Taglib uri = "/ WEB-INF/tld/struts-tiles.tld" prefix = "t"%>
<! DOCTYPE html PUBLIC "- / / W3C / / DTD HTML 4.01 Transitional / / EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title> Insert title here </ title>
</ Head>
<body> <br>

<f:view>
<table width="778" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<f:subview>
<t:insert attribute="header" flush="false"> </ t: insert>
</ F: subview>
</ Td>
</ Tr>
<tr>
<td>
<f:subview>
<t:insert attribute="body" flush="false"> </ t: insert>
</ F: subview>
</ Td>
</ Tr>
<tr>
<td>
<f:subview>
<t:insert attribute="footer" flush="false"> </ t: insert>
</ F: subview>
</ Td>
</ Tr>
</ Table>
</ F: view>
</ Body>
</ Html>

Five-page document written application templates tilespage.jsp

<% @ Page language = "java" contentType = "text / html; charset = gb2312"
pageEncoding = "gb2312"%>
<% @ Taglib uri = "/ WEB-INF/tld/struts-tiles.tld" prefix = "t"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title> Insert title here </ title>
</ Head>
<body> <br>
<t:insert definition="hbflayout" flush="true">
<t:put name="header" value="/jsp/tiles/header.jsp"> </ t: put>
<t:put name="body" value="/jsp/tiles/body.jsp"> </ t: put>
<t:put name="footer" value="/jsp/tiles/footer.jsp"> </ t: put>
</ T: insert>
</ Body>
</ Html>

Six-speed open your browser, http://192.168.2.52:8080/JSFTest/jsp/tiles/tilespage.faces, of course, write all their own access path.

It's that simple, for the first time one hour can handle that, and soon you like.

This article comes from CSDN blog, reproduced, please indicate the source: http://blog.csdn.net/sunhuiliang85/archive/2008/11/16/3313419.aspx
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of tiles mechanisms - is reproduced

  • Process migration from tomcat to websphere changes

    Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm's

  • JAVA EE JSP_JNDI

    dsfdsa http://lindows.javaeye.com/admin/blogs/213348 Tomcat 6 with the connection pool data source configuration http://www.blogjava.net/ec2008/archive/2008/07/19/216063.html project: test Driver path: D: \ workspace \ test \ WebRoot \ WEB-INF \ lib ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • The EJB3 Persistence

    EJB3 persistence with Hibernate is very similar to the mechanism: Environment: Server: JBOSS5.0 Database: MySQL5.0 1. Set up a data source First of all, in jboss-5.0.0.GA \ server \ default \ deploy, the establishment of a database used to connect the dat

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries