Wednesday, December 10, 2014

I have recently been honored via invitation to join the NetBeans Dream Team. I've been using NetBeans IDE since its infancy, and I've watched it evolve into one of the top IDEs for developing Java applications, amongst other things. I am honored and privileged to have the opportunity to help promote NetBeans, and collaborate with the other NetBeans Dream Team experts to help make the NetBeans IDE even better.

There were 16 new members that were invited to join, and Geertjan Wielenga has written a post about the new members here: http://netbeans.dzone.com/articles/16-new-netbeans-dream-team. I want to thank all of the members for having me as a NetBeans Dream Team member...I am looking forward to working with you.

To kick off my membership to the NetBeans Dream Team, I wanted to write a post that promoted some of my favorite, but perhaps most overlooked NetBeans features. I will list three such features in this post, as I must keep my writings short...and I could go on writing about my favorite features for quite some time. All that said...here are my favorite NetBeans IDE features that are oftentimes overlooked:

#1: Built-in Terminal: Did you know that NetBeans has a built in terminal at your disposal? Sure, it is acceptable to have a terminal window or command line open outside of NetBeans, but maintaining one or more of them inside of the IDE makes it even easier to focus on your tasks at hand...without the need to move outside of the IDE. (Speaking of which, did you know there is a task list in NetBeans...sorry, I digress). The NetBeans built-in terminal provides you with the ability to open one or more terminal sessions right within the IDE, and you can even open up an SSH connection to a remote server. This provides a unified development environment at its best! To open up a terminal, simply go to the "Window" menu, then select "IDE Tools" -> "Terminal".

#2: Version Control Made Easy: No matter which version control you use, NetBeans makes it simple, providing convenient integration points for version control with your NetBeans projects. I've used Mercurial, Subversion, and Git within NetBeans, and each of them is easy to use...with an intuitive interface, and even some additional plugins to make use easier. One of my favorite plugins is the Git Toolbar, which provides easy buttons for showing history, committing changes, etc.

#3: Debugger: When I am having an issue with one of my applications, the NetBeans debugger can be an invaluable utility. Perhaps my favorite feature of the NetBeans debugger is the ability to see the values of variables as the application is running.

The debugger provides the ability to set breakpoints (conditional if you'd like), so that one can evaluate the current status of the code when breakpoints are reached. If you are having an issue in one of your classes, the debugger allows you to see the current variable values, and step through the code to find the offending line. It also provides you with numerous other capabilities, such as the ability to set expression watches, easily see the call stack, the ability to see which classes are currently loaded, sessions, current threads, and more. The debugger has become one of those features that I cannot live without, and it deserves a book of its own.

That does it for this short post. Once again, I want to thank Geertjan and all of the members of the NetBeans Dream Team for having me...I am very glad to be a part of the team!

Friday, November 28, 2014

I had the privilege to review the book RESTful Java Patterns and Best Practices, authored by Bhakti Mehta for Packt Publishing. In short, this book hits the sweet spot when it comes to learning utilization of RESTful web services. As the book provides a solid foundation for the creation, testing, and utilization of RESTful web services with JAX-RS 2.0, it also provides information on essential topics, such as authentication, security, and performance. There is even coverage of advanced topics, such as rate-limiting, polling, and micro services.

The book begins by providing a general understanding RESTful web services, design principals, and the differences between the various HTTP verbs. This discussion is provided at a high level, such that it is generalized enough to cover various RESTful web service implementations. The first chapter then goes into the Java API for RESTful Web Services. This section of the first chapter is brief, and to the point. It clearly explains how to create services and then test/access them via the Client API, cURL, and other utilities. As mentioned at the top of this post, Chapter 1 provides a solid foundation...and it is a quick read also, which enables developers to get up and running quickly with the JAX-RS API.

The third chapter covers security, validation, and logging of RESTful web services. This is a chapter for intermediate users, as it goes beyond the basics and covers the use of filters for logging, and constraint annotations for validation. It then provides a brief example of building an exception class. Lastly, this chapter goes into authentication practices using SAML (Security Assertion Markup Language), OAuth, and tokens. While this chapter sets a good stage for discussing the various types of authentication, it does not go into detail on these topics.

Chapter 4 covers performance via caching, asynchronous and long-running jobs, and partial updates. The chapter clearly explains how to utilize the Cache-Control header and ETags. It then explains how to design asynchronous web services, and some best practices. The last topic in the chapter is partial updates...a topic that is briefly explained, but leaves room for further exploration.

The next chapter goes into advanced topics for RESTful web services...including rate-limiting, response pagination, internationalization and localization, and pluggability and extensibility. I really liked the way that this chapter covered rate-limiting in detail, and explained why this is an important topic. It then provides a detailed explanation for response pagination, along with a good example. The internationalization and localization section is brief, but provides a good enough explanation for getting started with internationalization. Lastly, the chapter provides a brief overview HATEOAS (Hypermedia as the Engine of Application State), testing, and extensibility.

The final chapter does a good job of wrapping up the many topics of RESTful web services, discussing the future of REST and emerging standards. It is a chapter that explains polling and the importance of providing real-time APIs for avoiding inefficiencies. Along the way, it touches upon various topics, such as WebHooks, SSEs (Server Sent Events), and WebSockets, and how they relate to RESTful services.

The book contains a helpful Appendix which covers various APIs from GitHub, Facebook, and Twitter. It is a nice closeout to the book, providing an overview of how to glean information from these important social media networks.

Overall, this book is a great read for getting started with RESTful web service creation and utilization with JAX-RS. I enjoyed the fact that the book was authored by Bhakti, who is very experienced with the topic, as she is a founding member of the GlassFish Application Server. I recommend this read for anyone who wants to get up and running quickly with REST, and also learn about various other RESTful concepts along the way. While this book does not delve into fine-grained details of topics such as authentication and partial updates, it provides a good foundation for learning more on such topics. Readers will go away from this book with a solid understanding of how to develop RESTful web services, and they will be able to start developing services after reading through the book. Those who wish to delve into more advanced topics will be provided with a good overview after reading this book, and they'll be pointed into the right direction for learning more on such topics.

Sunday, November 23, 2014

Have you heard of the NetBeans JPQL tool? This is an often overlooked feature of NetBeans IDE that can save developers a lot of time.

If you are a Java EE developer, then you've likely encountered moments when you would like to see the results of a Java Persistence Query Language (JPQL) query before you've written your session bean method. Being that I come from a database administrator background, I am oftentimes finding myself at the SQL command-line (or NetBeans SQL Editor) writing queries, and then translating the SQL into JPQL. NetBeans IDE contains a JPQL tool (since NetBeans 7.3), which makes it easy to write JPQL queries and retrieve results immediately. Let's see how:

The JPQL tool can be invoked within the context of a NetBeans project. The project must have a valid Persistence Context, meaning that it is wired up for database access. Once this is in-place, simply right click on the persistence.xml file, and click on the "Run JPQL Query" to open the tool.

The tool provides a nice editor that provides a top pane for entering a query, and a bottom pane for showing the SQL or the results of the query execution. If you have more than one Persistence Context within your persistence.xml, then you will have the option to select which context you would like to utilize for the query.

To execute the JPQL, simply click on the button next to the Persistence Context pull-down, or right click in the query editor and choose "Run JPQL".

The tool comes in super handy when you are executing queries that involve more than one entity.

Note: Be sure to "Build" your project successfully before trying to use the JPQL tool. If you do not have a successful build, you will likely encounter an error stating that the abstract schema type cannot be found:

Tuesday, November 04, 2014

The JSF 2.3 Expert Group is hard at work determining which features will be part of the upcoming release. The JSF Team been working hard improving CDI alignment, among other things. There are already a number of new features in the JSF 2.3 codebase that you can begin to test. I will attempt to keep this post updated with the latest features that have been added. For the most up-to-date reference, please see Manfred's blog. To reference the information from Manfred's blog, take a look here.

JSF 2.3 Features**Updated 04/2015: - PostRenderViewEvent added, which is published immediately after a view is rendered

If you would like to start testing out these new features today, the easiest way to get started is to simply download the 2.3 SNAPSHOT and then replace the javax.faces.jar file within your GlassFish/glassfish/modules directory with the snapshot.
You will need to be sure to reference version 2.3 in your faces-config.xml. as follows:

If you are adventurous and you would like to build JSF from source, that is also fairly simple. To do so, follow these steps:
1) Clone the trunk using Git: git clone https://github.com/javaserverfaces/mojarra.git
(Old Repository Path: Check out the trunk using SVN:
svn checkout --username yourname --password x https://svn.java.net/svn/mojarra~svn/trunk) 2) Copy the build.properties.glassfish file to build.properties 3) Edit the build.properties file and set jsf.build.home to your source home.
4) From the source home, run ant clean mainThe jsf-api.jar will be in SOURCE_HOME/jsf-api/build/lib and jsf-impl.jar will be in SOURCE_HOME/jsf-ri/build/lib. For more information on building the sources (and even contributing), please see the following reference:https://wikis.oracle.com/display/GlassFish/JavaServerFacesRI#JavaServerFacesRI-HowcanIcontribute%3F

