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

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

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

    銀色幻想

    常用鏈接

    統(tǒng)計(jì)

    積分與排名

    學(xué)習(xí)交流

    最新評(píng)論

    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應(yīng)用中另一個(gè)關(guān)鍵的功能就是適當(dāng)?shù)墓芾碣Y源。這包括將UI組件對(duì)象的定義和處理應(yīng)用程序指定的功能和保存數(shù)據(jù)的對(duì)象分開。它還包括在適當(dāng)?shù)姆秶斜4婧凸芾磉@些對(duì)象實(shí)例。

    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.
    一個(gè)典型的JSF應(yīng)用包括一個(gè)或多個(gè)后臺(tái)bean,在頁面中,這是和UI組件有關(guān)聯(lián)關(guān)系的JavaBeans組件。一個(gè)后臺(tái)bean定義了UI組件的屬性,每一個(gè)屬性都綁定到組件的值或者實(shí)例。一個(gè)后臺(tái)bean也可以定義和組件相關(guān),并執(zhí)行一定功能的方法,包括驗(yàn)證,事件處理,導(dǎo)航處理。

    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組件的值和實(shí)例到后臺(tái)bean的屬性或者通過UI組件的標(biāo)記引用后臺(tái)bean的方法,那么頁面開發(fā)者需要使用JSF表達(dá)式語言語法。這種語法使用“#{}”指示符。一個(gè)JSF的表達(dá)式可以是值綁定的(綁定UI組件或者他們的值到外部數(shù)據(jù)源)或者方法綁定(引用后臺(tái)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:
    為了演示值綁定表達(dá)式和方法綁定表達(dá)式,讓我們假設(shè)guessNumber應(yīng)用的userNo標(biāo)記引用了一個(gè)方法來作驗(yàn)證,而不是使用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.
    這個(gè)標(biāo)記將userNo組件的值綁定到UserNumberBean.userNumber后臺(tái)bean的屬性,這個(gè)方法對(duì)組件的本地值進(jìn)行了驗(yàn)證。

    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.
    屬性綁定到組件的值必須是組件支持的數(shù)據(jù)類型。例如,userNumber屬性返回一個(gè)Integer,這是一個(gè)UIInput支持的數(shù)據(jù)類型。

    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標(biāo)記還可以使用valueChangeListener屬性來引用一個(gè)方法,對(duì)應(yīng)于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.
    一個(gè)通過標(biāo)記表現(xiàn)的組件,如果實(shí)現(xiàn)了ActionSource,則可以使用actionListener和Action屬性來引用后臺(tái)bean的方法。action屬性引用一個(gè)方法來處理action事件。action屬性所引用的方法作一些處理,進(jìn)行頁面導(dǎo)航,并返回一個(gè)邏輯結(jié)果,導(dǎo)航系統(tǒng)使用這個(gè)邏輯結(jié)果來決定哪個(gè)頁面需要被顯示。

    A tag can also bind a component instance to a backing bean property. It does this by referencing the property from the binding attribute:
    一個(gè)標(biāo)記可以綁定組件的實(shí)例到后臺(tái)bean的屬性。可以通過從binding的屬性中引用一個(gè)屬性來實(shí)現(xiàn)。
    <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屬性引用的屬性必須有和組件實(shí)例類型相同的數(shù)據(jù)類型。
    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.
    當(dāng)一個(gè)組件實(shí)例被綁定到后臺(tái)bean的屬性,這個(gè)屬性就保存了組件的本地值,相反的,如果一個(gè)組件的值被綁定到后臺(tái)bean的屬性,則屬性保存的是模式值。在生命周期中的更新模式值的過程中發(fā)生更新本地值的操作。

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

    Binding a component's value to a bean property has these advantages: 將組件的值綁定到bean的屬性有這樣一些優(yōu)勢(shì):
    The page author has more control over the component attributes.
    頁面開發(fā)者對(duì)組件的屬性有更多的控制權(quán)。
    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.
    后臺(tái)bean不必依靠于JSF的API,可以更好的將表現(xiàn)層和模式層分開。
    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可以作數(shù)據(jù)類型轉(zhuǎn)換而不必有開發(fā)者來作一個(gè)轉(zhuǎn)換器。

    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.
    在大多數(shù)情況下,應(yīng)該盡量使用綁定組件的值而不是組件的實(shí)例到bean的屬性。只有當(dāng)你需要?jiǎng)討B(tài)的更改組件的屬性時(shí)才需要綁定組件的實(shí)例到bean的屬性。例如,假如需要在特定的情況下顯示一個(gè)組件,那么只需要在后臺(tái)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.
    后臺(tái)bean的創(chuàng)建和保存是通過可管理的bean的創(chuàng)建工具來完成的,在應(yīng)用的配置文件中進(jìn)行配置。當(dāng)一個(gè)應(yīng)用啟動(dòng)時(shí),它就處理這個(gè)文件,當(dāng)組件的標(biāo)記引用到他們時(shí),使這些bean可用并實(shí)例化他們。

    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可以引用一個(gè)bean的屬性之外,你還可以引用一個(gè)bean的屬性(例如方法和資源文件)通過自定義組件的屬性,創(chuàng)建一個(gè)ValueBinding實(shí)例來完成。

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


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 黄瓜视频高清在线看免费下载| 99精品在线免费观看| 免费看大美女大黄大色| 亚洲精品中文字幕无乱码麻豆| 91免费资源网站入口| 97se亚洲国产综合自在线| 丁香花在线观看免费观看| 亚洲最大av资源站无码av网址| 好大好硬好爽免费视频| 好男人www免费高清视频在线| 亚洲码一区二区三区| AV大片在线无码永久免费| 亚洲制服丝袜第一页| 日本不卡视频免费| 美女扒开尿口给男人爽免费视频| 免费在线观看黄网站| a毛片成人免费全部播放| 久久香蕉国产线看观看亚洲片| 一级毛片全部免费播放| 亚洲一区二区三区在线网站| 日韩精品视频免费观看| 一级一黄在线观看视频免费| 亚洲第一极品精品无码久久| 13一14周岁毛片免费| 亚洲成av人片天堂网无码】| 久久精品亚洲男人的天堂| 久9久9精品免费观看| 亚洲区日韩精品中文字幕| 亚洲乱亚洲乱少妇无码| 久久久久久久99精品免费观看| 久久精品国产亚洲av麻豆图片| 凹凸精品视频分类国产品免费| 国产中文字幕在线免费观看| 亚洲色图黄色小说| 免费人成年激情视频在线观看 | 久久精品熟女亚洲av麻豆| 国产成人精品曰本亚洲79ren| 一区二区三区在线免费看| 亚洲欧美日韩中文无线码 | 亚洲国产精品成人久久蜜臀 | 免费精品人在线二线三线区别|