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

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

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

    soufan

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      22 隨筆 :: 0 文章 :: 0 評論 :: 0 Trackbacks

    使用backing bean來添加UIComponents 到頁面中?

    下面是一個例子:

    jsp1.jsp:

    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <html>
    <f:view>
    <head>
    <title>jsp1</title>
      <link rel="stylesheet" type="text/css" href="./style.css" title="Style"/>
    </head>
    <body bgcolor="#ffffff">  TESTING...
      <h:form id="form1">
        <h:panelGrid id="panelgridtest" binding="#{jsp1Bean.component}"/>
      </h:form>
    </body>
    </f:view>
    </html>
    

    ?

    Jsp1Bean.java:

    package?test;
    ?
    import?javax.faces.application.Application;
    import?javax.faces.component.UIComponent;
    import?javax.faces.component.UIPanel;
    import?javax.faces.component.UIViewRoot;
    import?javax.faces.component.html.HtmlInputText;
    import?javax.faces.component.html.HtmlOutputText;
    import?javax.faces.context.FacesContext;
    ?
    public?class?Jsp1Bean
    {
    ????UIComponent?component?=?null;
    ????FacesContext?facesContext?=?FacesContext.getCurrentInstance();
    ????UIViewRoot?uIViewRoot?=?facesContext.getViewRoot();
    ????Application?application?=?facesContext.getApplication();
    ?
    ????public?Jsp1Bean()
    ????{
    ????}
    ?
    ????public?UIComponent?getComponent()
    ????{
    ????????if?(component?==?null)
    ????????{
    ????????????component?=?new?UIPanel();
    ????????}
    ????????return?component;
    ????}
    ?
    ????public?void?setComponent(UIComponent?component)
    ????{
    ????????this.component?=?component;
    ????}
    ?
    ?????//initialization?block
    ????{
    ????????try
    ????????{
    ????????????//outputText1
    ????????????HtmlOutputText?outputText1?=?(HtmlOutputText)?
    ??????????????facesContext.getApplication().createComponent(HtmlOutputText.COMPONENT_TYPE);
    ????????????outputText1.setValue("---the?outputText1?value---");
    ????????????//inputText1
    ????????????HtmlInputText?inputText1?=?(HtmlInputText)
    ????????????????facesContext.getApplication().createComponent(HtmlInputText.COMPONENT_TYPE);
    ????????????inputText1.setValue("---the?inputText1?value---");
    ?
    ????????????//add?outputText1?and?inputText1?to?component?("UIPanel")
    ????????????this.getComponent().getChildren().add(outputText1);
    ????????????this.getComponent().getChildren().add(inputText1);
    ????????}
    ????????catch?(java.lang.Throwable?t)
    ????????{
    ????????????System.out.println("java.lang.Throwable?exception?encountered...t.getMessage()="?+?t.getMessage());
    ????????????t.printStackTrace();
    ????????}
    ????}
    ?
    ????public?String?doAction()
    ????{
    ????????return?"submit";
    ????}
    }

    ?

    faces-config.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
                                  "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
      <navigation-rule>
        <from-view-id>/jsp1</from-view-id>
        <navigation-case>
          <from-action>submit</from-action>
          <to-view-id>/jsp1</to-view-id>
          <redirect/>
        </navigation-case>
      </navigation-rule>
      <managed-bean>
        <managed-bean-name>jsp1Bean</managed-bean-name>
        <managed-bean-class>test.Jsp1Bean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    </faces-config>
    
    posted on 2006-12-19 16:14 soufan 閱讀(245) 評論(0)  編輯  收藏

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


    網站導航:
     
    主站蜘蛛池模板: 无码国产精品一区二区免费虚拟VR| 亚洲va久久久噜噜噜久久男同| a毛片全部免费播放| 国产精品福利在线观看免费不卡| 国产成人无码免费看片软件| 国产精品四虎在线观看免费| 免费在线观看的黄色网址| 国产国拍精品亚洲AV片 | 性做久久久久久免费观看| 性感美女视频在线观看免费精品| 可以免费观看的国产视频| 国产人在线成免费视频| 亚洲经典在线观看| 人妻巨大乳hd免费看| 97精品免费视频| 天天操夜夜操免费视频| 亚洲av无码片区一区二区三区| 国产成人高清亚洲一区91| a在线观看免费视频| 免费看国产一级特黄aa大片| 亚洲欧洲日本在线| mm1313亚洲精品国产| 亚洲网红精品大秀在线观看| 亚洲国产精品ⅴa在线观看| 黄页免费在线观看| 精品亚洲麻豆1区2区3区| 无遮挡呻吟娇喘视频免费播放| aa级一级天堂片免费观看| 亚洲欧美日韩中文无线码| 国产精品免费精品自在线观看| 亚洲中文字幕无码永久在线| 四虎成人精品永久免费AV| 久久精品亚洲乱码伦伦中文| 久久亚洲中文字幕无码| 操美女视频免费网站| 亚洲一区二区三区无码国产| 免费一级毛片清高播放| 最好看的中文字幕2019免费| 亚洲精品乱码久久久久久V| 黑人精品videos亚洲人| 中文在线日本免费永久18近|