Displaying keyword search results 1 - 6
Created by Fang on December 06, 2011 19:03:25 Last update: December 07, 2011 08:54:11
Our custom tag, as implemented in the previous note , is broken when a template is used. Create a template file ( home-template.xhtml ):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric...and a test page that uses it ( home.xhtml ):
<?xml version="1.0" encoding="UTF-8"?> <ui:comp...Then request the page with URL: http://localhost:8080/facelet-demo/home.jsf?name=Jack . You'll find that our hello tag works inside ui:repeat but fails to get the value defined by ui:param ! What's the problem? Our hello tag implementation evaluated the EL with the wrong EL context! This is the corrected implementation:
package com.example; import java.io.IOExcep...
Created by Fang on October 28, 2011 13:49:40 Last update: October 30, 2011 19:23:25
This is a simple example to demonstrate the templating power of JSF facelets. If you've used struts tiles before, you'll recognize the simplicity of templating with facelets. I've stripped out everything else except the pages themselves, just to put our focus on facelets. This is a Maven based project, and you need Tomcat (or any servlet container) to run the resulting webapp. To begin with this is the list of files:
./pom.xml ./src/main/webapp/home.xhtml ./src...I left faces-config.xml in there for completeness sake, it may not be needed. The Maven POM ( pom.xml ):
<?xml version="1.0" encoding="UTF-8"?> <project...Web app configuration ( WEB-INF/web.xml ):
<?xml version="1.0" encoding="UTF-8"?> <web-app...Empty WEB-INF/faces-config.xml :
<?xml version="1.0" encoding="UTF-8"?> <!-- Thi...index.jsp is simply a redirect to home.jsf :
<% response.sendRedirect("home.jsf"); %>...
Created by Dr. Xi on March 24, 2011 12:11:14 Last update: March 24, 2011 12:22:03
This is the task: your client wants to know how the web application is used. That is pretty easy. A plethora of commercial tools or any of the free log analysis tools such as analog and AWStats would fit the bill. But here's the catch: they want to know not only what pages are visited by how many people and when, but also who logged in and did what. Your application is using form based authentication and therefore, everyone is anonymous in the web access log. What to do? This is a servlet filter that generates a web access log with authenticated user info that can be fed to log analysis tools such as analog and AWStats . Filter code (the output format is Apache...
Created by Dr. Xi on March 02, 2011 11:39:18 Last update: March 09, 2011 12:19:30
Some peculiarities about Java PrintWriter: PrintWriter never throws any exceptions. From JavaDoc : Methods in this class never throw I/O exceptions, although some of its constructors may. The client may inquire as to whether any errors have occurred by invoking checkError(). When error occurs, you'll never know anything more than that it occured, because checkError returns boolean. When a character is out of the range of the character encoding of the PrintWriter, it prints a question mark (?). But this is not an error. Test code:
import java.io.*; public class TestPrintWri...Latin1 test result:
java TestPrintWriter iso-8859-1 | od -bc 000000...UTF-8 test result:
java TestPrintWriter utf-8 | od -bc 0000000 141...Also, the constructor throws a FileNotFoundException when you try to write to a...
Created by Fang on July 26, 2010 19:18:28 Last update: August 18, 2010 19:13:02
The tags <c:import> The <c:import> tag imports the contents of a URL and expose that in one of three ways: Import contents from a URL and write it out to the page (url may be relative or absolute):
<c:import url="theUrl" />Import contents from a URL and save it to a scoped variable string named by the var attribute. Use the scope attribute to define the scope of the exported variable.
<c:import url="theUrl" var="importTest" scope="ses...Import a URL and expose to a Reader object named by the varReader attribute. The scope attribute does not apply. The varReader scoped variable can only be accessed within the body of <c:import> .
<c:import url="theUrl" varReader="theReader"/><c:url> The <c:url> tag constructs a URL and writes it out to the...
Created by Fang on September 07, 2009 16:39:37 Last update: September 07, 2009 18:43:04
It's easiest to use the archetype plugin to start a new Maven project. I'll use struts 1 as example since it's not in the built-in archetypes for archetype:generate . Generate a simple webapp with archetype:generate :
C:\work\maven>mvn archetype:generate -DarchetypeAr...It generates a directory structure like this:
struts1app struts1app/pom.xml struts1app/src...with a simple POM:
<project xmlns="http://maven.apache.org/POM/4.0.0"...Create settings.xml in $HOME/.m2 , add Java.net repository for Java EE dependencies:
<?xml version="1.0" encoding="UTF-8"?> <setting...Add Java EE and Struts dependencies in pom.xml . Note that the Java EE dependency has scope provided , meaning that the web app container provides the jars, therefore we don't need to bundle them with our war fie.
<project xmlns="http://maven.apache.org/POM/4.0.0"...Create a directory named java under main , create the Struts form and...