Here is an example application development video.
Tuesday, February 09, 2010
NetBeans 6.8 JSR-296 Database Application Example
Labels:
Apache Derby
,
example
,
frameworks
,
JSR-295
,
JSR-296
,
Netbeans
,
Swing
,
tutorial
Friday, January 22, 2010
JSF PhaseListener Example
I have been reading a book called JSF 1.2 Components from Packt Publishing to do a review. While reading the book, I thought about the numerous code examples that I have written over the years. I decided to publish this example based on JSF 1.2 and Facelets 1.1.14 using NetBeans 6.7.1.
This example demonstrates the use of a
Note: The component renderer for debugging components has a Javascript error which was introduced in Facelets 1.1.12 through 1.1.14 which will not render the Component tree. You must use either Facelets 1.1.11 or 1.1.15.B1 to have the component tree render.
Here is the sample code on Bitbucket: JSFPhaseListeners
This example demonstrates the use of a
PhaseListener which is set in the web.xml file. It also includes a component tree renderer which is also a PhaseListener. Facelets includes a component renderer for debugging purposes. You must include the <ui:debug/> tag in your xhtml file to use it.Note: The component renderer for debugging components has a Javascript error which was introduced in Facelets 1.1.12 through 1.1.14 which will not render the Component tree. You must use either Facelets 1.1.11 or 1.1.15.B1 to have the component tree render.
Here is the sample code on Bitbucket: JSFPhaseListeners
Monday, January 18, 2010
Apache Commons Configuration Example
The other night at the Greenville Java Users Group meeting I asked the members of the JUG to join an open source project and make a difference. I told them that you do not need to necessarily contribute code, but providing documentation assistance would make a difference.
In the same meeting I asked how many people could tell me about any of the Apache Commons projects. I was surprised at how many people could only list a couple. No one had heard of the Apache Commons Configuration project. I use the project to load properties into some of my projects. I was surprised that so many people "roll their own" around properties files.
I decided to make an Apache Maven project which demonstrates the power and simplicity of the framework.
Here is the sample code: apache-commons-configuration-example.zip
In the same meeting I asked how many people could tell me about any of the Apache Commons projects. I was surprised at how many people could only list a couple. No one had heard of the Apache Commons Configuration project. I use the project to load properties into some of my projects. I was surprised that so many people "roll their own" around properties files.
I decided to make an Apache Maven project which demonstrates the power and simplicity of the framework.
Here is the sample code: apache-commons-configuration-example.zip
/* * Copyright 2010 Blue Lotus Software, LLC. * Copyright 2010 John Yeary <jyeary@bluelotussoftware.com>. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * under the License. */ /* * $Id: Application.java 168 2010-01-19 03:09:36Z jyeary $ */ package com.bluelotussoftware.example.apache.commons; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; /** * <p>Example application to demonstrate the Apache Commons * Configuration framework.</p> * @author John Yeary <jyeary@bluelotussoftware.com> * @version 1.0-SNAPSHOT */ public class Application { private static final String PROPERTIES_FILE_NAME = "configuration.properties"; /** * <p>Default no-arg constructor.</p> */ public Application() { } /** * <p>Main application entry point.</p> * @param args * @throws ConfigurationException */ public static void main(String[] args) throws ConfigurationException { Application application = new Application(); application.createProperties(); application.setBackground("#c53478"); String background = application.getBackground(); System.out.println("background-color:" + background); } /** * <p>Creates a property file on the local system disk.</p> * @throws ConfigurationException if an <code>Exception</code> is encountered. */ public void createProperties() throws ConfigurationException { // Create a new property and save it. PropertiesConfiguration config = new PropertiesConfiguration(); config.save(PROPERTIES_FILE_NAME); } /** * <p>Sets a property called <code>colors.background</code> to the value provided, or assigns a color * value{@literal #000000} if none is provided .</p> * @param backgroundColor * @throws ConfigurationException if an <code>Exception</code> is encountered. */ public void setBackground(String backgroundColor) throws ConfigurationException { PropertiesConfiguration config = new PropertiesConfiguration(); config.load(PROPERTIES_FILE_NAME); if (backgroundColor == null) { config.setProperty("colors.background", "#000000"); } else { config.setProperty("colors.background", backgroundColor); } config.save(PROPERTIES_FILE_NAME); } /** * <p>Retrieves the background property from the properties file on * the system disk.</p> * @return the background color assigned in the properties file. * @throws ConfigurationException if an <code>Exception</code> is encountered. */ public String getBackground() throws ConfigurationException { PropertiesConfiguration config = new PropertiesConfiguration(); config.load(PROPERTIES_FILE_NAME); String background = (String) config.getProperty("colors.background"); return background; } }
Labels:
Apache
,
frameworks
,
Java
,
maven
,
tutorial
Subscribe to:
Posts
(
Atom
)
Popular Posts
-
Introduction This article is not another diatribe to tell you the importance of unit testing. I think we can all agree that it is important...
-
A friend of mine asked me if there was a list of reserved words in EL and JSF. He had previously looked for it, and after some Google search...
-
I saw a question posed on stackoverflow called Trouble with Primefaces 3.0.M2 SelectOneMenu Ajax behavior and I had just done an example a...
-
I was working on a couple of SSL based issues when I made a couple of observations. The default self-signed key generation in Java does not ...
-
This is an example on how to make a system call to the local operating system to execute external programs. This example was written to work...
-
We have been doing a lot of work lately with PrimeFaces. A common set of questions comes up about displaying <p:dialog/> boxes on a pa...
-
I was asked earlier today how to reset fields in a JSF application, if the validation fails. In his case, he had a Richfaces table which had...
-
Previously, I posted an example of how to use JSF 1.2 with form based authentication (j_security_check). In this example, I use JSF 2.x to...
-
Image by quasarkitten via Flickr The basics for creating a Maven archetype can be found in the Maven - Guide to Creating Archetypes . The ...
-
Abstract A common use case is to iterate over a collection of elements, and display them on a page. In the world of JSP, we would use a Ja...