Recent Notes

Displaying keyword search results 1 - 10
Created by James on October 16, 2013 09:14:24    Last update: October 16, 2013 09:14:24
The initial attempt was to compile the bunch of LESS files with: lessc less/* But then I got errors like: NameError: variable @line-height-computed is undef... The order of LESS files listed is important. Variables are defined in variables.less , so it should be listed first. For Bootstrap, the ordering is defined in bootstrap.less . So all you have to do is ( this is the right way ): lessc bootstrap.less bootstrap-compiled.css Just for the reference, this is the content of bpptstrap.css : /*! * Bootstrap v3.0.0 * * Copyright 2...
Created by Dr. Xi on May 24, 2012 20:36:53    Last update: May 24, 2012 20:36:53
I have two sites: site1 and site2 . I want to render some content from site2 on site1 . The content is different depending on whether the user is logged in site2 . For example, display Login button when user is not logged in, My Account link when user is logged in. I can inject content into the page on site1 by including a JavaScript generated from site2 : <script type="text/javascript" src="http://site2/c... This works because when the JavaScript is requested from site2 , the session cookie is sent along with the request, which is used by site2 to generate different content depending on the session status. However, for IE 9, this scheme breaks when site1 and site2 are in different security zones and IE protected...
Created by Fang on March 30, 2012 15:04:04    Last update: March 30, 2012 15:04:04
Spring MVC 3.1 can send either JSON or HTML response on the same URL, depending on the type of response requested. With this mechanism, a page can be sent when directly requested from a link, but a JSON response can be sent in response to an AJAX request. This is the controller code: package com.example; import java.util.Map; ... In the above example, JSON response will be sent when the HTTP request contains header "Accept: application/json". HTML response will be sent then the header is "Accept: */*", or "Accept: text/html", or anything else. You can add a limitation that the HTML response does not produce "application/json". But then the question is which response will be sent when the HTTP header is "Accept: */*"? Both methods will...
Created by James on February 02, 2012 15:40:32    Last update: February 02, 2012 15:40:32
It's pretty easy to embed Flash video in HTML with swfobject . This example comes directly from the docs: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric... where swfobject.js and expressInstall.swf comes with swfobjects. I provide these files: swf/MySwfFile.swf images/CoverArt.jpg video/MyFlashVideo.flv
Created by Dr. Xi on January 17, 2012 11:58:16    Last update: January 17, 2012 11:58:16
Steps to configure JavaMail resource for Tomcat 6 & 7: Install JavaMail jar: download the JavaMail API , unzip the archive and copy mail.jar to $CATALINA_HOME/lib . Add JavaMail resource to $CATALINA_BASE/conf/context.xml : <?xml version="1.0"?> <Context> . ... Add resource-ref for the JavaMail resource to your webapp WEB-INF/web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app... Use the JavaMail resource in your webapp: // import javax.naming.*; // import javax.mail....
Created by Fang on January 04, 2012 11:14:46    Last update: January 04, 2012 11:14:46
Assume that your messages are defined in MessageResources.properties , this is how you load and use the messages: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric... In MessageResources.properties : pageTitle = JSF Resource Bundle Example page.he...
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 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" ): &lt;table border='1' cellspacing='0' cellpadding='...
Created by James on November 27, 2011 16:02:11    Last update: November 27, 2011 16:02:11
This is an example that uses the XSLTProcessor jQuery plugin for client side XSLT. Unfortunately it didn't work in IE or Chrome. It worked in Firefox but somehow disable-output-escaping="yes" was ignored. <!DOCTYPE html> <html xmlns="http://www.w3.org/...
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:...
Previous  1 2 3 4 5 Next