Java and JSF howto blogs and code snippets
|
Using Rhinoslider with image and youtube content in JSF pages
Posted on Saturday May 04, 2013 14:44:17 Filed under HTML/JS/CSS category
|
|
|
Rhinoslider sample.
|
|
Rhinoslider is a beautiful JQuery slider plugin that can handle images, video and other HTML content with many custom options. Using the plugin in HTML pages is quite simple and straightforward. Their website even has a generator that will give you a code and start customizing the plugin from there. Here in this blog, we will demostrate how to integrate this plugin on images and youtube videos into a JSF page based on version 1.05 of the plugin. We will provide 2 options of embedding the plugin. Live demo is available in the home page with this site.
Listing 1 below, is a sample generated page. Please make sure that items from 6 to 11 of the snippet are accessible from the page itself. These items are part of the plugin download. If using PrimeFaces, you may want to remove lines 6 to 8. Also lines 10 and 11 are optional and are controlled by the values of "easing" and "controlsMousewheel" parameters of the plugin (see Listing 7).
Creating a Facebook-like panel with slim scrollbars and infinite scrolling in PrimeFaces
Posted on Friday February 08, 2013 11:40:40 Filed under Java/JSF category
Some of the Facebook panels with slim scrollbars and infinite scrolling are those non full-page panels used to display notifications and messages. These are activated by button-icons in the upper left corner of your timeline. In this blog, we will demonstrate how to create similar panels using slimScroll jQuery plugin in
PrimeFaces.
Please note that the first section of this blog (slimScroll panel without the infinite scrolling) also works for standard JSF projects.
Building a page with infinite scroll in PrimeFaces using Waypoints jQuery plugin
Posted on Friday December 21, 2012 17:55:02 Filed under Java/JSF category
Infinite scroll is a page feature where in data is automatically loaded as you scroll down to the bottom of a page. Facebook uses this feature in
their "news feeds".
This demonstration uses PrimeFaces with a jQuery plugin called WayPoints. Plugin download and documentation can be found here http://imakewebthings.com/jquery-
waypoints/. We employed PrimeFaces' <p:remoteCommand /> and <p:outputPanel /> along with Waypoints, the main component of the
process. It is Waypoints that initiates the update process that call <p:remoteCommand />, and in turn into the backing code, as soon
as a Waypoint element appears at the bottom of the page/viewport.
Validating an email address in PrimeFaces p:inputText field with p:ajax
Posted on Tuesday December 04, 2012 10:33:33 Filed under Java/JSF category
The example that follows demonstrates how to validate an email address inputted from a PrimeFaces <p:inputText /> field. It validates the
correctness of the email address as well as its existence. PrimeFaces version 3.4.1 was used to test this demonstration.
SSH tunneling with Java, a database connection example
Posted on Wednesday November 07, 2012 16:59:02 Filed under Java/JSF category
This blog is about using SSH tunnel in Java through jsch, a Java an implementation of SSH2. As an example, we connect to an MySQL installation in a remote host behind a firewall which not accessible from the outside. What an SSH tunnel does is forward accesses from a local port to a remote port on a remote host and transfer data in a secure manner.
First download jsch here http://www.jcraft.com/ and add it to your project. The only requirements are, you
have to have an SSH account on the remote host, and for the database example, a database account with a
"connect" permission.
Using Primefaces PrimePush with Tomcat 7
Posted on Thursday October 04, 2012 15:17:05 Filed under Java/JSF category
PrimePush comes bundled with PrimeFaces. It uses Atmosphere, a WebSocket/Comet framework for asynchronous server-browser communications.
Atmosphere however does not come with PrimeFaces out of the box. You need add to your project the necessary Atmosphere runtime libraries. In this blog we will show you how to get going with PrimePush in PrimeFaces 3.4.1 for use with Tomcat 7 (tested with Tomcat 7.0.27).
Write your own URL rewrite filter for existing JSF pages
Posted on Saturday April 07, 2012 19:49:39 Filed under Java/JSF category
This blog is based on our simple URL rewrite implementation for our existing JSF/PrimeFaces pages. As a demonstration, suppose you have an existing page with following URL pattern.
|
A dynamic standard sitemap.xml with Google image extension implemented as a Java Servlet
Posted on Wednesday March 06, 2013 19:57:25 Filed under Java/JSF category
A sitemap.xml generated on demand is very helpful for websites that has lots of pages and with pages that are added frequently. According to
Google, sitemaps help their crawlers find pages from websites. This is true for new websites or for pages that has fewer links to them.
The servlet herein described is based on sitemaps.org protocol with Google image extension. We used JDOM2 library to create the XML sitemap
structure. Below is how a standard sitemap looks like with the Google image extension. Please note that image extension is supported only by
Google. Bing/Yahoo ignores them.
Generating XML RSS 2 feeds with JDOM 2 with a servlet
Posted on Thursday January 31, 2013 15:03:52 Filed under Java/JSF category
To better demonstrate how to generate XML RSS 2 feeds, we will use a servlet with JDOM 2 library. In this short blog, we will generate only the
required elements plus a few options for feed reader interoperability. Please refer to the RSS 2 documentation for more of the optional elements and
to learn more about the RSS 2 specifications. JDOM 2 is available for download here http://www.jdom.org/.
Below is a sample RSS 2 feed generated by the servlet that follows further down (contents edited for clarity).
Implementing a collapsible ui:repeat rows in JSF
Posted on Wednesday December 19, 2012 15:35:45 Filed under Java/JSF category
Here is simple implementation of a JSF <ui:repeat /> component with collapsible rows with the aid of JQuery.
It is very simple, no specials tricks, except that the components inside <ui:repeat /> must have a unique ID (or class) which is handled by the
backing code. Toggling the visibility of the frame (<div />) is taken cared of by the onclick
event on the link, in this case <h:outputLink />
Download and crop an image direct from a servlet
Posted on Tuesday November 13, 2012 17:10:45 Filed under Java/JSF category
This blog is a demonstration on how to download an image and crop them directly just before the servlet writes the image into the
response. This is useful in instances where you don't want the downloaded image saved before they are consumed.
The following is that servlet, it takes two parameters, the url of the image, and the image type. Add parameters as your
application may require. Please refer to the inline comments for more information.
Asynchronous tasks in JSF applications
Posted on Tuesday October 16, 2012 21:27:23 Filed under Java/JSF category
This is an example on how to implement concurrency in JSF applications using the Executor framework.
We used, in our example below, java.util.concurrent.ThreadPoolExecutor as a static instance that is created and destroyed from the
init and destroy events listened to by javax.servlet.ServletContextListener of our application. ThreadPoolExecutor execute threads
from a queue of Runnable or java.util.concurrent.Callable using an unbounded java.util.concurrent.LinkedBlockingQueue
that holds the tasks submitted by clients for execution.
Speed up Primefaces page load with p:remoteCommand partial update
Posted on Wednesday June 06, 2012 22:41:37 Filed under Java/JSF category
Consider a Primefaces page with many components and one of the components in the page takes time to load may be because it loads a lot of data or
the backing code of the component connects to slow servers. As a result the entire page is blocked and not visible to the user until that one
component loads completely.
We overcome this scenario by using Primefaces' p:remoteCommand.
|
|
|
|
|