To sum it all up: Java is everywhere, and it is a dominant player in IoT, desktop, and Enterprise.

In Reflection:

After having a few days to reflect on my experiences at JavaOne 2014, a few things come to mind.

First, this was by far the most jam-packed JavaOne that I've attended. Not only were there more attendees this year, but there also seemed to be more great sessions. In many cases, I did not know which direction to turn, as there was usually more than one session that I wished to attend in any given time slot.

Second, the networking opportunities at JavaOne are world-class. There are so many knowledgeable resources at JavaOne, it is worth the trip just to have the chance to speak with the industry leaders.

Third, the community really is driving Java forward. I just recently joined the JCP, and also the JSF 2.3 Expert Group...so this year I paid particular attention to the JCP sessions. That said, the JCP is doing an outstanding job of driving community participation, with the Java EE 8 specifications, in particular. Throughout the conference, there were dozens of examples from around the world that spoke to the great work that the JCP has been doing...keep up the great work!

Finally, the Java ecosystem is strong, and it is gaining momentum. Java really is everywhere...and even though I primarily focus on enterprise, it is great to see all of the many areas in which Java is being utilized. There were many great examples and presentations of embedded Java in the IoT space specifically...can't wait to see what's in store for years to come. All that said, this year's trip to JavaOne was great. I was delighted to have the fortunate opportunity to present during a few different sessions this year, which made it all the better!

In the next few sections, I will provide a brief overview on most of the sessions that I attended. Hope you will find it useful and utilize the information to help you determine which slides to download and sessions to watch on Parleys once the videos are added.

Duke's Cafe

Sunday, Sept 28:

The conference began with a bang, as the attendees in registration were talking about the days to come. Excitement filled Moscone South, as NetBeans Day was jam packed full of useful information, and sessions covering all areas of Java. I attended a few NetBeans community panels, which were all filled with interesting use-cases and success stories revolving around Java and the NetBeans IDE. It was great to see all of the many different ways that people are utilizing NetBeans.

GlassFish RoadMmap and Executive Panel

This has become an annual session for me, as I am a huge fan of GlassFish. This panel was hosted by Reza Rahman, and attendees learned about the future of the application server from John Clingan, Mike Lehman, and Cameron Purdy. GlassFish 5 is slated for release with Java EE 8, and therefore GlassFish will remain the reference implementation of Java EE. There were questions regarding the adoption rate of Java EE...specifically around Java EE 7, since there were only a handful of compatible containers at the time. The panel remarked that they hope to reduce the adoption time for Java EE 8, with hopes that WebLogic will release a Java EE 8 compatibility within 6 months of the Java EE 8 reference implementation release. Glad to hear that GlassFish has a vibrant future as the reference implementation for Java EE.

