Creating a basic JSF View: Hello World!!
Aug 24, 10 by Juan Lebrijo about weblogic, blog, Eclipse
In a previous project we saw how to create a Weblogic basic web project. Based on this we will create a very basic view with JSF. JSF has some advantages:
  • Clean Cross browsing: we can forget styles and javascript, and navigator sigularities.
  • Encapsulates the view components
  • It is XML, then is text, then is always editable.
  • Standards based = XHTML + JavaScript + JSP + Java (JEE5+)
  • Some libraries (oracle-ADF, richfaces, icefaces) allow Rich Inernet Applications development.
How described technical espec we will make the views with JSF 1.2, Oracle implementation. We can add this facet in the project properties:
1248.thumbnail.gif 6.64 KB

Managed Bean

This object will map our JSPs and will store the server data in the session. Then I will put as view object:
package view;

public class HelloBean {
    private String nombre = null;

    public String getSaludo() {
        return "Hola, "+nombre;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
}
We must map this bean in faces-config.xml:
1223.thumbnail.gif 4.23 KB

Creating JSPs

We will create a JSP/JSF page using "New JSF page (html)" template:
1222.thumbnail.gif 7.76 KB
The palette helps us to create the JSPs:
1221.thumbnail.gif 5.14 KB
We will create a name request form, saludame.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>




Insert title here



    
    Soy: 
        
    



The response, saludo.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>




Insert title here



    



Navigation rules

We will create the navigation rule in faces-config.xml:
  1. Select Navigation Rules tab in the file
  2. The palete helps us to create the navigation diagram
  3. In the link write the literal that fulfil the rule, in the action of saludame.jsp.
1220.thumbnail.gif 7.87 KB

Test

Deploy your Weblogic, and in the address http://localhost:7001/wsc/faces/saludame.jsp , we take the following result:
1219.thumbnail.gif 4.85 KB