Recent Notes

Displaying keyword search results 1 - 7
Created by Fang on November 14, 2011 20:50:51    Last update: November 22, 2011 09:06:10
This facelet fragment will never print anything: <ui:repeat var="person" value="#{myBean.theJTeam}"... because the test condition always returns false, even though the person var is not null. The same happens even when I define another variable with ui:param : <ui:repeat var="person" value="#{myBean.theJTeam}"... What's happening? The c:if test condition is evaluated before the ui:repeat tag had a chance to set the value! Both facelet ui tags and JSTL c tags are evaluated at the Render Response phase of the JSF lifecycle. But within the Render Response cycle, there are two sub-phases (so to speak): the first builds the UI element tree, the second renders the UI tree. The JSTL c:if tag is evaluated when the tree is built, but the facelet ui:repeat tag is evaluated when the UI...
Created by Fang on November 08, 2011 20:55:00    Last update: November 21, 2011 18:19:44
In the simple taglib example , I used a tag handler class to implement a taglib. This is an example to implement a taglib with a UI component. The purpose is to use a custom tag to split a string and print each part in a separate paragraph, i.e., print <p>john</p> <p>steve</p> <p>mike</p> with custom tag <my:foreach> : <my:foreach var="who" value="john steve mike"> ... These are the files: pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0"... src/main/java/com/example/UIForeash.java : package com.example; import java.io.IOExcep... src/main/resources/META-INF/faces-config.xml : <?xml version="1.0" encoding="UTF-8"?> <faces-c... src/main/resources/META-INF/foreach.taglib.xml : <?xml version="1.0" encoding="UTF-8"?> <facelet... How to use: Put the JAR file generated by the above project in the WEB-INF/lib folder of the web app. If the web app is a Maven project, just add the taglib project as a dependency:...
Created by Dr. Xi on April 20, 2011 21:44:15    Last update: May 02, 2011 20:56:58
The String.format() method provides versatile formatting capabilities. This tutorial tries to present these capabilities in a accessible manner. The format string A format string can contain zero, one, or more format specifiers . The general form of a format specifier is: %[argument_index$] [flags] [width] [.precision]co... where things in square brackets are optional, and conversion is a character indicating the conversion to be applied to the corresponding variable value. The only required characters in the format specifier is the percent sign % and the conversion character. A simple example: public static void simpleFormat() { System.out... The Argument index The argument index is specified by a number, terminated by the dollar sign $ . The same argument may be repeated multiple times in a format string. Unindexed...
Created by Dr. Xi on November 18, 2010 22:13:36    Last update: November 18, 2010 22:13:36
You can use the eval function to substitute a value defined by a variable. Suppose you have a string literal $a = 'a $string' and you want Perl to substitute $string with the value of the $string variable. This is normally not a problem. Because if you use double quote, Perl does the interpretation automatically: $string = 'theactual'; $a = "a $string"; pri... But this doesn't work if the value of $string isn't available when you define the template $a . In this case, you have to use single quote to preserve the template definition. But you can use eval to do the replacement when the value of $string becomes available: #!/usr/bin/perl $a = 'a $string'; $string = ...
Created by Fang on April 03, 2010 20:21:15    Last update: April 04, 2010 03:30:22
The tags <c:out> The <c:out> tag evaluates an expression and outputs the result on the page. The syntax is: <c:out value="value" [escapeXml="{true|false}"] ... where escapeXml defaults to true and default defaults to empty string "". <c:out value="${expr}" escapeXml="false"/> is equivalent to ${expr} . If a variable is set in multiple scopes, the lower scope wins. In the following example code, attribute1 is set in request, session, and application scopes; attribute2 is set in session and application scopes; attribute3 is set in the application scope. The results are: <c:out value="${attribute1}"/> : Attribute1 request scope <c:out value="${attribute2}"/> : Attribute2 session scope <c:out value="${attribute3}"/> : Attribute3 application scope To access values in higher scopes, you have to specify the scope explicitly, like this: <c:out value="${sessionScope.attribute1}"/> : Attribute1 session...
Created by Dr. Xi on December 04, 2009 04:33:05    Last update: December 04, 2009 04:33:05
Variable Meaning $_ The default or implicit variable. @_ Within a subroutine the array @_ contains the parameters passed to that subroutine. $a, $b Special package variables when using sort() $<digit> Contains the subpattern from the corresponding set of capturing parentheses from the last pattern match, not counting patterns matched in nested blocks that have been exited already. $. Current line number for the last filehandle accessed. $/ The input record separator, newline by default. $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after...
Created by Dr. Xi on May 29, 2007 03:48:01    Last update: May 29, 2007 03:49:54
The following applies to Bourne, Korn and Bash: $var or ${var} Replaced by the value of var . Use braces to avoid ambiguity. ${var-value} Use the value of var if set, use value otherwise. ${var+value} Use the value of value if var is set, use nothing otherwise. ${var=value} Use the value of var if set, other wise, use value and assign value to var . ${var?value} Use the value of var ; otherwise, print value to standard error and exit the current shell. If value is omitted, a standard error message is printed instead.