GlassFish Adoption Story
Next up, I attended the GlassFish Adoption Story to learn that Mohamed Taman's team had implemented a Java card system very rapidly via GlassFish and Java EE 7. Martin Mares, one of the talented GlassFish developers, then provided a brief demo of the powerful GlassFish admin utility. It was great to see how others are making use of GlassFish, and it was also nice to have the opportunity to hear from one of the GlassFish developers first hand.

Java Strategy and Technical Keynote

I attended the Java Strategy and Technical keynote next. Although it was not quite as exciting as JavaOne 2013...which included great announcements like Java EE 7 and coverage if Java 8 and JavaFX 8 new features...this keynote was inspiring, as there were many examples demonstrating great things that people are achieving with Java technology. Watch here...

Java Strategy and Technical Keynote

NetBeans Day Sessions

I finished off the day with a couple of more NetBeans day sessions, learning how companies such as Boeing and the oil industry is making great use of NetBeans IDE. I was privileged enough to present a lightning talk, covering some of the great NetBeans and PrimeFaces integration. During these NetBeans Day events, I ran into some great Java minds...too many to name! In my session alone, I had the honor to present with Tim Boudreau, Kirk Pepperdine, Stephen Reinert, and Martijn Verburg. It was a great experience to have the opportunity to network with these brilliant people.

Java EE Appreciation Event

On Sunday evening, the excellent networking continued as I met up with the Jython leads: Frank Wierzbicki and Jim Baker, followed by the annual Java EE Appreciation Event at Thirsty Bear. I was lucky enough to have in-depth conversations with people like Freddy Guime, John Clingan, David Heffelfinger, Sven Reimers, and more. I also had the privilege of meeting Ed Burns for the first time since joining the JSR 372 expert group. One of my favorite networking events of JavaOne, by far...thanks Oracle!

Monday, Sept 29

Monday was a full day...starting at 7:30 and going until 10:00 in the evening. Of course, the day actually started at 8:30 am, but I had to get to Duke's Cafe for my morning coffee fix first! I started my day off right with a JSR-107 (JCACHE) Tutorial. This was an excellent 2 hour tutorial that was led by Steve Millidge of C2B2. He had a few slides, but delved into lots of code examples. We did not cover a server-side scenario, but instead we focused on a Java SE-based solution with Oracle Coherence. I got a lot out of the session, and it was jam packed with information for the full two hours.

Next up was a session on Java EE 8, led by Linda DeMichiel, Java EE 8 Specification Lead. This was an informational session regarding ideas and concepts that are being kicked around (and some already implemented) for Java EE 8. Nice indeed to learn about the possible future of Java EE by the leaders themselves.

Parc 55 Lounge

My afternoon was full of great sessions (including one of my own). The schedule went like this:

HTTP 2.0 Comes to Java: What Servlet 4.0 Means To You

Excellent session hosted by Ed Burns and Shing Wai Chan discussing the future with Servlet 4.0. HTTP 2 will make quite a difference behind the scenes...sounds like these two have a great strategy for moving forward. If you work with Java EE and you missed this talk, I recommend checking out the slides.

Java EE 7 Recipes (My Talk)

I covered 25 different topics in this talk, spanning across most of the Java EE 7 APIs. I gave a similar talk for the Chicago Coder Conference a couple of months back, but I changed a few recipes a bit and added a recipe covering JAX-RS AsyncResponse. I feel that my Java EE 7 Recipes talk was well received, but I tried to pack too much into it. I ended up stumbling a bit because I was a bit too rushed...I'll have to cut back on the content a bit next time so that I have more time to answer questions. I was honored to have a full room, along with Reza Rahman (Oracle Java EE Evangelist) in the audience.

This talk was given by Martin Grebac, and it discussed the upcoming JSON-B API for Java EE. Well attended, and very informative...looking forward to working with this API!

What's Next for WebSocket API

I was unable to attend the entire WebSocket session, although I did make most of it. Throughout the session, Pavel Bucek went through the history of the API, usage, and then touched upon a few of the updates that we will see in the next release.

JCP Community Party

No doubt, this was a highlight of the trip for me! The JCP Community is celebrating 15 years, and the party was great. Held on the top floor of the Hilton, this party was located in a fantastic setting, and I met up with many brilliant minds there...David Heffelfinger, Freddy Guime, Bob Paulin, Jim Weaver, Geertjan Wielenga...just to name a few. It was a quick visit, as I had to be off to the GlassFish BOF over at Moscone!

Top of the Hilton at the JCP Community Party

GlassFish BOF

I came in toward the end of this BoF, as I was late arriving from the JCP Party. Always great to speak with the leaders of GlassFish...including Reza Rahman, John Clingan, David Delebasse, and more. It was great to learn the needs that others in the industry have with respect to GlassFish.

What's Next for JSF?

Excellent BoF, hosted by Ed Burns and Manfred Riem. Discussed the future of JSF...focused efforts on tidying up via Oracle, but more of a community-driven effort to add new features. Kito Mann discussed how he'd like to add JSON Rendering to the spec, and Ian Hlavats presented an excellent talk on adding Twitter bootstrap support and/or RenderKits that target AngularJS directives.

Calling all GlassFish Users and Groups

This was a small-sized BoF, as there were only a handful of attendees since it was so late in the evening. We were able to engage in conversation with Reza Rahman, Steve Millidge, John Clingan, and others to learn about how we can help GlassFish to move forward. Most important things we can do are testing bug repairs, clean up the issue tracker, download and test the builds, etc. Take a look at https://glassfish.java.net/fishcat
to learn more about getting involved.

Tuesday, Sept 30

Another day full of excellent tutorials, sessions, and BoFs. I had no scheduled talks on Tuesday, so I was open to take in the conference...and I did just that. I started the morning with another 2 hour tutorial given by Michael Finocchiaro and Ryan Cuprak on getting applications to mobile using Cordova. Very detailed, and based around a real life application deployment.

