Jsf Utility : JavaServer Faces « J2EE « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » J2EE » JavaServer FacesScreenshots 
Jsf Utility
 
/*
 * BEGIN_HEADER - DO NOT EDIT
 
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the "License").  You may not use this file except
 * in compliance with the License.
 *
 * You can obtain a copy of the license at
 * https://open-jbi-components.dev.java.net/public/CDDLv1.0.html.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * HEADER in each file and include the License file at
 * https://open-jbi-components.dev.java.net/public/CDDLv1.0.html.
 * If applicable add the following below this CDDL HEADER,
 * with the fields enclosed by brackets "[]" replaced with
 * your own identifying information: Portions Copyright
 * [year] [name of copyright owner]
 */

/*
 * @(#)JsfUtility.java 
 *
 * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
 
 * END_HEADER - DO NOT EDIT
 */


import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;


public class JsfUtility {

    protected JsfUtility() {
        super();
    }

    /**
     * Helper method to set value expression property.
     *
     @param component The UIComponent to set a value expression for.
     @param name The name of the value expression property.
     @param expression The expresion for the value expression.
     */
    public static void setValueExpression(UIComponent component, String name, 
            String expression) {
        if (expression == null) {
            return;
        }
        FacesContext context = FacesContext.getCurrentInstance();
        component.setValueExpression(name, createValueExpression(
    context, expression, Object.class));
    }
    
    /**
     * Helper method to set a method expression property.
     * Create a method expression that returns String and has no
     * input paramaters.
     *   
     @param component The UIComponent to set a value binding for.     
     @param name The name of the method expression property
     @param expression The expression to create.
     */
    public static void setMethodExpression(UIComponent component,
      String name, String expression) {
  setMethodExpression(component, name, expression,
    Object.class, new Class[0]);
    }
    /**
     * Helper method to set a method expression property.
     *   
     @param component The UIComponent to set a value binding for.     
     @param name The name of the method expression property
     @param expression The expression to create.
     */
    public static void setMethodExpression(UIComponent component,
      String name, String expression, Class out, Class[] in) {
        if (expression == null) {
            return;
        }
        FacesContext context = FacesContext.getCurrentInstance();
        component.getAttributes().put(name, 
      createMethodExpression(context, expression, out, in));
    }

    public static MethodExpression createMethodExpression(
      FacesContext context, String expr, Class out, Class[] in) {

  return context.getApplication().getExpressionFactory().
      createMethodExpression(context.getELContext(), expr, out, in);
    }

    public static ValueExpression createValueExpression(
      FacesContext context, String expr, Class value) {

  return context.getApplication().getExpressionFactory().
      createValueExpression(context.getELContext(), expr, value);
    }
}

   
  
Related examples in the same category
1. Change Bean Property
2. Hello World JSF
3. JavaServer Faces
4. jsf jpa war
5. Gathers all select items from specified component's children
6. Converts UISelectMany submitted value to converted value
7. Simple utility class for CSS style formatting
8. Common static utility methods that help in implementing JSF tags
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.