<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    銀色幻想

    常用鏈接

    統計

    積分與排名

    學習交流

    最新評論

    JSF中BackingBean的管理

    Backing Bean Management

    Another critical function of Web applications is proper management of resources. This includes separating the definition of UI component objects from objects that perform application-specific processing and hold data. It also includes storing and managing these object instances in the proper scope.
    web應用中另一個關鍵的功能就是適當的管理資源。這包括將UI組件對象的定義和處理應用程序指定的功能和保存數據的對象分開。它還包括在適當的范圍中保存和管理這些對象實例。

    A typical JavaServer Faces application includes one or more backing beans, which are JavaBeans components (see java/j2eetutorial14/doc/JSPIntro8.html#wp70711">JavaBeans Components) associated with UI components used in a page. A backing bean defines UI component properties, each of which is bound to either a component's value or a component instance. A backing bean can also define methods that perform functions associated with a component, including validation, event handling, and navigation processing.
    一個典型的JSF應用包括一個或多個后臺bean,在頁面中,這是和UI組件有關聯關系的JavaBeans組件。一個后臺bean定義了UI組件的屬性,每一個屬性都綁定到組件的值或者實例。一個后臺bean也可以定義和組件相關,并執行一定功能的方法,包括驗證,事件處理,導航處理。

    To bind UI component values and instances to backing bean properties or to reference backing bean methods from UI component tags, page authors use the JavaServer Faces expression language (EL) syntax. This syntax uses the delimiters #{}. A JavaServer Faces expression can be a value-binding expression (for binding UI components or their values to external data sources) or a method-binding expression (for referencing backing bean methods). It can also accept mixed literals and the evaluation syntax and operators of the JSP 2.0 expression language (see java/j2eetutorial14/doc/JSPIntro7.html#wp71019">Expression Language).
    如果要綁定UI組件的值和實例到后臺bean的屬性或者通過UI組件的標記引用后臺bean的方法,那么頁面開發者需要使用JSF表達式語言語法。這種語法使用“#{}”指示符。一個JSF的表達式可以是值綁定的(綁定UI組件或者他們的值到外部數據源)或者方法綁定(引用后臺bean的方法)。它也可以使用JSP2.0中的語法。

    To illustrate a value-binding expression and a method-binding expression, let's suppose that the userNo tag of the guessNumber application referenced a method that performed the validation of user input rather than using the LongRangeValidator:
    為了演示值綁定表達式和方法綁定表達式,讓我們假設guessNumber應用的userNo標記引用了一個方法來作驗證,而不是使用LongRangeValidator。
    <h:inputText id="userNo"
      value="#{UserNumberBean.userNumber}"
      validator="#{UserNumberBean.validate}" />

    This tag binds the userNo component's value to the UserNumberBean.userNumber backing bean property. It also refers to the UserNumberBean.validate method, which performs validation of the component's local value, which is whatever the user enters into the field corresponding to this tag.
    這個標記將userNo組件的值綁定到UserNumberBean.userNumber后臺bean的屬性,這個方法對組件的本地值進行了驗證。

    The property bound to the component's value must be of a type supported by the component. For example, the userNumber property returns an Integer, which is one of the types that a UIInput component supports, as shown in java/j2eetutorial14/doc/JSFIntro5.html#wp114980">Developing the Beans.
    屬性綁定到組件的值必須是組件支持的數據類型。例如,userNumber屬性返回一個Integer,這是一個UIInput支持的數據類型。

    In addition to the validator attribute, tags representing a UIInput can also use a valueChangeListener attribute to refer to a method that responds to ValueChangeEvents, which a UIInput component can fire.
    除了validator屬性之外,UIInput標記還可以使用valueChangeListener屬性來引用一個方法,對應于ValueChangeEvents。

    A tag representing a component that implements ActionSource can refer to backing bean methods using actionListener and action attributes. The actionListener attribute refers to a method that handles an action event. The action attribute refers to a method that performs some processing associated with navigation and returns a logical outcome, which the navigation system uses to determine which page to display next.
    一個通過標記表現的組件,如果實現了ActionSource,則可以使用actionListener和Action屬性來引用后臺bean的方法。action屬性引用一個方法來處理action事件。action屬性所引用的方法作一些處理,進行頁面導航,并返回一個邏輯結果,導航系統使用這個邏輯結果來決定哪個頁面需要被顯示。

    A tag can also bind a component instance to a backing bean property. It does this by referencing the property from the binding attribute:
    一個標記可以綁定組件的實例到后臺bean的屬性。可以通過從binding的屬性中引用一個屬性來實現。
    <inputText binding="#{UserNumberBean.userNoComponent}" />

    The property referenced from the binding attribute must accept and return the same component type as the component instance to which it's bound. Here is an example property that can be bound to the component represented by the preceding example inputText tag:
    通過binding屬性引用的屬性必須有和組件實例類型相同的數據類型。
    UIInput userNoComponent = null;
    ...
    public void setUserNoComponent(UIInput userNoComponent) {
      this.userNoComponent = userNoComponent;
    }
    public UIInput getUserNoComponent() {
      return userNoComponent;
    }

    When a component instance is bound to a backing bean property, the property holds the component's local value. Conversely, when a component's value is bound to a backing bean property, the property holds its model value, which is updated with the local value during the update model values phase of the life cycle.
    當一個組件實例被綁定到后臺bean的屬性,這個屬性就保存了組件的本地值,相反的,如果一個組件的值被綁定到后臺bean的屬性,則屬性保存的是模式值。在生命周期中的更新模式值的過程中發生更新本地值的操作。

    Binding a component instance to a bean property has these advantages:
    綁定一個組件的實例到bean的屬性有下面的一些優勢。
    The backing bean can programmatically modify component attributes.
    后臺bean可以程序化的處理組件的屬性。
    The backing bean can instantiate components rather than let the page author do so.
    后臺bean可以例示組件而不是讓頁面開發者來作這個工作。

    Binding a component's value to a bean property has these advantages: 將組件的值綁定到bean的屬性有這樣一些優勢:
    The page author has more control over the component attributes.
    頁面開發者對組件的屬性有更多的控制權。
    The backing bean has no dependencies on the JavaServer Faces API (such as the UI component classes), allowing for greater separation of the presentation layer from the model layer.
    后臺bean不必依靠于JSF的API,可以更好的將表現層和模式層分開。
    The JavaServer Faces implementation can perform conversions on the data based on the type of the bean property without the developer needing to apply a converter.
    JSF可以作數據類型轉換而不必有開發者來作一個轉換器。

    In most situations, you will bind a component's value rather than its instance to a bean property. You'll need to use a component binding only when you need to change one of the component's attributes dynamically. For example, if an application renders a component only under certain conditions, it can set the component's rendered property accordingly by accessing the property to which the component is bound.
    在大多數情況下,應該盡量使用綁定組件的值而不是組件的實例到bean的屬性。只有當你需要動態的更改組件的屬性時才需要綁定組件的實例到bean的屬性。例如,假如需要在特定的情況下顯示一個組件,那么只需要在后臺bean中訪問綁定的屬性就可以了。

    Backing beans are created and stored with the application using the managed bean creation facility, which is configured in the application configuration resource file, as shown in java/j2eetutorial14/doc/JSFIntro5.html#wp114997">Adding Managed Bean Declarations. When the application starts up, it processes this file, making the beans available to the application and instantiating them when the component tags reference them.
    后臺bean的創建和保存是通過可管理的bean的創建工具來完成的,在應用的配置文件中進行配置。當一個應用啟動時,它就處理這個文件,當組件的標記引用到他們時,使這些bean可用并實例化他們。

    In addition to referencing bean properties using value and binding attributes, you can reference bean properties (as well as methods and resource bundles) from a custom component attribute by creating a ValueBinding instance for it. See java/j2eetutorial14/doc/JSFCustom5.html#wp114102">Creating the Component Tag Handler and java/j2eetutorial14/doc/JSFCustom7.html#wp120558">Enabling Value-Binding of Component Properties for more information on enabling your component's attributes to support value binding.
    除了通過value和binding可以引用一個bean的屬性之外,你還可以引用一個bean的屬性(例如方法和資源文件)通過自定義組件的屬性,創建一個ValueBinding實例來完成。

    posted on 2006-02-24 17:43 銀色幻想 閱讀(367) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 精品日韩亚洲AV无码| 亚洲精品制服丝袜四区| 亚洲综合av一区二区三区| 1000部国产成人免费视频| 亚洲无线一二三四区| 曰批视频免费30分钟成人| 亚洲欧洲日产国产最新| 在线永久看片免费的视频| 欧洲 亚洲 国产图片综合| 日本不卡视频免费| 丰满妇女做a级毛片免费观看| 国产a v无码专区亚洲av| a级精品九九九大片免费看| 久久精品国产精品亚洲色婷婷| 久久综合国产乱子伦精品免费| 亚洲电影一区二区| 亚洲成人免费网址| 亚洲成aⅴ人片久青草影院按摩| 国产一区视频在线免费观看 | CAOPORN国产精品免费视频| 中文字幕精品亚洲无线码一区应用| 中文字幕在线免费播放| 亚洲av无码无在线观看红杏| 亚洲一级毛片免费看| 亚洲AV无码之国产精品| 亚洲精品自在在线观看| 成人浮力影院免费看| 无码天堂va亚洲va在线va| 亚洲av无码成人黄网站在线观看| 美女网站免费福利视频| 老外毛片免费视频播放| 久久久久亚洲精品影视| 好爽又高潮了毛片免费下载| 日韩在线视频免费| 亚洲白色白色永久观看| 免费在线观看黄网站| 99久久免费看国产精品| 美女黄频免费网站| 亚洲日本香蕉视频| 亚洲毛片不卡av在线播放一区| 人妻无码一区二区三区免费 |