Adopt-a-JSR for Java EE 8

In this talk, Heather Vancura, Reza Rahman, Ed Burns, and Mohamad Taman discussed the different ways in which JUGs could assist if their organization were to join the Adopt-a-JSR program. This was very beneficial to me personally because I am going to be helping the Chicago Java User Group with their efforts in adopting JSR 366. Heather provided an excellent overview of the program. Reza discussed about the focus points for Java EE 8. Ed spoke to his experience with user groups adopting JSRs that he has led in the past. Mohamed discussed how he and his organization had successfully rolled out a major enterprise system utilizing Java EE technologies and Java Card.

Stop! or My Duke Will Shoot!

The excellent Dierk Konig presented on OpenDolphin and communications with IoT devices. During the presentation, he utilized a mobile phone to target and shoot the audience with foam darts. OpenDolphin is an open source framework for constructing JavaFX applications using an MVC architecture. In summary: have a look at OpenDolphin...looks great!

** Lunch with Apress: I was lucky enough to grab lunch at Duke's cafe with my Apress editor, Jonathan Gennick.

** Creating Our Robot Overlords

This one gets two stars, as it was one of my most enjoyed sessions of the conference. Jim Weaver hosted the IoT and JavaFX experts: Mark Heckler and Sean Phillips, who demonstrated how to program Drone devices with Java. Mark presented a very amusing and brilliant session with a drone that he ended up programming to fly in several different patterns. During his presentation, he mentioned that he did not achieve the end result without injury or ruin in his living room. The drone took flight in front of the audience, all the while presenting data that was displayed in real time via a JavaFX GUI written by Jens Deters. Sean was in charge of constructing a 3D JavaFX fly pattern simulator, with which he did an outstanding job. The simulator showed a TIE Fighter flying the same pattern as the drone just flew in front of the crowd. The entire presentation was impressive!

About to Put Drone Into Flight

Simplifying HTML5/JavaScript Rich Clients with Java EE

In this session, Geertjan Wielenga demonstrated how to easily construct a JSF application from entity classes using NetBeans. Johannes Wiegend then demonstrated how to do the same with AngularJS. Informative, and it makes me love JSF, NetBeans, and PrimeFaces even more. While there is benefit to being diverse with choice in development frameworks, I'll continue to use JSF where possible, and leave AngularJS and other client side frameworks to those that tend to weigh more on the client or require more statelessness than JSF offers.

Model-View-Controller in Java EE 8

I have been curious to see how the new MVC framework for Java EE evolves. I am happy to know that it is in the good hands of Manfred Riem, Spec lead. In this BoF, Manfred covered where he believes the JSR will focus, and re-iterated that it is not meant to be a JSF replacement. It will be good to have a standard in Java EE for this style of web development. More tools for the job!

Meet the Java EE Specification Leads

I arrived a bit late for this BoF, but it was very important for Java EE. In this BoF, Linda DeMichiel and Bill Shannon outlined what is in store for Java EE 8, thus far. All Java EE 8 spec leads were on the panel, and answered various questions regarding their specifications. I had the honor of speaking with Bill Shannon after the BoF for a few minutes regarding the Adopt-a-JSR program.

Wednesday, Oct 1
I was energized when I woke up on Wednesday because I was really looking forward to my Java EE Recipes for Concurrency talk later that afternoon. This was the mood of the day, as I only attended a few sessions, but had the opportunity to take in the best of JavaOne...the networking.

PrimeTime JSF with PrimeFaces 5.0

Kito Mann is an excellent speaker. What's better than to have an excellent speaker talk on an excellent topic. Hands down (IMO), the best JSF framework available today, PrimeFaces was covered from top to bottom via Kito's presentation. While I am already very familiar with the framework, I did learn a few new tips from Kito...very insightful. Also very surprised to receive a tweet from Cagatay Civici (PrimeFaces Lead) during the presentation, requesting a photo. I have the honor of sitting on the JSF 2.3 Expert Group with both Kito and Cagatay.

Java EE 7 Hands On Lab

David Heffelfinger and Mark Heckler were the presenters for this year's Java EE Hands On Lab, and they did a terrific job. I had the opportunity to help answer questions for the class, along with Sven Reimers and Bob Larson. It was great to interact with the students, learning the areas in which they develop and why they are trying to learn Java EE. For those who began their journey into Java EE with this class, they couldn't have begun a better way.

David Heffelfinger Teaching JSF

Mark Heckler Spreading Knowledge of JavaEE

Debugging and Profiling Robots

Int his session, the great James Gosling presented along with other JavaFX and IoT experts: Mark Heckler, Jose Pereda, and Jens Deters. Geertjan Wiengela ran interference during this session that provided some good tips, "lessons learned", and great tooling tips from the IoT masters. James Gosling told some tales regarding his experiences with the wave gliders. I was surprised to learn that the biggest issue is fishermen. Mark Heckler flew the drone and spoke about NetBeans for debugging and profiling. Jose and Jens demoed their Raspberry Pi tablets and controlled devices over seas in a live session. All in all....great!

James Gosling's Wave Runner in the Exhibition Hall

Project Avatar: Server-Side JavaScript on the JVM

John Clingan led this talk, followed by some discussion with the Project Avatar team members. During this session, Project Avatar 2.0 was announced, which virtually enables Node.js applications to run on the JVM. They call Avatar "serverside JavaScript for the JVM", and I can see its use-case. I'll certainly keep an eye on this project, as it seems to have a great team behind it.

Java EE 7 Recipes for Concurrency

I was honored to present on the Concurrency Utilities for Java EE as the last presentation time slot for the day. The room was jam packed, and it was full of smart individuals who asked great questions. I was very happy with the way that this session went, and I was happy with the great crowd of attendees. Thanks, and I hope that it was useful.

I had the privilege to attend the JavaOne Appreciation Event with some of the smartest minds in the business. It was great to get out for the evening and see one of the classics, Aerosmith, and also to engage in some highly technical collaboration.

