JSF: Lesson – 1: JSF Specifications #Java Short Notes

  • Video Demonstration of a sample JSF application create: Read the article first
    • JSF Specifications
    • JSF is not standalone technology, you have to use it in conjunction with JSPs, Servlets, EJBs
    • How to use JSF with Servlets and EJBs: In Servlet or EJB, explicitly create instances of UI components and use the UI classes directly
    • JSF with JSPs: Use the JSF custom tag library with JSP
    • To use JSF, you need to understand JSF lifecycle: take a look at JSF Lifecycle: Restore view, Apply request values, Process validations, Update model values, Invoke application, Render response
    • How to install JSF: Current version of Sun’s Application Server contains JSF and JSTL
    • For Tomcat 5.5:
      • Download JSF from http://java.sun.com/j2ee/javaserverfaces/download.html and JSTL from http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html.
      • Put these Six JSF JARs into your project WEB-INF/lib folder or tomcat lib folder: commons-beanutils.jar, commons-collections.jar, commons-digester.jar, commons-logging.jar, jsf-api.jar, and jsf-impl.jar
      • Download JSF Jars
      • Put these two JSTL JARs in the same way: jstl.jar and standard.jar
    • JSF provides different custom actions as will be provided below:
    • You can use these elements/controls/actions to collect user data, to display output, to validate user inputs, control the flow of the application dynamically/statically also, convert data from one type to another.
    • HTML Custom Actions
      Input: To create input elements
      h:inputHidden, h:inputSecret,h:inputText, h:inputTextarea

      Output:create output elementsh:message, h:messages,h:outputFormat, h:outputLabel,h:outputLink, h:outputText
      Selection: Create selection elements like combo boxesh:selectBooleanCheckbox,h:selectManyCheckbox,h:selectManyListbox,h:selectManyMenu,h:selectOneListbox,h:selectOneMenu,h:selectOneRadio
      Commands: Create form submission buttons or links
      h:commandButton,h:commandLink
      Miscellaneous
      h:dataTable, h:form,h:graphicImage, h:panelGrid,h:panelGroup, h:column

    • JSF Core custom actions:

      Converters:Standard
      f:convertDateTime,f:convertNumber, f:converter
      Listeners:Listener for a component
      f:actionListener,f:valueChangeListener
      Miscellaneous
      f:attribute, f:loadBundle,f:param, f:verbatim
      Selection
      f:selectItem, f:selectItems
      Validators:Standard
      f:validateDoubleRange,f:validateLength ,f:validateLongRange ,f:validator
      View: Create JSF view or sub-view
      f:facet, f:subview, f:view

    • An example of JSF with JSP with Managed Bean Support
      • You need a configuration file like faces-config.xml , or you can use any other file but you have to supply the file name in the web.xml file.
      • To use a managed bean, you need to define a managed bean in the JSF configuration file with a name, class, and scope
      • Also you need to define navigation rules in the configuration file. A navigation-rule defines the start page, a condition, and which page to navigate to when the condition occurs
      • Create the managed bean class
      • In your JSP, you should refer to the JSF tag libs and JSTL tag libs by
      • Then in the JSP page you will be able to use the JSF tags and the managed beans directly
      • A sample example with code
      • Video Demonstration of the example JSF application create
      • Details about other JSF features like: using managed beans, controlling page navigation, accessing JSF context data in beans, converting data, validating user inputs, using message bundles to support internationalization will be disucssed in another article.
  • From: http://sitestree.com/?p=4991
    Categories:Java Short Notes
    Tags:
    Post Data:2012-10-30 13:33:53

    Shop Online: https://www.ShopForSoul.com/
    (Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
    In Bengali: http://Bangla.SaLearningSchool.com
    http://SitesTree.com
    8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
    Shop Online: https://www.ShopForSoul.com/
    Medium: https://medium.com/@SayedAhmedCanada