編程之道

          無論是批評的,贊揚(yáng)的,指著的都請EMAIL給我,你的建議將是我前進(jìn)的動(dòng)力! 聯(lián)系我

          后臺(tái)如何調(diào)用JSF頁面的值

          ?

          1.???? 通過 backing bean 對頁面的值進(jìn)行綁定

          ?

          JSF 封裝的 HTML 控件都有一個(gè) binding 的屬性,通過該屬性可以在后臺(tái)對該控件取值賦值。

          ?

          < body >

          ??????? < f:view >

          ??????? ??????? < h:form >

          ??????? ??????? ??????? < h:inputText binding = "#{loginBean.txtUser}"></h:inputText>

          ??????? ??????? ??????? < h:commandButton actionListener = "#{loginBean.txtListener}"value="enter"></h:commandButton>

          ??????? ??????? </ h:form >

          ??????? </ f:view >

          </ body >

          ?

          ?

          ??????? private UIInput txtUser ;

          ??????? public UIInput getTxtUser() {

          ??????? ??????? return txtUser ;

          ??????? }

          ?

          ??????? public void setTxtUser(UIInput txtUser) {

          ??????? ??????? this . txtUser = txtUser;

          ??????? }???????

          ???????

          ??????? public void txtListener(ActionEvent e){

          ??????? ??????? txtUser .setValue( "11111" );

          ??????? ??????? System. out .println( txtUser .getValue().toString());

          ??????? }

          ?

          2.???? 在一個(gè) bean 中調(diào)用其它 bean


          ????????
          ???????? ??????? FacesContext context = FacesContext.getCurrentInstance();

          ??????? ??????? ??????? ValueBinding binding = context.getApplication().createValueBinding(

          ??????? ??????? ??????? ??????? ??????? "#{uptBean}" );

          ??????? ??????? ??????? uptBean bean = (uptBean) binding.getValue(context);

          ?

          這段代碼就是用來調(diào)用 uptBean CreateValueBinding ()方法中的參數(shù),可以是 bean ,也可以 bean 中對應(yīng)得數(shù)據(jù)。




          ?

          ?

          posted on 2007-01-18 12:21 瘋流成性 閱讀(1162) 評論(0)  編輯  收藏 所屬分類: Java


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 樟树市| 陵川县| 岑溪市| 太原市| 宁河县| SHOW| 桃江县| 稻城县| 双峰县| 时尚| 黄梅县| 宁蒗| 开封县| 抚顺县| 孝昌县| 浦北县| 西宁市| 汕尾市| 清徐县| 大港区| 江安县| 万源市| 绥化市| 江门市| 济宁市| 永寿县| 松潘县| 绩溪县| 襄汾县| 绥江县| 双江| 晋江市| 迭部县| 娄底市| 葵青区| 城口县| 邯郸市| 当阳市| 大方县| 沿河| 新闻|