Oracle Appreciation Event

Thursday, Oct 2

Final day...what a week! It flew by, and I barely had a moment to sit down and take a breather in Duke's Cafe (although I did catch the NullPointers playing there for about 1/2 hour and they were excellent).

JavaOne Community Keynote

The keynote was great, and I was lucky enough to sit only a few rows back, right in the center. I was happy that the technical session was presented again, and Mark Reinhold and Brian Goetz did a great job. Jim Weaver is always a great presenter, as were all of the others on stage. This is truly a great time to be a Java developer...exciting times in all areas of the platform!

Mark Reinhold

JavaOne Q&A with the Experts

Java EE 8 Community Update and Panel

The panel in this session was comprised of Java application server product leads (David Blevins, John Clingan, Cameron Purdy, Bruno Borges, Kevin Sutter, Mark Little), as well as the expert community voice of Adam Bien. In this session, the leads gave their thoughts on Java EE 8, and what features or ideas are most important from their perspective. The community had a voice in that the audience was invited to ask questions and raise comments/discussions on what features the community feels are needed for Java EE 8 compliant containers.

Building Java Applications with JavaFX 8 and Java EE 7

Bruno Borges presented some ideas around different integration points for JavaFX8 applications with the Java EE 7 stack. He outlined which Java EE 7 APIs are likely useful for use with JavaFX applications, and which would be less useful. He also touched upon some ideas on how to achieve integration, as well as highlighted some frameworks that are currently in existence to help fill the gaps.

Enterprise Nashorn

This talk was presented by Adam Bien, and he delved into some real-life use-cases for Nashorn within Java Enterprise environments. It was interesting to hear how his projects have made use of Nashorn and also how easy the integration between Java and JavaScript can be achieved.

Applying Groovy Closures for Fun and Productivity

I closed out the conference by attending this talk, which was presented by the great Venkat Subramaniam. In this talk, Venkat did an excellent job of showing how useful Groovy closures can be. He also went into some detail on other useful features, such as currying and memoization, both of which Groovy has to offer.

Summary

JavaOne 2014 was well worth the trip. Not only was it chocked full of great session content and tutorials, but it also provided a world-class collaboration composed of some of the greatest minds in Java.

Thursday, August 28, 2014

I am delighted to be presenting on Java EE topics this year at JavaOne. In particular, I will be presenting on Concurrency Utilities for Java EE, as well as presenting recipes covering some of the new features in Java EE 7. I want to thank Geertjan Wielenga, who has asked me to present a lightning talk for NetBeans Day (September 28), where I will be covering some of the great NetBeans support for the PrimeFaces JSF Framework. Looking forward to it!

David Heffelfinger and Mark Heckler will be hosting the Java EE Hands On Lab for JavaOne. I want to thank them for asking me to be on-hand to help out, as needed. Looking forward to helping promote Java EE. The details are as follows:Session ID: HOL1827Session Title: Java Platform, Enterprise Edition Lab 101: An IntroductionVenue / Room: Hilton - Franciscan A/BDate and Time: 10/1/14, 10:00 - 12:00Looking forward to seeing everyone at the conference!

Friday, August 22, 2014

If you have developed an application that utilizes PrimeFaces, or if you are planning to develop a web application for use on desktop and mobile devices, then consider PrimeFaces Mobile for your mobile implementation. This blog post will cover some basics to help you get started developing a mobile interface for an existing PrimeFaces application. However, the same procedures can be applied to an application that is being written from scratch. This article is a precursor to an article that I am currently writing for OTN, which will cover the PrimeFaces Mobile API in more detail. That article will be published later this year.Getting in the Mobile Mindset

One of the most important pieces of a mobile project is getting into the mobile mindset. While you may have a set of components that you are comfortable using on standard web applications, these components may not provide the best experience when transferred to the smaller screen. For that reason, you need to think about how your user is going to be interacting with your application on the small screen, and provide them with the most convenient user interface as possible. Some things to consider are the amount of text that you will want your users to be typing. If they are on a small device, it may be cumbersome to type lots of text, so we will want to provide them with easy to use components, allowing them to type as little as possible, and even selecting from lists instead. We also need to consider real estate (no not the housing market). Adding a menu to the top or bottom of the screen may not be beneficial to the user if they do not have enough screen left to easily navigate an application.

These are just a couple of the issues tat are presented when developing applications for a mobile device. PrimeFaces Mobile is well suited to assist in these areas since it is built upon one of the leading mobile HTML5 based UI frameworks. PrimeFaces Mobile consists of many UI components that can enable users to be highly productive on a mobile device. If you take a look at the PrimeFaces Showcase, you can see many of these mobile components in action. This enables you to get an idea of how these components look, and how they react for the user. It is recommended to visit the PrimeFaces mobile showcase on a mobile device such as a smartphone or tablet gain the best understanding of how they'll react.

Creating a Mobile Root

Now that you have a basic understanding of some mobile design concepts, let's take a look at how easy it is to get started creating mobile views using PrimeFaces mobile. Before PrimeFaces 5, mobile was a separate download that needed to be included in your project. Now it is easier than ever to get going with PrimeFaces Mobile, as it is packaged as part of PrimeFaces 5. This makes it easy to build enterprise web applications on PrimeFaces for the standard browser, and then build separate views for use on mobile devices, oftentimes utilizing the same back-end business methods for each. I recommend creating a view that is dedicated as a starting point or "root" for mobile device users. I also recommend creating a separate MobileNavigationController class to handle navigation throughout the mobile views, as needed. We can utilize the mobile root view to set the hook for using the MobileNavigationController vs. the standard web application navigation.

For the purposes of this article, let's simply call our mobile root mobileRoot.xhtml. In this case, mobleRoot.xhtml may look something like the following:

