Saturday, December 22, 2012

How to use jQuery star rating in JSF2

This post is to show how to use jQuery star rating in JSF2.

for native JSF2 implementation, please perform Adding jQuery capabilities into JSF2.
for Richfaces, make sure jQuery is working by verify jQuery in Richfaces 4 is working

Required software:
1. jQuery star rating plugin

Pre-requisite
1. JSF2/Richfaces application properly setup
2. jQuery plugin working properly in Richfaces 4



Steps:
1. put all the content of star rating into resources folder
putting star rating library into JSF project

2. invoking star rating with the following codes in xhtml
invoking star rating

3. capture the value in JSF managedBean
capturing star rating value in managedBean
4. If this is a portlet application, replace the HttpServletRequest with HttpPortletRequest.

you may also take a look on Setting jQuery Star Rating value when loading a page

and you might also interesting on How to install jQuery plugin in Richfaces 4

Done!!

6 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. can i see the content of your bean class?

    ReplyDelete
    Replies
    1. You may take a look on http://kianworknotes.blogspot.com/2012/12/setting-jquery-star-rating-value-when.html, if you still have queries, please let me know.

      Thanks

      Delete
    2. Thanks for the reply Kian.
      Im working in Seam + JSF Portlet for drug discoveries project.
      Sorry for bothering you with questions
      I want to know where did you put this business logic code:

      FacesContext context = FacesContext.getCurrentInstance();
      String star1 = ((HttpServletREquest)context.getExternalContext().
      getRequest()).getParameter("star1");

      In my case,all the business logic I did in 1 action class.So,do I need to put the above code in my action class?

      I also want to ask whether can I use my existing Bean class which includes rating field inside it.

      Thanks in avance.

      Delete
    3. Yes, the above codes i put in a method of my managedBean class.
      eg,
      public void retrieveRatingValue() {
      FacesContext context = FacesContext.getCurrentInstance();
      String star1 =
      ((HttpServletREquest)context.getExternalContext().
      getRequest()).getParameter("star1");

      ................
      ................
      }

      It can be put inside any method of your managedBean.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...