Recent Notes

Displaying keyword search results 1 - 10
Created by Fang on April 16, 2012 13:32:10    Last update: April 16, 2012 13:32:10
There are two steps to create a custom function for JSP: Declare the function in the TLD: <?xml version="1.0" encoding="UTF-8" ?> <taglib... Implement the function (must be static): package com.example; public class UrlTransl... To use the function: <%@ taglib uri="http://www.example.com/jsp/tags" p...
Created by Fang on December 05, 2011 08:41:31    Last update: December 05, 2011 08:41:31
Behavior for functions substringBefore and substringAfter are well defined when the string to look for exists. But what happens when the substring is not found? Do they return the whole string or empty string? Code: <p>substringBefore('a.b', '.'): #{fn:substringBefo... Result: substringBefore('a.b', '.'): a substringBef...
Created by Fang on November 12, 2011 21:03:03    Last update: November 12, 2011 21:03:03
Experts may disagree but I found it absolutely stunning that JSF EL does not provide an operator for string concatenation. The Java "+" operator is there for the take. Java, which is a strongly typed compiled language, overloads the "+" operator in such a way that any object can be concatenated with a string. But JSF EL, which definitely isn't as strongly typed as Java, restricts the "+" operator to numerical values only! Of course, experts may argue that the "+" operator overloading is a huge design flaw of the Java language. But even so, JSF EL is not the right place to fix it! In some cases, a concatenation operator isn't needed, for example: <ui:repeat var="tab" value="#{tabs}"> <img ... But in case the concatenated...
Created by Fang on November 02, 2011 16:40:10    Last update: November 02, 2011 16:40:10
Facelet taglib schema from JavaServer Faces Spec 2.0: <xsd:schema targetNamespace="http://java.sun.com/x...
Created by magnum on September 11, 2011 19:46:09    Last update: September 11, 2011 19:46:09
A pair of C functions convert between an Internet address and a string (ASCII): #include <arpa/inet.h> /* * Returns a poin... However , these functions do not support IPv6. The new pair is: #include <arpa/inet.h> /* Convert a Internet ad... Examples: #include <sys/socket.h> #include <netinet/in.h>...
Created by Dr. Xi on October 01, 2007 03:26:46    Last update: August 25, 2011 08:57:40
Use the sub function in the re module to do global replacement: import re re.sub(pattern, replacement, inpu...
Created by Dr. Xi on July 14, 2011 11:47:48    Last update: July 14, 2011 11:47:48
The String.trim function trims spaces from both ends. There's no built-in function to trim only the right side or left side. To right trim: String trimmed = original.replaceAll("\\s+$", ""); To left trim: String trimmed = original.replaceAll("^\\s+", "");
Created by jinx on May 18, 2011 20:09:05    Last update: May 18, 2011 20:09:05
The PHP function file_get_contents reads the entire contents of a file into a string, while the function file reads a file into an array. file_get_contents('filename') is equivalent to implode('', file('filename')) : <?php // reads entire file into array, one elem...
Created by jinx on May 03, 2011 11:43:26    Last update: May 03, 2011 11:43:26
The PHP function strval returns the string value of a variable. It does the same thing as casting a variable to string, or automatic conversion where string is expected. Conversion rules: Type String Value Boolean TRUE '1' Boolean FALSE '' (empty string) integer of float string representing the number Array The string 'Array' Object Result of __toString() if defined, error otherwise Resource 'Resource id #n' , where n is a number assigned to the resource. NULL '' (empty string) Example: <?php set_error_handler(function($errno, $errst... Results: bool(true) --------------------- strval: '1'...
Created by jinx on May 02, 2011 12:14:23    Last update: May 02, 2011 12:15:07
The PHP function ctype_digit returns true when all characters in a string is numeric. Use this function only on strings. You get unexpected results with other data types. Example: <?php $a = array("124.34", "00088760", "1.3e5",... Results: string(6) "124.34" ----------------- ctype_d...
Previous  1 2 3 4 5 6 7 Next