Javax.faces.component.actionsource2 jar file
APIs for attaching additional behavior to user interface components. Specialized user interface component classes for HTML. APIs for traversing a user interface component view. Classes and interfaces defining per-request state information.
Contains classes and interfaces defining converters. Interfaces describing events and event listeners, and concrete event implementation classes. Classes and interfaces defining the rendering model. Interface defining the validator model, and concrete validator implementation classes. Classes required for integration of JavaServer Faces into web applications, including a standard servlet, base classes for JSP custom component tags, and concrete tag implementations for core tags.
ActionSource is an interface that may be implemented by any concrete UIComponent that wishes to be a source of ActionEvent s, including the ability to invoke application actions via the default ActionListener mechanism. A simple callback interace that enables taking action on a specific UIComponent either facet or child in the view while preserving any contextual state for that component instance in the view. EditableValueHolder is an extension of ValueHolder that describes additional features supported by editable components, including ValueChangeEvent s and Validator s.
NamingContainer is an interface that must be implemented by any UIComponent that wants to be a naming container.
Components that want to leverage the partial state saving feature must implement this interface instead of implementing StateHolder , from which this interface inherits. Define a Map -like contract that makes it easier for components to implement PartialStateHolder.
This interface is implemented by classes that need to save their state between requests. Define a Map -like contract that makes it easier for components to implement TransientStateHolder. This interface is implemented by classes that need to save state that is expected to be available only within the scope of the current request.
UIComponentBase is a convenience base class that implements the default concrete behavior of all methods defined by UIComponent. Because MapComponent is a parent component of AreaComponent , the area tags must be rendered after the beginning map tag and before the ending map tag. To accomplish this, the MapRenderer class renders the beginning map tag in encodeBegin and the rest of the map tag in encodeEnd.
If a component needs to perform the rendering for its children, it does this in the encodeChildren method. Here are the encodeBegin and encodeEnd methods of MapRenderer :. Notice that encodeBegin renders only the beginning map tag. The encodeEnd method renders the input tag and the ending map tag. The encoding methods accept a UIComponent argument and a javax. FacesContext argument. The FacesContext instance contains all the information associated with the current request.
The UIComponent argument is the component that needs to be rendered. The rest of the method renders the markup to the javax. ResponseWriter instance, which writes out the markup to the current response. This basically involves passing the HTML tag names and attribute names to the ResponseWriter instance as strings, retrieving the values of the component attributes, and passing these values to the ResponseWriter instance.
The startElement method takes a String the name of the tag and the component to which the tag corresponds in this case, map.
Passing this information to the ResponseWriter instance helps design-time tools know which portions of the generated markup are related to which components. The writeAttribute method takes the name of the attribute, its value, and the name of a property or attribute of the containing component corresponding to the attribute. If you want your component to perform its own rendering but delegate to a renderer if there is one, include the following lines in the encoding method to check whether there is a renderer associated with this component:.
The MapComponent class delegates all rendering to MapRenderer , so it does not need to check for available renderers. In some custom component classes that extend standard components, you might need to implement other methods in addition to encodeEnd. During the Apply Request Values phase, the JavaServer Faces implementation processes the decode methods of all components in the tree. Converter implementation to convert the value to a type that is acceptable to the component class.
A custom component class or its renderer must implement the decode method only if it must retrieve the local value or if it needs to queue events. The component queues the event by calling queueEvent. It then uses that name as the key to the request parameter map to retrieve the current value of the input field. This value represents the currently selected area. Nearly all the attributes of the standard JavaServer Faces tags can accept expressions, whether they are value expressions or method expressions.
It is recommended that you also enable your component attributes to accept expressions because it gives you much more flexibility when you write Facelets pages.
To enable the attributes to accept expressions, the component class must implement getter and setter methods for the component properties.
These methods can use the facilities offered by the StateHelper interface to store and retrieve not only the values for these properties but also the state of the components across multiple requests. For both components, the simple getter and setter methods store and retrieve the key values and state for the attributes, as shown in this code fragment from AreaComponent :.
Because the Back button relies on the backButton style rule defined in stylesheet. This can be avoided by setting prependId to false. Enter a number in the welcome page, then click Submit. Click the Back button. If you cannot see the number in the server log, try rebuilding the application by right-clicking the project node and choosing Clean and Build. Type in the correct number and click Submit. The application compares your input with the currently saved number and displays the appropriate message.
Click the Back button again. Notice that the previously entered number is no longer displayed in the text field. Facelets has become the standard display technology for JSF 2. Facelets is a light-weight templating framework that supports all of the JSF UI components and is used to build and render the JSF component tree for application views. It also provides development support when EL errors occur by enabling you to inspect the stack trace, component tree, and scoped variables.
Although you may not have realized it, the index. Facelets pages use the. The purpose of this section is to familiarize you with Facelets templating. For projects containing many views, it is often advantageous to apply a template file that defines the structure and appearance for multiple views.
When servicing requests, the application inserts dynamically prepared content into the template file and sends the result back to the client. Although this project only contains two views the welcome page and the response page , it is easy to see that they contain a lot of duplicated content.
You can factor out this duplicated content into a Facelets template, and create template client files to handle content that is specific to the welcome and response pages.
This section makes use of these wizards. Create a Facelets template file. Choose from any of the eight layout styles and click Finish. You will be using the existing stylesheet, so it does not matter which layout style you choose. The wizard generates the template.
After completing the wizard, the template file opens in the editor. To view the template in a browser, right-click in the editor and choose View.
The tag library has the ui prefix. By using these tags, Facelets is able to construct a component tree that encompasses the entire page. For example:. Reexamine the welcome and response pages. The only content that changes between the two pages is the title and the text contained in the grey square. The template, therefore, can provide all remaining content. Copy relevant code from either the index.
The project now contains a template file that provides the appearance and structure for all views. You can now create client files that invoke the template. Create template client files for the welcome and response pages. Name the template client file for the welcome page greeting. For the response page, the file will be response.
Click the Browse button next to the Template field, then use the dialog that displays to navigate to the template. The new greeting. Specify greeting as the title for the file. Make the following change in bold.
Switch to the index. Then switch back to greeting. Then select the tag from the list of code completion suggestions. If only one logical option is available when pressing Ctrl-Space, it is immediately applied to the file.
JSF tag libraries are automatically declared when invoking code completion on tags. Because the project already contains a file named response. For purposes of this tutorial, just copy and paste the provided code.
Open response. If it is already opened, press Ctrl-Tab and choose it. Replace the contents of the entire file with the code below. Note that the file is identical to greeting. The project is deployed to the GlassFish server, and opens in a browser.
Using the Facelets template and template client files, the application behaves in exactly the same way as it did previously. This can make development more efficient and easier to maintain when working in large projects.
Send Feedback on This Tutorial. JavaServer Faces Technology Official homepage. Apache NetBeans. Latest release. Introduction to JavaServer Faces 2. Makes it easy to construct a UI from a set of reusable UI components Simplifies migration of application data to and from the UI Helps manage UI state across server requests Provides a simple model for wiring client-generated events to server-side application code Allows custom UI components to be easily built and re-used.
To complete this tutorial, you need the following software and resources. Adding JSF 2. Click the Submit button. The response page response. Select the Frameworks category and then click the Add button. Click OK. Click OK to finalize changes and exit the Project Properties window. ManagedBean; import javax. Creating a Constructor The UserNumberBean constructor must generate a random number between 0 and 10 and store it in an instance variable.
Figure 8. Adding Properties The Facelets pages that you create in the next section will need to access the number that the user types in, and the generated response. Start by declaring an Integer named userNumber. Select the userNumber : Integer option. Click Generate.
0コメント