Posts tagged Bean

Hello Struts

0

Struts is a java framework for web implements the MVC design pattern.
Struts facilitates the work of page redirection, form submitting, data validation and much more.

a common scenario is a login page
login.jsp that contains two inputs user name and password
a simple java class/bean that maps this information ( has two properties username and password)
an action servlet that receives the login page data and put them into the bean
then make a specific action (Logining) after that redirecting to another page (success page or return to the login page if error happened)
(more…)

Building simple Data Access Layer

0

The aim of this tutorial is to manage the access of a table in database from separate layer written in java, this layer usually called Data Access Layer (DAL)
this layer consists of A simple class/POJO/Bean called Data Transfer Object(DTO) this object is just a simple mapping to the table, every column in the table would be a member variable in the class.

our aim is to order this layer to create, modify, delete or search for an entity Using simple java objects rather than dialing with SQL statements and Database issues.

Database Creation

We want to create a simple table for users, we may create it using these fields

  • id
  • name
  • password
  • age

(more…)

Dynamic breadcrumb / navigation menu

0

A breadcrumb / navigation menu should track all the moves of the user from a page to another

the concept of making a dynamic navigation menu is to save every visited page in a list so that it contains all the visited pages from the home page until the current page
when i click on any menu item (return to a previous page on my navigation) i should clear all the pages after this page from the list.

user visits history should be stored among all user requests and should be unique to every user, so we would store navigation information in Session scope

(more…)

Hello JSF

0

Java Server Faces (JSF) is component-based framework that facilitates using HTML elements because you will not responsible anymore for writing parts of your HTML code

An example is to make a login page

we will start by making a bean represents our data
it will contain two properties represents the name and the password (two attributes, two setters and two getters )

also we’ll include a method that checks if that login details is valid or not
for simplicity we’ll choose a simple rule
if the name equals password then it’s correct login information
we can change this lines of code by what you want as for example connection to our database to check for these details

package beans;

public class User {

    private String name;
    private String pass;

    public void setName(String name) {
        this.name = name;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getName() {
        return name;
    }

    public String getPass() {
        return pass;
    }

    public String check()
    {
        if(name.equals(pass))
            return "welcome";
        else
            return null;
    }

}

there is something missing
till now it’s just a bean
we need to tell the framework that it’s a managed bean providing a name for it and a scope to be put into

Managed Bean
JSF framework uses some kind of beans called Managed Beans to store form data
so we will start to make our own ManagedBean

(more…)

Go to Top