myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Myfaces Wiki] Update of "Getting started with Netbeans and MyFaces (en)" by Koen Samyn
Date Wed, 29 Mar 2006 20:44:26 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by Koen Samyn:
http://wiki.apache.org/myfaces/Getting_started_with_Netbeans_and_MyFaces_%28en%29

New page:
##language:en
== Getting started with Netbeans and Myfaces ==

This page offers a quick start if you want to try out the MyFaces component library in [http://www.netbeans.org
Netbeans 5.0]. Netbeans offers some support for JSF 1.1 and it is quite easy to define the
MyFaces library.

=== Create a new webapplication ===

Netbeans comes with Tomcat installed out of the box so it isn't really necessary to install
the Tomcat webserver unless you want a specific version of the Tomcat webserver. 

The first step you need to take is to create a new webapplication via File -> New Project,
and follow the wizard :



1. '''''Choose Project''''' : Choose category "Web" and pick and ordinary "Web Application".
Click "'''Next'''".[[BR]]

2. '''''Name and Location''''' : Choose a directory for your project, and make sure "'''Source
Level'''" has the correct setting. You will usually want to use JDK 1.5 for your project so
leave this checkbox unchecked.[[BR]]

3. '''''Frameworks''''' : Pick the JSF framework. The "''' Servlet URL mapping'''" determines
the URL you need to use to access a JSF page. (for example http://localhost:8084/'''faces'''/eerstejsfpagina.jsp).

The project is now ready for use. The wizard created the '''faces-config.xml''' file for you
and also an example JSF file with the name '''welcomeJSF.jsp'''. 


=== Create a MyFaces library in Netbeans ===

To be able to use all the components in the MyFaces framework you need to download a lot of
Java libraries. MyFaces uses some libraries from the Apache Commons project and I have never
had a problem when using the latest version of these libraries. The set of libraries that
works is :

commons-lang-2.1.jar[[BR]]
commons-beanutils.jar[[BR]]
commons-codec-1.3.jar[[BR]]
commons-collections-3.1.jar[[BR]]
commons-digester-1.7.jar[[BR]]
commons-el.jar[[BR]]
commons-fileupload-1.1.jar[[BR]]
commons-validator-1.2.0.jar[[BR]]
commons-io-1.1.jar[[BR]]
jakarta-oro-2.0.8.jar[[BR]]
myfaces-all.jar[[BR]]

All "'''commons'''" libraries can be downloaded from [http://jakarta.apache.org/site/downloads/downloads_commons.html
commons download website]. The '''Jakarta ORO''' library can be downloaded from [http://jakarta.apache.org/site/downloads/downloads_oro.cgi
ORO website].

And finally you can download the  '''myfaces''' library from the [http://myfaces.apache.org/download.html
 MyFaces website].

Now you need to add a new library in Netbeans via "'''Tools -> Library Manager'''". Click
"New Library" en enter the name "'''MyFaces'''" (or any name you would like for the library)
and add the jar files mentioned via "Add JAR/Folder...".

=== Project configuration ===

1. Open the context menu of the project in Netbeans and choose "Properties". Select "Libraries"
and add a reference to the "MyFaces" library you just created. Because '''myfaces-all.jar'''
contains a complete JSF implementation you need to '''uncheck''' the '''JSF 1.1''' library
. In principle it should be possible to use the tomahawk.jar file in combination with the
JSF 1.1 library in Netbeans but I could not get it to work.

2. Open the '''web.xml''' file (in '''Configuration Files''') and add the following filter
definitions (Click "XML" in Netbeans to see the XML view of the file) :

{{{
    <filter>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
        <init-param>
            <param-name>maxFileSize</param-name>
            <param-value>20m</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>/faces/*</url-pattern>
    </filter-mapping>
}}} 

The filter definitions need to be placed right under the  '''web-app''' element.

=== A simple JSF page with a MyFaces component ===

{{{
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <f:view>
            <h:form>
                <t:outputText value="Hello MyFaces!"/>
            </h:form>
        </f:view>
    </body>
</html>
}}}

Mime
View raw message