Recent Notes
Displaying keyword search results 1 - 10
Created by Dr. Xi on February 13, 2012 20:59:35
Last update: February 13, 2012 20:59:54
The insertAttribute tag allows you to have a body as well as specify a default value, but both values are scriptless , i.e., scriptlet is not allowed in body:
<tiles:insertAttribute name="javascript">
<scri...
and defaultValue is output literally:
<tiles:insertAttribute name="javascript"
de...
And, <put-attribute> in tiles definition does not replace the body of <tiles:insertAttribute> , it appends to the body!
Created by Fang on February 10, 2012 16:17:13
Last update: February 10, 2012 16:17:13
The annotation @org.hibernate.annotations.Type overrides the default hibernate mapping type used for a column. This can usually be omitted since Hibernate normaly infers the correct type to use.
But @Type is required in ambiguous scenarios such as a java.util.Date attribute, which can map to SQL DATE , TIME or TIMESTAMP . You use the @Type("timestamp") annotation to tell Hibernate that a timestamp converter should be used, which identifies an instance of org.hibernate.type.TimestampType .
@Type can also be used to identify custom type converters, which can be defined with @TypeDef at the class level:
@TypeDefs(
{
@TypeDef(
na...
or with an xml file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mappi...
Created by James on February 02, 2012 16:00:15
Last update: February 02, 2012 16:00:15
Video for Everybody seems to be a generic way to embed video in a web page, even without flash. This code snippet comes from that site.
<!-- first try HTML5 playback: if serving as XML, ...
Created by zhidao on January 23, 2012 14:58:58
Last update: January 23, 2012 14:58:58
This exception occurs when the Java object attribute is of type String, while the database column is of type CHAR(n), and hibernate.hbm2ddl.auto is validate in persistence.xml .
There are two solutions:
Add columnDefinition to the @Column annotation:
@Column(name = “STATE_CODE”, columnDefinition = “c...
Remove hibernate.hbm2ddl.auto from persistence.xml .
Created by Fang on January 16, 2012 19:32:20
Last update: January 16, 2012 19:32:54
You can submit a form via Ajax by the jQuery Form Plugin . There are two main methods:
ajaxForm : prepares a form for Ajax submit.
Example:
$('#myFormId').ajaxForm({
target: ...
When the form is submitted, it is sent via Ajax.
ajaxSubmit : submit a form via Ajax.
Example:
$('#myForm2').submit(function() {
// i...
jQuery Form Plugin is not in the core jQuery API, so you have to include an additional JS file:
<head>
<script type="text/javascript" ...
Created by James on January 16, 2012 10:05:10
Last update: January 16, 2012 10:06:13
There are two ways to get the submit button:
Use the :submit selector (note the space between the form name and :submit ):
$('#the-form-id :submit')
Use attribute selector (also, space between form id and attribute selector):
$('#the-form-id [type="submit"] ')
// or
$(...
jQuery recommends the latter if you are concerned about performance:
Because :submit is a jQuery extension and not part of the CSS specification, queries using :submit cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use [type="submit"] instead.
Created by Fang on January 04, 2012 09:54:05
Last update: January 04, 2012 09:54:05
There are two ways to validate a form with JSF: jsf validation on the page with <f:validate...> tags (for example: <f:validateLength> , <f:validateRegex> , etc.), or JSR303 bean validation. This note is about how to customize messages for JSR303 bean validation. The validation message is specified in the message attribute for each validation annotation type. The mesage attribute is not a literal string, but a string that is interpolated in various ways. For example, the default validation message for AssertFalse is {javax.validation.constraints.AssertFalse.message} , which is replaced with the corresponding string in ValidationMessages.properties (or ValidationMessages_tr.properties , ValidationMessages_es.properties , depending on the locale). This is the contents of ValidationMessages.properties in the hibernate validator reference implementation:
javax.validation.constraints.AssertFalse.message =... To customize the messages, just provide the new value in...
Created by Fang on December 03, 2011 12:31:20
Last update: December 03, 2011 12:33:23
The <h:outputText> tag generates different output for body text and value attribute. I tested the following with Apache MyFaces 2.1.3:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric...
With value attribute, the output was:
<table border='1' cellspacing='0' cellpadding='4'>...
With text in body, the output was (i.e., the text was escaped despite escape="false" ):
<table border='1' cellspacing='0' cellpadding='...
Created by Fang on December 01, 2011 18:54:54
Last update: December 01, 2011 18:54:54
Use the varStatus attribute with the ui:repeat tag to get the iteration index:
<ui:repeat varStatus="status" var="item" value="#{...
The varStatus attribute specifies the name of the exported request scoped variable for the status of the iteration.The object is a POJO with the following read-only JavaBeans properties. This scoped variable has nested visibility.
begin of type Integer
end of type Integer
index of type int
step of type Integer
even of type boolean
odd of type boolean
first of type boolean
last of type boolean
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 ...