Wednesday, March 2, 2011

People With Same Birthday Compatibel

Basics Tutorial Web applications with NetBeans Part 3

now proceed to create our Bean. We
Sources are located in
Packages





to right click and select -> New -> Java Package


write avbravo.com




Within avbravo.beans
right click, select New-> Other
Categories Java Server Faces and File Type: JSF Bean Managed

We indicate the name: Login and Scope: Session (for which the value is maintained throughout the user session)

We created bean




generated code

javax.faces.bean.ManagedBean import, import
javax.faces.bean . SessionScoped;

/ **
* * @ Author
avbravo
* /

@ @ ManagedBean
SessionScoped
public class Login {
/ ** Creates a new instance of Login * / public
Login () {}

}
add two String attributes


right-click with your mouse and select Insert Code or press the key combination ALT + INS




select Getters and Setters

select all fields

The IDE generates get and set methods for each field
our class would be as follows
avbravo.beans package;

import javax. faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
/**
 *
 * @author avbravo
 */

@ManagedBean
@SessionScoped
public class Login {
String username;
String password;
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
   this.username = username;}

/ ** Creates a new instance of login * /
; public Login () {}

}

Edit the
index.xhtml


Agregamps In value = "" add # {and activates the wizard allows you to select
class

login select the class and write. and activates the wizard (you can activate by pressing CTRL + SPACE) and select username


repeat the same procedure for password.
the end result is this


In the next blog will create a page that will display the data sent by the user and stored in the Login class

0 comments:

Post a Comment