S U N D A R R A J A N

Google Search Engine

Friday, December 30, 2011

JSF Standards


JSF Standards:·
  • 1. Go for  “XHTML”  instead of “jsp”
    • XHTML is XML compatible, if use JSP extra overhead will be there for converting into DOM. 
  • 2. Go for “facelets”
    •  There is a viewhandler for JSF also as like other frameworks. The drawback in the JSF view handler is, there is no configurable support for multiple view in the JSF application.
    • Facelets: The mismatch between JSF and JSP technology is a serious problem in JSF development. The issue is how to integrate JSP’s dynamic content into JSF’s component-based model. JSP is singularly focused on generating dynamic output, whereas JSF requires JSP to coordinate building a component model. Facelets will overcome this. Facelets has several compelling features:-         
    • Facelets saves JSF from the burden of JSP - Great for templating and composition components plus bonuses like el functionsCreating component libraries-          No tld files and no tag classes to define a UIComponent
    • <%@ taglib uri=”http://java.sun.com/jsf/html” prefix=”h”%/>          
    • Will be written as  
    • http://www.w3.org/1999/xhtmlxmlns:h=”http://java.sun.com/jsf/html” >         
  • 3. Try to reuse the HTML components except for the component will needs to be binded in the backing beans. Data binding will not happen for the HTML components.
  • 4. Id is not mandatory conceptually but it is mandatory for developing websites and it should be meaningful and unique.
  • 5. Don’t use special charactersIf you want display special characters use Unicode or < h:outputText  value=” ”  escape=”false” /> ·        
  • 6. Don’t use JSTL tags (like c:if , c:for …), use rendered tags instead (UI:repeat instead of c:for). Place java script in separate file. Consolidate the java script function and have it as a separate JS file instead of adding functions in the head part of the page. ·        
  • 7. Don’t use style attribute to define styles, use styleClass and define those style classes in separate file and use them when you required. Do not use in-line styles. ·        
  • 8. Avoid changing the value of the fields dynamically using java script functions. ·        
  • 9. Do not use JSTL tags until it’s mandatory·        
  • 10. All the non JSF components should be inside tag.·        
  • 11. Use subview tag if we have are including another page in to the parent page.
Best practices:·
        
Use Neko parser for converting into XML DOM we can configure this in the in the web.xml context param. This is the parser used for parsing the XML in the AJAX call. This is used with Richfaces framework. Since we are going to made the ajax call using jquery, we will not be using this. Neko parser extends SAX parser and it is faster compared to others·        
State saving methodology
  • Client: Use this when you have more forms , navigations in the same page or AJAX code etc..
  • Server: otherwise go for server side. Use server. ·
Property file in JSF application:

Don’t use instead go for configuration in faces-context.xml

tag is used to load the recourse bundle and store it as a map in the request scope.  
Loading property file with :

JSF 1.1and 1.2 supports f:loadBundle feature Loading property file using faces-config.xml     

1.  If the properties file is present in WEB-INF/classes/com/test/resource/messages.properties:                          
                            
                                   
     com.test.resource.messages                        
        msgs
                           
       
2. Once loaded, message strings can be accessed using the value expression #{varName.keyName}. The advantage is it will load property file only once.  For managed beans use appropriate scope  

Is this bolg useful?

Rate

S U N D A R R A J A N

Followers