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

分类:Web 时间:2010-04-01 人气:382
分享到:
blog comments powered by Disqus

相关文章

  • The absolute uri: http://java.sun.com/jstl/core_rt cannot be resolved in error 2010-05-30

    Quote About The absolute uri: http://java.sun.com/jstl/core_rt cannot be resolved in either web.xml or the jar files deployed with this application to solve! HTTP Status 500 - --------------------------------------------------------------------------

  • tomcat6 可以 正常访问 tomcat67可以 访问有问题http://java.sun... 2013-09-17

    org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler

  • <% @ Taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%> does not recognize the error: to htt 2008-08-28

    <% @ Taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%> does not recognize the error: To https: / / jstl.dev.java.net / download.html to download jstl of the two on the jar package. Import project can be

  • About org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/j 2009-05-24

    This problem usually occurs because the jar (jstl.jar, and standard.jar) caused problems: The first is: Eclipse project is to import JSTL.jar and standard.jar Second: Modify the web.xml, add the following statement: <jsp-config> <taglib> <t

  • In the JSP in This absolute uri http://java.sun.com/jsp/jstl/core cannot be resolved - the solution 2010-08-28

    About JSP in org.apache.jasper.JasperException: This absolute uri http://java.sun.com/jsp/jstl/core) cannot be resolved in either web.xml or the jar files deployed with this application According "master JSP - Web application development technology a

  • Problems in jboss6: BossXBRuntimeException: {http://java.sun.c/j2ee} name not found as 2010-11-10

    Recently deployed with the old jboss6 application, problems encountered and resolved it, and now it records, to facilitate future search. First, the deployment of jsp2.0 jboss6 application problems: org.jboss.xb.binding.JBossXBRuntimeException: {http

  • java通过共享变量结束run停止线程的方法示例 2015-02-21

    这篇文章主要介绍了java通过共享变量结束run停止线程的方法,大家参考使用 stop()方法已经被弃用,原因是不太安全.API文档中给出了具体的详细解释. 通过interrupted()方法打断线程.不推荐. 通过共享变量结束run()方法,进而停止线程.如实例 public class ThreadInterrupt { public static void main(String []args){ Runner run = new Runner(); run.start(); try {

  • java dynamic compilation and run (reproduced) 2010-03-22

    Compiled by JavaCompiler are generated in the current directory. Class files using compiler option to change the default directory. Compiler option is an element of the String type of Iterable collections. If we can use the following code in D under

  • java RMI example (can run) 2010-03-29

    0 Recommended RMI, Remote Method Invocation (Remote Method Invocation) is the Enterprise The pillars of JavaBeans is to build a distributed Java application, a convenient way. RMI is very easy to use, but it is very powerful. RMI is based on interfac

  • java thread start()和run()方法简析 2014-06-26

    本文以java中thread的start()和run()的区别做详细介绍, 需要了解跟多的朋友可以参考下 1.start()方法来启动线程,真正实现了多线程运行,这时无需等待run方法体代码执行完毕而直接继续执行下面的代码: 通过调用Thread类的start()方法来启动一个线程, 这时此线程是处于就绪状态, 并没有运行. 然后通过此Thread类调用方法run()来完成其运行操作的, 这里方法run()称为线程体, 它包含了要执行的这个线程的内容, Run方法运行结束, 此线程终止, 而CP

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.453 (s). 12 q(s)