Skip to main content

Posts

Showing posts with the label Java EE 6

JSF + JPA + JasperReports (iReport) Part 1

Hi in this post we will see the overview of  JasperReports  and how to integrate into JSF application. JasperReports is the world's most popular open source reporting engine. It is entirely written in Java and it is able to use data coming from any kind of data source and produce pixel-perfect documents that can be viewed, printed or exported in a variety of document formats including HTML, PDF, Excel, OpenOffice and Word.  In Primeface  library also use this JasperReports to generate the PDF, CSV and DOC formats with single line of code. see here . but its not flexible and we cant change template. so here we see the how to use JasperReports for create the template and integrate  JSF 2.0. We are using iReport tool for crating template. Download JasperReports and iReport Jasper Reports download from here . This zip contain jasper library and its dependencies and lots sample codes. iReport download  from here Now create the simple JSF Application to retrieve the data f

Understanding Java Server Faces 2.0 Part 3

This is Third  part of JSF 2.0 discussion. Please visit  part one   and part two Update : New Post JasperReports in JSF In this post we will discuss JSF with AJAX. In JSF 2.0 gives full support for ajax integration in web application.  With Ajax, web applications can send data to, and retrieve data from, a  server  asynchronously (in the background) without interfering with the display and behavior of the existing page. so with help of ajax we will make more interactive page.   JSF 2.0 Faclets provide <f:ajax> tag for achieve ajax in web application without writing client side java script ajax code. JSF 2.0 takes care all of this. JSF and ajax integration is one of the greatest feature. and no other framework provide this much easy ajax integration in web application. Consider we have one simple web application it prompt the name and click submit button its display the name in same page in some where . we will see this example without ajax  index.xhtml < h

Understanding Java Server Faces 2.0 Part 2

This is Second  part of JSF 2.0 discussion. Please visit   part one   Update :  New Post JasperReports in JSF In JSF 2.0 part 1   post, i used  @ManagedBean annotation for POJO java class. Its OK, actually it derived from JSF 1.2.But we should use @Named annotation instead of @ManagedBean, if CDI  ( Contexts and Dependency Injection ) environment is available. I used Tomcat 7, its not Java EE 6 server and by default CDI is not available.  But we can use JBoss's Weld lib for achieve  CDI in tomcat with minimal configuration. Weld is reference implementation of CDI and its comes standalone version also. This standalone version weld provide CDI environment for both Web Application and Java SE application. By default Glassfish 3.0/3.1 server comes with weld  library for CDI Environment. Here i am using Glassfish server with CDI enabled. Page Navigation        This post we will discuss page navigation in JSF2.0. Page Navigation means flow of the application. From one page

Contexts and Dependency Injection Series

Contexts and Dependency Injection (CDI )  JSR 299  is a new feature in Java EE 6 Web Profile .  Its Enhance the JSR 330 Dependency Injection in Java. CDI are highly used annotation. CDI makes Loose coupling between classes. To use javax.inject.Inject annotation, we can inject any class into another classes  i put 4 part series of CDI, you can get it here Learning CDI (Contexts and Dependency Injection) Part 1 Learning CDI (Contexts and Dependency Injection) Part 2 Learning CDI (Contexts and Dependency Injection) Part 3 Learning CDI (Contexts and Dependency Injection) Part 4

Why should I learn JSF

Java Server Faces (JSF) is one of the presentation web frameworks in java. There is lots of others frameworks like Spring, GWT, Wickets, Struts. Today this post we ll discuss why JSF is more important then others.Here I am not  criticize any frameworks. i just talking about JSF.   In JSF 1.2 and previous version of JSF used JSP as a view declarative language and JSP life cycle is not matched with JSF and ajax requests. JSF 1.2 are complex to use and they have some short coming in feature. But JSF 2 is completely changed the adapt lots of technologies, but still its support backward compatible.Its very easy to learn. More over JSF is center piece in Java EE 6 Spec. It means that what are the new components or specification introduced in Java EE 6 are seamlessly integrated into JSF. Because those components spec is designed for JSF in mind.

Understanding Java Server Faces 2.0 Part 1

Update : I put new post for  Why should I learn JSF                   I put new post for  Understanding Java Server Faces 2.0  Part  2   JavaServer Faces (JSF) is a Java-based Web application framework intended to simplify development integration of web-based user interfaces.  Java Server Faces (JSF) 2.0 is a improved component of Java EE 6 Specification.  Its Component based model. Its is alternative technology for Struts, JSP, Spring. Its MVC (Model-View-Controller) based architecture.

Understanding CDI (Contexts and Dependency Injection) Part 4

This is Fourth  part of CDI discussion.Please visit   part one ,  part two  and    part three Interceptors Interceptors is one feature of CDI. Using this feature we can intercept the method call. Its counterpart technique for Aspect Oriented Programming (AOP) in Spring. Its helps to analysis the business methods and these interceptors are disabled by default. so we can enable/disable the interceptor in deployment time through beans.xml  file. Create interceptor      To create interceptor involves two step process. first to create interceptor binding and  implement the interceptors. here we create Log Interceptor, so we need to create Log Interceptor Binding(its  like qualifier) Log.java here @InterceptorBinding is represent that the annotation 'Log' is interceptor second, we need to implement the interceptors LogImpl.java here @Interceptor represent that its interceptor implementation @Log specifies to which interceptor  implementation , both of these lin

Understanding CDI (Contexts and Dependency Injection) Part 3

This is Third  part of CDI discussion.Please visit   first part  and part two , @Alternative In part two  we seen @qualifier 's to resolve the unambiguous problem for one interface and more than on implementation. In qualifier helps to solve in development time. (i.e all meta information is stored in class files). Another solution is @Alternative annotation solve the problem in  deployment  time. all configuration is stored in beans.xml in WEB-INF folder We take same example what we discussed in last part  one interface (Hello) and two implementation(HelloImplOne, HelloImplTwo) here i marked @Alternative in both implementation Hello Interface HelloImplOne Implementation HelloImplTwo Implementation and go and modify the beans.xml in WEB_INF folder In <alternatives> tag in beans.xml we need specify which one need to inject. See the screen cast for demo Comments are welcomed

Learning CDI (Contexts and Dependency Injection) Part 2

This is second part of CDI discussion. If u r not visited, Please visit first part , Qualifier            Its annotation, its helps to create our qualifier annotation. We already seen if we have more than one implementation of particular interface then we can't inject, because ambiguity issues are arise. so we need to define own qualifiers and marked the annotation with that qualifier. When inject we need to mention the qualifier. For Example We have one interface and two implementation Hello Interface HelloImplOne Implementation HelloImplTwo Implementation  In Injection  Point (i.e where u inject the class, i.e where u use @inject key word) if u try to inject using interface like this u get AmbiguousResolutionException. but we can still use like this @javax.inject.Inject HelloImplOne hello; @javax.inject.Inject HelloImplTwo hello; so we need use qualifier we can create own qulaifier like any class here @Qualifier - is annotation to rep

Learning CDI (Contexts and Dependency Injection) Part 1

Please see the second part  here Contexts and Dependency Injection (CDI )  JSR 299  is a new feature in Java EE 6 Web Profile .  Its Enhance the JSR 330 Dependency Injection in Java. CDI are highly used annotation. CDI makes Loose coupling between classes. To use javax.inject.Inject annotation, we can inject any class into another classes     In traditional way, we create the instance using ' new ' operator in another class. here thats instance life time is dependent on target class. its tightly coupled. Here CDI makes to loosely coupled and change the life-cycle for that instance.