Saturday, May 17, 2014

How to integrate SlidesJS into JSF2

SlidesJS is an image slider that is nice and easy to implement.
To implement SlidesJS into JSF2.x application, just need to download the required files and follow the steps below.

1. copy all the required files into resources folder.

2. include the following css into the target xhtml page or .css file

/* Prevents the slideshow from flashing on load */
#slides {
#slides .slidesjs-container {
#slides .slidesjs-previous {
  margin-right: 5px;
#slides .slidesjs-next {
  margin-right: 5px;
.slidesjs-pagination {
    margin:6px 0 0;
    float: right;
    list-style: none;
.slidesjs-pagination li {
    float: left;
    margin: 0 1px;
.slidesjs-pagination li a {
    display: block;
    width: 13px;
    height: 0;
    padding-top: 13px;
    background-image: url(/MY_APP_NAME/resources/jquery/slides/pagination.png);
    background-position: 0 0;
    float: left;
    overflow: hidden;
.slidesjs-pagination li, .slidesjs-pagination li { background-position: 0 -13px; }
.slidesjs-pagination li a:hover { background-position: 0 -26px; }
#slides a:link, #slides a:visited { color: #333; }
#slides a:hover, #slides a:active { color: #9e2020; }
replace the MY_APP_NAME to the target JSF application name.

3. add the following line into the target xhtml
<h:outputScript library="jquery/slides" name="jquery.slides.js" />

4. add the following javascript into the target xhtml
    $(function() {
        width: 940,
        height: 528,
        navigation: {
          effect: "fade"
        pagination: {
          effect: "fade"
        effect: {
          fade: {
            speed: 400

5. add the following code block into the target xhtml
<div id="slides">
<img src="img/example-slide-350-1.jpg" alt="Photo by: Missy S Link:">
<img src="img/example-slide-350-2.jpg" alt="Photo by: Daniel Parks Link:">
<img src="img/example-slide-350-3.jpg" alt="Photo by: Mike Ranweiler Link:">
<img src="img/example-slide-350-4.jpg" alt="Photo by: Stuart SeegerLink:">
<a href="#" class="slidesjs-previous slidesjs-navigation"><i class="icon-chevron-left icon-large"></i></a>
<a href="#" class="slidesjs-next slidesjs-navigation"><i class="icon-chevron-right icon-large"></i></a>

p/s: the red highlighted section can be replaced by any <img /> tag to display our desired pictures instead of the demo pictures.

reference: more jQuery image slider here.



Related Posts Plugin for WordPress, Blogger...