terça-feira, 18 de setembro de 2007

Default Action for a JSF Form

Description

The current JSF-RI implementation does not allow to you to define the default action in case the user submits the form by pressing the Enter key instead of clicking the action button explicitly. As a result, the form action becomes undefined and the current page is just reloaded. Developers have to write additional javascript code to prevent such undesirable behavior.

The j4j:defaultAction custom component included in the j4j tag libraries allows you to define the default action for a form by adding as a child tag to the commandButton tag.

PS: This component was writen before even first version fo Firefox is released. This is a code that works also in FireFox. function trapEnter(evt) { var keycode; if (evt) ; else if (window.event) evt = window.event; else if (event) evt = event; else return true; if (evt.charCode) keycode = evt.charCode; else if (evt.keyCode) keycode = evt.keyCode; else if (evt.which) keycode = evt.which; else keycode = 0; if (keycode == 13) { document.getElementById('form:save').click(); return false; } else return true; }

How to Download

Download the compiled code using this URL: j4j.jar (4 K)

How to Use

1. Put the j4j.jar file in the WEB-INF/lib folder of your project.

2. Add the following declaration at the top of the page:

... taglib uri="http://javascript4jsf.dev.java.net/" prefix="j4j" ...

3. Add the j4j:defaultAction component as an empty child element of the commandButton that you want to make a default button.

Source Code

Here is the part of the library structure in j4j.jar that relates to this component:

The boldfaced code shows how to insert a reference to the proxy component in the faces-config.xml file:


   
 
org.j4j.defaultAction
org.j4j.components.UIDefaultAction


Here is the content of the j4j.tld file:


retirados de http://www.jsftutorials.net/defaultActionTag.html

segunda-feira, 17 de setembro de 2007

Dicas para execução do eclipse

retirado de http://wiki.eclipse.org/index.php/FAQ_How_do_I_run_Eclipse%3F

Eclipse 3.3

When you unzip the Eclipse SDK, it creates a base install directory called eclipse. The directory layout looks something like this:

   eclipse/
     features/   ''the directory containing Eclipse features''
     plugins/   ''the directory containing Eclipse plugins''
     eclipse.exe  ''platform executable''
     eclipse.ini
     eclipsec.exe              ''(windows only) console executable''
     epl-v10.html  ''the EPL license''
     eclipse.ini 
     jre/   ''the JRE to run Eclipse with''
     notice.html 
     readme 

You can start Eclipse by running eclipse.exe on Windows or eclipse on other platforms. This small launcher essentially finds and loads the JVM that is on your PATH. On Windows, the eclipsec.exe console executable can be used for improved command line behaviour.

Alternatively, you can launch Eclipse by directly invoking the JVM as follows:

   java -jar eclipse/plugins/org.eclipse.equinox.launcher_1.0.0.v20070606.jar

NOTE: The version of org.eclipse.equinox.launcher in the above command must match the version actually shipped with Eclipse. For more details on launching Eclipse using Java (not eclipse.exe) with the 3.3 launcher, see Starting Eclipse Commandline With Equinox Launcher.

Dicas JavaServer Faces

retirados de: http://www.oracle.com/webapps/online-help/jdeveloper/10.1.3?topic=sf_ajsfwebxml_html

Part of a JSF application's configuration is determined by the contents of its J2EE application deployment descriptor, WEB-INF/web.xml . JDeveloper automatically creates the web.xml file when you create a JSF page or document, and initializes the JSF configuration to default settings. You can then modify these settings for your particular application.

For more information about the web.xml file, see About Web Module Runtime Configuration. For information about configuring web.xml for ADF Faces, see About Configuring web.xml for ADF Faces.

Three web.xml elements contain JSF-related configuration settings:

  • <context-param> - sets parameters for the JSF application
  • <servlet> - maps the JSF servlet to a symbolic name
  • <servlet-mapping> - maps the JSF servlet symbolic name to a URL pattern
Use to set application-wide JSF parameters. The syntax is:

    parmName
   parmValue        
where
parmName
is the parameter's symbolic name
parmValue
is the value you wish to set for the parameter

The following parameters are available in JSF:

javax.faces.CONFIG_FILES
Use: Specifies paths to JSF application configuration resource files. Value: A comma-separated list of application-context-relative paths.
javax.faces.DEFAULT_SUFFIX
Use: Specifies a file extension (suffix) for JSP pages that contain JSF components. The default is .jsp . Value: A file extension
javax.faces.LIFECYCLE_ID
Use: Selects a lifecycle identifier other than the default set by the javax.faces.lifecycle.LifecycleFactory.DEFAULT_LIFECYCLE constant. Value: Lifecycle identifier
javax.faces.STATE_SAVING_METHOD
Use: Selects a state saving method. Value: Either server or client. The default is server, which stores the application's view state on the server. If you select client, JSF stores the view state on the browser client.
Use: Maps the JSF servlet javax.faces.webapp.FacesServlet to a symbolic name. Value: Symbolic name. For example, to use myServlet as the symbolic name, add the following to web.xml:

 myServlet
 javax.faces.webapp.FacesServlet
        
Use: Maps URL patterns to the JSF servlet's symbolic name. Value: URL pattern. You can use either a path prefix or extension suffix pattern:
path prefix
provides a mapping to the JSF servlet. All URLs in the application would contain this prefix in their path. For example, http://localhost:8080/login/faces/index.jsp

 faces-servlet-name
 /faces/*
              
extension suffix
provides an extension to which the servlet maps JSPs that include JSF content. For example, http://localhost:8080/login/index.faces

 faces-servlet-name 
 *.faces