Hakan Uygun (hakan.uygun@ozguryazilim.com.tr)
<web-fragment> <servlet> <servlet-name>myFrameworkServlet</servlet-name> <servlet-class>myFramework.myServlet</servlet-class> </servlet> </web-fragment>
<xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <head> <title>Guess Number JSF Application</title> </head> <body> <h:form> <h2>Hi. My name is Duke. I am thinking of a number from <b> <h:outputText value="#{UserNumberBean.minimum}"/> to <b> <h:outputText value="#{UserNumberBean.maximum}"/>. <p>Can you guess it ?</p> <h:graphicImage id="waveImg" url="/wave.med.gif" /> <h:inputText id="userNo" value="#{UserNumberBean.userNumber}"> converterMessage="#{ErrMsg.userNoConvert}"> <f:validateLongRange minimum="#{UserNumberBean.minimum}" maximum="#{UserNumberBean.maximum}"/> </h:inputText> <h:commandButton id="submit" action="success" value="submit" /> <h:message showSummary="true" showDetail="false" style="color: red; font-family: 'New Century Schoolbook', serif; font-style: oblique; text-decoration: overline" id="errors1" for="userNo"/> </h2> </h:form> </body> </html>
@ManagedBean(name="userBean") @RequestScoped public class UserBean { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public UserBean() {} }
@WebService(endpointInterface = "juma.mohammad.Greeting") public class GreetingImpl implements Greeting { @WebMethod public String sayHello(String name) { return "Hello, Welcom to jax-ws " + name; } }
@Path ("items") @Produces (MediaType.APPLICATION_XML) Public class ItemsResource { @Context UriInfo uriInfo; @GET Items listItems() { Return Allitems(); } @POST @Consumes (MediaType.APPLICATION_XML) Public Response create(Item item) throws ItemCreationException { ... } ... }
DAL : Data Access Layer
@Entity @Table(name="ACCOUNT") public class Account extends AuditBase implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.TABLE,generator="genericSeq") @Column(name="ID") private Long id; @Column(name="ACCOUNT_TYPE") @Enumerated(EnumType.ORDINAL) private AccountType accountType; @Column(name="CODE", length=20, nullable=false, unique=true) @NotNull @Length(max=20, min=1) private String code; @Column(name="NAME", length=50) @Length(max=50, min=1) private String name; ..... }
@PersistanceContext EntityManager em; Account acc = em.find(Account.class, 1L); acc.setCode(“010101”); em.merge(acc); //Sorgu em.createQuery(“select c from Account c”) .getResults();
EntityManager em = ... ; CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Employee> cq = cb.createQuery(Employee.class); Root<Employee> emp = cq.from(Employee.class); cq.select(emp); cq.where(cb.equal(emp.get(Employee_.lastName), "Smith")); TypedQuery<Employee> query = em.createQuery(cq); List<Employee> rows = query.getResultList();
@Stateful Class public HelloAction implements Serializable{ public String sayHello( String name ){ return “Hello “ + name; } } //Kullanım @Ejb HelloAction hello;
@Stateful @SessionScoped @Model public class Login { @Inject Credentials credentials; @Inject EntityManager userDatabase; private User user; @RolesAllowed("user") @Produces @LoggedIn User getCurrentUser() { ... } }
@Qualifier @Retention(RUNTIME) @Target({TYPE, METHOD, FIELD, PARAMETER}) public @interface Informal {}
private int maxNumber = 100; ... @Produces @MaxNumber int getMaxNumber() { return maxNumber; } ---------- //Kullanım Biçimi @Inject @MaxNumber Instance<Integer> randomInt;