編程之道

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

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

          ?

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

          ?

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

          ?

          < 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.???? 在一個 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 瘋流成性 閱讀(1161) 評論(0)  編輯  收藏 所屬分類: Java


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 浮山县| 马关县| 石楼县| 黄梅县| 武义县| 中超| 广安市| 正阳县| 平和县| 贵定县| 昌平区| 洞口县| 韶山市| 岳普湖县| 江西省| 宁远县| 上蔡县| 京山县| 九龙坡区| 甘泉县| 南乐县| 新和县| 阿克陶县| 同仁县| 犍为县| 永新县| 奉贤区| 陵水| 达州市| 林甸县| 榆林市| 锡林浩特市| 宜昌市| 保亭| 烟台市| 噶尔县| 鹿泉市| 资溪县| 祁东县| 蓝田县| 普洱|