Recent Notes

Displaying keyword search results 1 - 6
Created by Fang on January 28, 2012 13:24:09    Last update: January 28, 2012 13:31:22
This is a simple JSP custom tags library with tag body. Just like the JSF counterpart , it splits a string and repeats the body for each word, i.e., with this markup: <%@ taglib uri="" prefix... output: <html> <body> <p>Hello Tigger!</p> <p>H... With Maven, this is the directory structure: ./src ./src/main ./src/main/resources ./s... There are three files to write: pom.xml : <project xmlns=""... src/main/java/tagdemo/ : package tagdemo; import src/main/resources/META-INF/demotag.tld : <?xml version="1.0" encoding="UTF-8"?> <!DO... Build with: mvn clean install To use it as a dependency in other Maven projects: <dependency> <groupId>tag-demo</groupId> ...
Created by Fang on November 28, 2011 21:04:15    Last update: November 28, 2011 21:04:15
Some innocent looking JavaScript may cause a fatal error in a Facelet page. For example: <script type="text/javascript"> if (items.lengt... or <script type="text/javascript"> // jQuery code ... Because Facelet is strict XML, therefore, < and > must be escaped. There are several ways to deal with this: Do not embed JS code directly in the page. Put the code in .js files and include it in the page with the src attribute. Put JS code in a CDATA section: <h:outputScript target="head"> <![CDATA... Use XML entities: <script type="text/javascript"> // jQuery code ...
Created by freyo on April 15, 2011 09:00:54    Last update: April 15, 2011 09:00:54
Sample code for writing to a file in the internal storage. There are three steps: Open the file with Context.openFileOutput , which returns . Write to the file. Close the file. import*; import android.content.Contex... The second parameter to openFileOutput is the operating mode. Available values are: Context.MODE_PRIVATE Context.MODE_APPEND Context.MODE_WORLD_READABLE Context.MODE_WORLD_WRITEABLE The file is saved in /data/data/<package_name>/files .
Created by Dr. Xi on August 27, 2010 22:35:53    Last update: August 27, 2010 22:35:53
This example decompresses a gzip compressed file with . The input is assumed to be Base64 encoded after being gzipped (such would be the case when binary data is transmitted within an XML file). You don't need the Base64InputStream if the data is not Base64 encoded. import*; import
Created by Fang on August 23, 2010 22:55:58    Last update: August 24, 2010 15:45:04
The tags XML flow control tags are exactly the same as their Core flow control equivalents, except that the test condition with a boolean EL expression is replaced by the select condition with an XPath expression. In the case of the forEach tag, the items attribute is replaced with the select attribute. In a test condition, the XPath expression is evaluated to a boolean value by the rules of the XPath boolean() function, which converts its argument to a boolean as follows: a number is true if and only if it is neither positive or negative zero nor NaN. a node-set is true if and only if it is non-empty. a string is true if and only if its length is non-zero. an object of...
Created by Dr. Xi on December 12, 2007 20:30:01    Last update: December 12, 2007 20:32:23
This is a script to tail a log file through the web browser. It uses AJAX, apache web server, mod_python, UNIX utilities tail (requires the --lines switch) and wc . The log file may reside on the web server or any other host accessible from the web server through SSH. Although it's written in python, it should be easy to port to other languages such as Perl. Apache httpd.conf : LoadModule python_module modules/ ... Python script: import time, os from os.path import basename ...