Total Pageviews

2010/12/01

The value of attribute "itemLabel" associated with an element type "null" must not contain the '<' character.

Environment: JSF 2.0 on GlassFish V3

[Error Message]
The value of attribute "itemLabel" associated with an element type "null" must not contain the '<' character.

Source Code 

Root Cause
The problem results from the itemValue cannot accept < in xhtml page

Solution
Move selectItems value and label to managed bean
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    //declare a List variable    
   public List compareList = new ArrayList();
 
    //declare a getter class
    public List getCompareList() {         
  compareList.clear();
  compareList.add(new SelectItem(">", ">"));
  compareList.add(new SelectItem("<", "<="));
  return compareList;     
 }

xhtml page should be updated to be like this:

Demo:

2010/11/02

PrimeFaces 2.X + JSF 2.0 Quick Start

Prerequisite
This example will apply facelets template. Therefore, concerning faceletes template topics, please refer to :

PrimeFaces 2.X + JSF 2.0 Quick Start

1. Create two classes: PersonBean.java and PersonControl.java


2. Create Person.java
Utilized annotation to declare managed bean and its scope instead of faces-config.xml

3. Create PersonControl.java
Utilized annotation to declare managed bean, ManagedProperty and its scope instead of faces-config.xml

4. Create index.xhtml
You will see this page only have one text filed for user to fill.

Two buttons in this page:
  • Submit button: click submit button as user fill in name
  • Clear button: click clear button to clear text field

5. Create hello.xhtml
Show welcome message in this page. And click home button to head for previous page.


6. Define navigation rule in faces-config.xml

7. Demo

User fill in name and click submit button

show welcome message in next page.



JSF2 + Facelets + PrimeFaces 2.2


1. Download PrimeFaces jar files from http://www.primefaces.org/downloads.html
2. Utilize JSF 2.0 and copy PrimeFaces-2.2.jar to WEB-INF/lib

3. you don't need to register servlet and servlet mapping in web.xml from JSF 2.0

4. You don't need to declare p:resources tag in head area

5. Create a simple page with 5 PrimeFaces command buttons in panel

6. Demo


Compare PrimeFaces 1.x with PrimeFaces 2.x

2010/11/01

One or more resources have the target of 'head', but no 'head' component has been defined within the view.


Environment: JSF 2 + Facelets + PrimeFaces 2.1 + Glassfish V3

As I run my test.xhtml, it will show this error message in console:
sourceId=null[severity=(ERROR 2), summary=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.), detail=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.)] sourceId=null[severity=(ERROR 2), summary=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.), detail=(One or more resources have the target of 'head', but no 'head' component has been defined within the view.)]


You will see this javascript error in my browser

Root Cause: I need to edit my template.xhtml
[Before]

[After]

Demo

How to integrate JSF 2.0 with Facelets

1. Create Dynamic Web Project. Assign project name, target runtime, dynamic web module version, and configuration.


2. Click Next

3. Click Next

4. Select JSF 2.0 in user library, and click finish.

5. The Dynamic Web Project had been created. (NOTICE: you won't need jsf-facelets.jar anymore)

6. Edit web.xml. Added one context parameter.

7. You don't need to add view-handler in faces-config.xml

8. Create header template page

9. Create footer template page

10. Create template page. Including header, title, body, and footer area.

11. Create test.xhtml. Apply template.xhtml, and insert new contents into title area and body area.

12. Demo


Compare JSF 1.2 with JSF 2.0 concerning configurations:

2010/10/19

Apache Maven Quick Start


M2Eclipse Installation

1. Select Help > Install New Software. This should display the "Install" dialog.
2. Paste the Update Site URL into the field named "Work with:" and press Enter.
Pressing Enter should cause Eclipse to update list of available plugins and components.
m2eclipse Core Update Site: http://m2eclipse.sonatype.org/sites/m2e

3. Click Next

4. Choose "I Accept...", and click Next

5. downloading M2Eclipse jar files

6. Restart Eclipse


Create a Maven Project

1. New a project --> Maven Project

2. Click Next

3. Choose"maven-archetype-qiickstart", and click next

4. fill in group id, artifact id, version. Click finish.

5. Your Maven Project had been created.


6. Go to find out specific jar file: http://mvnrepository.com. For example, I would like to use commons lang in my maven project.

7. Choose specific jar file

8. Copy dependency tag to my pom.xml

pom.xml

9. You can find out commons-lang-2.5.jar had been downloaded.

10. I can import StringUtils in my class.