Posts

Showing posts from January, 2014

Daniel That: How to display code in blogger posts

Daniel That: How to display code in blogger posts



How to display code in blogger posts In this post, I'm going to show step by step how to display code nicely in blogger posts using SyntaxHighlighter.

1) First, we need to add the html code below on the head section of our blogger template. To do this, inside blogger:
Select Template on the left hand side.Click Edit HTML.Then copy the code below just before the closing head tag (i.e </head>). You can easily find it by using the search box accessing to it with Control+F.
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/s…

JSF 2.0 Example Code

Excerpted from  http://balusc.blogspot.com/2011/01/jsf-20-tutorial-with-eclipse-and.html 

Model:

package com.example; import java.io.Serializable; import java.util.Date; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; public class User implements Serializable { private static final long serialVersionUID = 1L; private Long id; @NotNull (message = "Please enter username") private String username; @NotNull (message = "Please enter password") @Pattern(regexp = ".*(?=.{8,})(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).*", message = "Password is not strong enough") private String password; @NotNull (message = "Please enter email") @Pattern(regexp = "([^.@]+)(\\.[^.@]+)*@([^.@]+\\.)+([^.@]+)", message = "Email is not in valid format") private String email; private Date birthdate; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Str…

java - Design Patterns web based applications - Stack Overflow

java - Design Patterns web based applications - Stack Overflow




A bit decent web application consists of a mix of design patterns. I'll mention only the most important ones. Model View Controller patternThe core (architectural) design pattern you'd like to use is the Model-View-Controller pattern. TheController is to be represented by a Servlet which (in)directly creates/uses a specific Model and Viewbased on the request. The Model is to be represented by Javabean classes. This is often further dividable in Business Model which contains the actions (behaviour) and Data Model which contains the data (information). The View is to be represented by JSP files which have direct access to the (Data)Model by EL (Expression Language). Then there are variations based on how actions and events are handled. The popular ones are: Request (action) based MVC: this is the simplest to implement. The (BusinessModel works directly with HttpServletRequest and HttpServletResponse objects. You have t…