<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无码网站大全| 在线观看免费高清视频| 18禁无遮挡无码网站免费| 国产美女无遮挡免费视频网站| 四虎永久在线精品免费观看地址| 国产成人亚洲综合无码| 久久精品国产亚洲av麻| 亚洲Av高清一区二区三区| 久久亚洲欧美国产精品| 成人无码区免费A∨直播| 18未年禁止免费观看| 日韩一级视频免费观看| 亚洲永久精品ww47| 亚洲码在线中文在线观看| 在线观看亚洲专区| 成人影片一区免费观看| a级毛片无码免费真人| 亚洲国产日韩成人综合天堂| 亚洲男人的天堂在线播放| 亚洲最大中文字幕无码网站| 1000部禁片黄的免费看| 四虎影院免费在线播放| 中文字幕亚洲日本岛国片| 亚洲精品国产福利片| 国产亚洲午夜精品| 在线成人爽a毛片免费软件| 国产精品自在自线免费观看| 亚洲精品无码MV在线观看| 亚洲av一本岛在线播放| 中文字幕成人免费高清在线视频| 91黑丝国产线观看免费| 亚洲一区二区高清| 亚洲AV无码一区二区三区人| 人禽伦免费交视频播放| 嫖丰满老熟妇AAAA片免费看| 久久亚洲国产精品五月天婷| 久久久国产亚洲精品| 青青草原1769久久免费播放| 国产午夜鲁丝片AV无码免费| 亚洲电影国产一区|