!!! Listings zum Artikel "Webgesicht"
!!! von Martin Marinschek und Gerhard Petracek
!!! in iX 10/2009, S. 145
!!! Listing 1: Minimales XHTML
Irian - JSF 2.0 MBlog
Hallo #{user.userName} - Willkommen bei JSF 2.0!
!!! Listing 2: Managed Bean
@ManagedBean
@RequestScoped
public class User {
public String getUserName() {
return "iX-LeserIn";
}
}
!!! Listing 3: Geänderte Managed Bean
@ManagedBean(name = "user")
@SessionScoped
public class User {
private String userName;
private String password;
//+ Getter- und Setter-Methoden
}
!!! Listing 4: Login
!!! Listing 5: Annotation
public class User {
@NotNull
@Size(min = 3, max = 7)
private String userName;
@NotNull(message = "{password.required}")
@Size(min = 7, max = 14)
private String password;
//+ Getter- und Setter-Methoden
}
!!! Listing 6: Stylesheet einbinden
Irian - JSF 2.0 MBlog
!!! Listing 7: Formular
!!! Listing 8: Matadaten
!!! Listing 9: Listener
public void loadBlog(ComponentSystemEvent componentSystemEvent) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if((!(facesContext.getRenderKit().getResponseStateManager()
.isPostback(facesContext)) &&
!facesContext.isValidationFailed())) {
this.currentBlog = this.blogService
.loadBlog(this.loadBlogOfUser, this.loadBlogByName);
//...
}
//...
this.blogList = this.blogService
.getBlogs(this.currentUser.getUserName());
}
!!! Listing 10: Verlinkung
Name
Beschreibung
#{currentBlog.description}
!!! Listing 11: Composite Component