In the view above, a JSF viewAction is used to initiate the MobileNavigationController doMobile() method, which sets the mobile UI into motion. From this point, the navigation can take the user to the primary movile view of the application, and it can also set any other necessary configurations. The addtohomescreen.js script (http://cubiq.org/add-to-home-screen) can be also be used to supply a nice button to recommend mobile device users to add the mobile application to their homescreen for a more rich experience. I will address some additional custom configurations for full screen web applications in a future post or the upcoming OTN article.

Creating a Simple Mobile View

Once we've provided our users with a clear path to access the mobile views, we need to ensure that the PrimeFaces mobile render kit is being used to display the mobile views. To flag a view for use with PrimeFaces Mobile, supply the "renderKitId" attribute in the <f:view> tag of your view, and apply PRIMEFACES_MOBILE as the value.

<f:view renderKitId="PRIMEFACES_MOBILE">

Another requirement or building a PrimeFaces Mobile view is to add the mobile namespace (xmlns:pm="http://primefaces.org/mobile"), as it will be used for each of the PrimeFaces Mobile specific components. It is also a good idea to include the JSF passthrough (xmlns:pt="http://xmlns.jcp.org/jsf/passthrough") namespace, as we may wish to make use of some HTML5-specific features.

A mobile page consists of a header, content, and a footer. Each mobile page is enclosed within the <pm:page> tag. A mobile view can consist of a single page enclosed in <pm:page>, or multiple pages, each with their own identifiers. In this example, we will create two views that constitute two mobile pages, the second page is accessed via a link on the first page. It is possible to utilize Facelets templates to build an entire mobile application solution, but in this example we will create each view separately. It is also possible to develop using the "single page" application strategy that is currently quite popular...we will cover more on that in the OTN article.

The PrimeFaces Mobile example in this post and also the upcoming OTN article builds upon the Acme Pools example that was used in my "PrimeFaces in the Enterprise" article for OTN (http://www.oracle.com/technetwork/articles/java/java-primefaces-2191907.html). In the full web version, the root view includes a listing of Acme Pool customers in a table view (Figure 1). We would like to transform this view (and the others) to work better on a mobile device, and also allow selection of each row, which will take us to more information on the selected customer.

Figure 1: Standard Acme Pools View

For the purposes of this post, we will work with the initial customer view to convert it into a mobile view. The view will contain a list of customers, and if you select a particular row in the view, then more information on the selected customer will be displayed. To display a table using PrimeFaces mobile, you must make use of the DataList component, which provides a convenient "clickable" link or button for each row of data. The DataList differs from a DataTable in that there are no columns in a DataList, but rather, there is one group of related data for each row of data. The group of data should be wrapped with a clickable link, which will then provide navigation for the user to the second view displaying more details on the selected item. The following code is used to develop the mobile UI for the customer data list.

As you can see, we flag the view for PrimeFaces Mobile use via the specification in the <f:view> tag. We then create a <pm:page>, and inside of the page we have sections for <pm:header>, <pm:content>, and <pm:footer>. The main content consists of a PrimeFaces mobile DataList that displays customer data, and the data is wrapped in a p:commandLink component. When the link is clicked, the #{customerController.loadCustomer} method is invoked, passing the ID of the selected customer. Note that the DataList component uses passthrough attributes to specify the data-role and data-filter HTML5 attributes. These are used to provide the user with a more rich experience. The filter makes it easy for the user to begin typing a value into a filter textbox, and have the list shortened to contain only the records that contain the typed text. The resulting view looks like Figure 2.

Figure 2: Mobile View

The code in Listing 2 contains the implementation for loadCustomer(). The customer ID is passed to the find() method of the EJB, which then returns the selected customer data.

When a customer is selected in the DataList, the loadCustomer() method is invoked, and it results in the navigation to our second mobile view, customerInfo.xhtml (Figure 3). The second mobile view basically displays customer details, and provides a link to go back to the DataList of customers. The code for customerInfo looks like that in Listing 3.

As you can see, the customerInfo view contains the same structure as the original mobile view. There are no special mobile components added, but as you can see from Figure 3, the standard PrimeFaces panel is styled to display nicely on the mobile device.

Figure 3: Mobile View Selection

Conclusion

That wraps it up for this brief look into using PrimeFaces mobile. As you can see, it is easy to develop a mobile interface for your applications. The PrimeFaces mobile suite also includes custom frameworks for navigation, events, and more, making it easy to provide a nice mobile experience. For instance, the events framework includes some swipe events, as well as taphold. It is even possible to hook into the JQuery Mobile framework to provide even more mobile events to your application.

The PrimeFaces mobile navigation framework consists of transitions, which ultimately provide your application with a smoother feel. For instance, one can provide a transition of "slide" to a button navigation, which will result in a UI view that slides into focus when the button is clicked. All of this can be tested using the PrimeFaces Showcase.

For more information on these and other important features of PrimeFaces mobile, please watch for my upcoming OTN article.

Saturday, August 02, 2014

The Chicago Coder Conference was held on Friday, August 5th. The conference venue was a sleek downtown facility on Wacker Drive. There were breakfast bagels and great coffee to start the day, along with some good networking opportunity. The keynote began at 8:30 am, where JUG member Scott Kramer spoke about the events of the day, and introduced the keynote speakers. The keynote included two speakers, each of which were executives from Chicago based companies. The cars.com executive got into some technical detail covering Hadoop, and how it works, which was quite interesting.

The sessions I attended were led by excellent speakers. Oracle’s own John Clingan spoke to Java EE 7 and Java EE 8 in his first session. His talk detailed how Java EE has evolved over the years, and he discussed some of the ideas for the future of Java EE. Those ideas encompassed a JSON-B API, incremental enhancements to many of the other APIs, continued focus on HTML5, more focus on the cloud, and some key enhancements to Java EE security. Some of the security concepts looked quite interesting, as it may be possible in the future to utilize annotation based security, rather than configuration.

Next, I attended a session by Davinder Kohli entitled “Unclouding the Cloud”. In this session, we learned the inner workings of several private and public cloud infrastructures. He and his colleague then gave a demo of OpenStack, which was interesting, as we learned how easy it was to start and deploy new WordPress sites.

The lunch was great…good food and more great networking. I then gave a talk on Java EE 7 entitled “Java EE 7 Recipes”. The talk was well received, and I had quite a few people come and ask questions after the session. I learned that many people are still not very familiar with the new Java EE, but they remember how difficult J2EE was in the past. I will be giving a similar presentation at JavaOne...what would you like for me to cover??

The next session was an excellent presentation by Simon Maple entitled “Guide to JVM Languages”. In this session, he demoed Java 8 lambdas, functional interfaces, and default methods in a live-coding demonstration. He then covered how to use some similar features in Groovy, Scala, Kotlin, Ceylon, and Xtend. This session was great, as Simon is an excellent speaker who involved the audience throughout the session. We were able to compare each of the different languages, and learn a bit about each one. The overall concept was that the JVM has many great languages…we should try to learn a few of them.

The last session I attended was presented by John Clingan, and it was covering Project Avatar. Avatar.js is meant to be a node.js solution for the JVM. In fact, most node.js applications can now be run on the JVM using Avatar.js. John talked to the reasons why Oracle wanted to develop this solution, and why it was important for the community. Node.js users could port their applications, and make use of all Java libraries since they are on the JVM with Avatar.js. Many of the Java EE APIs are being wrapped in JavaScript so that they are accessible to clients using 100% JavaScript. Oracle knows that Knockout JS and Angular JS are leading the way in single page application frameworks…and they want to enable easy development against Java EE and other JVM technologies for these front end technologies.

Overall, this was an excellent conference. Kudos go out to the Chicago Java Users Group, and the Illinois Java Users Group for doing such a great job. Big thanks to Scott Kramer for nudging me to submit a presentation for this conference…it was a great time.

Tuesday, July 22, 2014

Work on the JavaServer Faces 2.3 Specification has begun. According to the specification summary:This JSR aims to improve the clarity of the existing JavaServer Faces(JSF) specification and introduce a small, targeted set of new featuresas directed by community contribution.To summarize, JSF 2.3 will target small scale new features, community driven improvements, and platform integration.Summary of features from the JSR text:- Ajax method invocation: Ability to make direct CDI method invocations from Ajax- Multi-field validation- Ability to @Inject FacesContext- EL Performance Optimizations- Cross-form Ajax Clarifications- Platform Integration: Ability to leverage platform features from Java EE 8 and Java SE 8Proposed TimelineQ3 2014 Expert Group formedQ1 2015 Early DraftQ3 2015 Public ReviewQ4 2015 Proposed Final DraftQ3 2016 Final ReleaseSpecification leads: Edward Burns and Manfred RiemJSR Text: https://java.net/downloads/javaserverfaces-spec-public/JSF_2_3/PreJsrFiling/20140706-jsf23-jsr.txtFollow @jsf_spec on Twitter for JSF 2.3 updates.

Wednesday, June 11, 2014

This year, I submitted three proposals for the JavaOne conference, which takes place September 28 - October 2nd in San Francisco. I am thrilled that two of them were accepted, and I am looking forward to presenting. Here are a few details on the selected submissions:

Session ID: CON2038
Session Title: Java EE 7 Recipes

Abstract:

Learn important features of Java EE 7 through a number of examples, using a hands on approach, including working code demonstrations. The examples are presented in a Problem, Solution, and How it Works recipe-style format, correlating usage of the APIs to real-life scenarios. The presentation introduces topics using an easy-to-understand approach, and the examples showcase new features of Java EE 7, as well as mature Java EE features. Recipes cover a variety of APIs from JSF to JPA to WebSockets, providing an overview of Java EE 7, along with examples using APIs together. The talk explains server-side resources using GlassFish 4.

Attendees will walk away with a solid understanding of some of the most important features of Java EE 7.

Session ID: CON2258
Session Title: Java EE 7 Recipes for Concurrency

Abstract:

This session will demonstrate how to make use of the Concurrency Utilities for Java EE using a hands on approach, including working code demonstrations. The examples will be presented in a Problem, Solution, and How it Works recipe-style format, which will correlate usage of the API to real-life scenarios. Attendees will learn how to make use of ManagedExecutorService, ManagedScheduledExecutorService, ContextService, and ManagedThreadFactory resources via practical examples. The talk will explain server-side resources and configuration via GlassFish, submitting tasks for asynchronous processing, and handling results. In the end, attendees will be able to go back to the office and start making use of the Concurrency Utilities.

I want to thank all of the JavaOne content reviewers for their hard work, and I appreciate the opportunity to present! I've seen lots of Twitter posts mentioning excellent sessions that have been selected from very prominent speakers. I am grateful to be included as a presenter at one of the best Java conferences in the world, and I am looking forward to seeing all of the great presentations from others.

Thursday, May 22, 2014

My day job involves heavy use of data. We use relational databases to store everything, because we rely on enterprise level data management. Sometimes it is useful to have the ability to extract the data into a simple format, such as a spreadsheet, so that we can manipulate it as-needed. This post outlines the steps that I've taken to produce a effective and easy-to-use JSF-based data export utility using PrimeFaces 5.0. The export utility produces a spreadsheet, including column headers. The user has the ability to select which database fields to export, and in which order they should be exported.

We want to ensure that we have a clean user interface that is intuitive. For that reason, I chose not to display any data on the screen. Rather, the user interface contains a PrimeFaces PickList component that lists the different data fields to choose from, along with a button to produce the export. Let's begin by setting up the database infrastructure to make this export utility possible.

For this post, I've enhanced the AcmePools application, which was developed via my article that was posted on OTN entitled PrimeFaces in the Enterprise. The export utility allows one to export customer data into a spreadsheet. The customer data is included in the sample database which is installed within Apache Derby by NetBeans, or you can use the SQL script for this post. To follow along with the creation of this export utility, please download or create the AcmePools project within your environment.

There are two parts to the data export utility, the first part being a PrimeFaces PickList component for the user to select which fields to export, and the second being an export button which will extract the selected field contents into a spreadsheet. The end result will resemble a user interface that looks like Figure 1.

Figure 1: Data Export Utility

Developing the PickList Component

To begin, create the data infrastructure to support the PickList component. This consists of a single database table to hold column names and labels for the entity data you wish to export, and optionally a database sequence to populate the primary key for that table. In this case, the database table is named COLUMN_MODEL, and we populate the table with the entity field names that correspond to the database column names for the CUSTOMER database table.

Next, create an entity class that can be used for accessing the column data from within the component. If you use an IDE such as NetBeans, this can be done very easily via a wizard. If using NetBeans, right click on the com.acme.acmepools.entity package, and select "New"-> "Entity Classes from Database", and then choose the data source for our sample database. When the list of tables populates, select the COLUMN_MODEL table, as shown in Figure 2. Lastly, choose "Next" and "Finish" to create the entity class.

Figure 2. NetBeans IDE New Entity Classes from Database

Once completed, the entity class entitled ColumnModel should look as follows:

Next, create an EJB session bean for the newly generated entity class so that the component can query the column data. You can use your IDE for this as well if you'd like. If using NetBeans, right-click on the com.acme.acmepools.session package, and select "New"->"Session Beans for Entity Classes". Once the dialog opens, select the entity class "com.acme.acmepools.entity.ColumnModel" from the left-hand list, and click "Finish" (Figure 3).

Figure 3: NetBeans IDE Session Beans for Entity Classes Dialog

After the session bean has been created, add a method named findId(), which can be used for returning the column id value based upon a specified column name. The full sources for the ColumnModelFacade should look as follows:

Next, create a some helper classes that will be utilized for loading and managing the data within the PickList component. The first class is named ColumnBean, and it is used to store the entity data, which is later passed off to the PickList for use. The code for ColumnBean is a simple POJO:<

The PickList component needs to use a PrimeFaces DualListModel for accessing and updating the data. Therefore, we must implement a class that can be used for coercing the entity data into our ColumnBean POJO, and then storing it into the DualListModel so that it can be utilized by the PickList component. In the following class, entitled PickListBean, the constructor accepts a List<ColumnModel>, which is the entity data as an argument, performs the coercion, and then stores it into a DualListModel<ColumnBean> collection for use by the component.

Lastly, we need to create a controller class to access all of this data. To do so, create a class named ColumnModelController within the com.acme.acmepools.jsf package, and make it a CDI managed bean by annotating it with @Named and @SessionScoped. Make the class implement Serializable. The initial controller class should look as follows (we will be updating it later to include methods to facilitate the export):

As you can see, the getColumns() method queries the ColumnModel entity, which populates the DualListModel<ColumnBean> via the PickListBean constructor.

That takes care of the database infrastructure and business logic...now let's look at the PrimeFaces component that is used for the PickList. The following excerpt, taken from the WebPages/poolCustomer/CustomerExport.xhtml view, contains the markup for the PickList component:

As you can see, the PickList is using columnModelController.columns for the data, which then uses the columnLabel field for displaying the names of the entity fields for export. The titles for the source and target PickList windows are customizable via a facet.

Adding the Export Functionality

Now that we've developed a functional pick list, we need to do something with the data that is selected. In this exercise, we will use a PrimeFaces DataExporter component to extract the data and store it into an Excel spreadsheet. In reality, we need to incorporate a DataTable into the view to display the data first, and then we can use the DataExporter component to export the data which resides in the table.

To construct the DataTable that will be used for displaying the data, we need to add a few methods to the ColumnModelController class. These methods will allow us to process the DataTable dynamically, so that we can construct columns based upon those that are chosen within the PickList. In reality, the DataTable will query all of the Customer data, and then it will only display those columns of data that are selected within the PickList. (We could modify this query by adding a filter, but that is beyond the scope of this post). To load the table with data, we simply call upon the com.acme.acmepools.jsf.CustomerController getItems() method to return all of the data.

Now let's add the necessary methods to the ColumnModelController so that we can dynamically construct the table. First, add a method that will be invoked when we click the "Export" button. This method will be responsible for building the currently selected column list:

The updateColumns() method binds a UIComponent to the table within the JSF view. It then has the capability of providing sorting, if elected. Subsequently, lets now look at the createDynamicColumns() method that is called upon.

The createDynamicColumns() method does a few things. First, it captures all of the selected columns from the PickList, and stores them into a String[] named columnKeys. To do this we use the helper method named getIncludedColumnsByName(), and split the results by comma. The sources for this method are as follows, and it basically grabs the currently selected columns from the PickListBean and appends each of them to a String, which is then returned to the caller.

Next, the createDynamicColumns() method then uses a loop to parse through each of the selected columns within the String[], and add them to the columnList, which going to be used to construct the DataTable with the appropriate columns.

Now let's take a look at the markup that is used to construct the DataExport utility:

As you can see, the DataTable is set to not render, because we really do not wish to display it. Instead, we wish to export its contents using the DataExporter component. To construct the DataTable dynamically, the columns call upon the columnModelController.dynamicColumns method to return the dynamic column list. This method looks as follows:

public List<ColumnModel> getDynamicColumns() {
return columns;
}

Within the DataExporter utility component, the columnModelController.preProcess method is assigned to the preprocessor attribute to initiate the dynamic column list. The target is set to the customerTable widget, which is the DataTable that we've dynamically constructed based upon the selected columns. In order to export this to an xls spreadsheet, you must add the org.apache.poi dependency within the Maven POM for the project, as follows:

<dependency>

<groupId>org.apache.poi</groupId>

<artifactId>poi</artifactId>

<version>3.7</version>

</dependency>

That's it...now you should have a fully functional data export utility using PrimeFaces components. The complete sources are available on GitHub using the link below. This code has been written in NetBeans IDE 8.0, and deployed to GlassFish 4.0. I utilized PrimeFaces 5.0 for this project.