Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Development Guide for JSF component Model

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on the "JSF component model development guide", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn the "JSF component model development guide"!

JSF component model

The JSF component model is similar to the AWT GUI component model. It has events and properties, just like the Swing component model. It also has containers that contain components, which are also components, and can also be contained by other containers. Theoretically, the JSF component model is separated from HTML and JSP. JSF comes with a standard set of components that contains JSP bindings to generate HTML renderings.

Examples of JSF components include calendar input components and HTML rich text input components. You may never have time to write such components, but what if they already exist? By turning common functions into commodities, the component model lowers the bar for adding more functionality to Web applications.

The function of a component usually revolves around two actions: decoding and encoding data.

◆ decoding (decoding) is the process of converting incoming request parameters into the value of a component.

◆ encoding (encode) is the process of converting the current value of a component into the corresponding tag (that is, HTML). The JSF framework provides two options for encoding and decoding data, using direct implementation, the component implements decoding and encoding by itself, and using delegated implementation, the component entrusts the renderer to encode and decode.

If you choose a delegate implementation, you can associate components with different renderers and render components in different ways on the page, such as multiple list boxes and a column of check boxes. Therefore, the JSF component consists of two parts: the component and the renderer. The JSF component class defines the state and behavior of the UI component; the renderer defines how to read the component from the request and how to display the component-- usually rendered through HTML. The renderer converts the value of the component to the appropriate tag. Event queuing and performance verification occur within the component.

All JSF component models are UIComponent. When developing your own components, you need to inherit UIComponentBase, which extends UIComponent and provides a default implementation of all abstract methods in UIComponent. The component has parents and identifiers. Each component is associated with a component type that is used to register the component in the context configuration file (faces-config.xml) of the face. You can use JSF-EL (expression language) to bind JSF components to managed bean properties. You can associate an expression to any property on a component, which allows you to set the property value of the component with JSF-EL. When creating component properties that use JSF-EL binding, you need to create a value binding expression. When calling the getter method of a bound property, the getter method must obtain a value with a value binding unless the setter method has already set a value. Components can be used as ValueHolder or EditableValueHolder. ValueHolder is associated with one or more Validator and Converter; so JSF UI components are also associated with Validator and Converter

Components such as the form field component have a ValueBinding that must be bound to the read and write properties of the JavaBean. Components can call the getParent method to access their parents, or they can call the getChildren method to access their children. A component can also have a facet component, which is a child of the current component and can be accessed by calling the getFacets method, which returns a mapping. Facets is a famous sub-component.

The concepts of many of the components described here will be part of the examples shown next, so keep them in mind!

LoginComponent of the JSF component

Here are the steps I'm going to take:

1. Extend UIComponent to create a class that extends UIComponent to save the component state and register the component with faces-config.xml

two。 Create custom tags, inherit UIComponentTag, override encode, override decode, and register the renderer with faces-config.xml

3. Define the renderer or implement it inline, return the renderer type, return the component type, and set properties that might use JSF expressions

At this point, I believe you have a deeper understanding of the "JSF component Model Development Guide". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report