隨筆-348  評論-598  文章-0  trackbacks-0
          第一種方法:
          JSF頁面中的代碼:
          <h:form id="messageForm">
          <h:outputText id="outputMessage"/>
          <h:commandButton value="Get Message"
          actionListener
          ="#{testForm.sendMessage}"/>
          </h:form>
          后臺程序:
          public void sendMessage(ActionEvent e)
          {
          FacesContext context 
          = FacesContext.getCurrentInstance();
          UIViewRoot view 
          = context.getViewRoot();
          HtmlOutputText output 
          =
          (HtmlOutputText)view.findComponent(
          "messageForm:outputMessage");
          output.setStyle(
          "color:blue");
          output.setValue(
          "Who's the Mann?");
          }
          之后,當點擊Get Message的時候頁面就會在outputMessage的地方輸出 Who's the Mann?
          第二種方法:
          <h:inputText value="#{registrationForm.comments}"
          binding
          ="#{registrationForm.commentsInput}"/>
          commentsInput是RegistrationForm中的一個HtmlInputText類型的一個變量,通過binding屬性將前臺UI控件和后臺同類型的變量綁定,就可以在后臺直接操作了。

          ---------------------------------------------------------
          專注移動開發

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2008-10-17 13:51 TiGERTiAN 閱讀(1093) 評論(0)  編輯  收藏 所屬分類: JavaJSF
          主站蜘蛛池模板: 农安县| 西乌| 洞口县| 富顺县| 砚山县| 太湖县| 扶风县| 桐柏县| 鹤壁市| 明水县| 临沭县| 三江| 新河县| 张北县| 元氏县| 大港区| 营口市| 滦平县| 葵青区| 巴塘县| 会同县| 泰来县| 贞丰县| 衢州市| 普洱| 崇仁县| 哈密市| 武冈市| 江华| 札达县| 邵阳县| 会宁县| 沙坪坝区| 阿荣旗| 铅山县| 灵宝市| 临邑县| 亳州市| 达拉特旗| 霞浦县| 海门市|