锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久亚洲欧洲国产综合,亚洲短视频男人的影院,亚洲AV永久无码精品一福利 http://m.tkk7.com/Vincent-chenxj/category/36153.htmlzh-cnTue, 02 Dec 2008 16:19:14 GMTTue, 02 Dec 2008 16:19:14 GMT60JSF闂闆嗛敠http://m.tkk7.com/Vincent-chenxj/articles/243633.htmlVincent-chenVincent-chenMon, 01 Dec 2008 01:55:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/243633.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/243633.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/243633.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/243633.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/243633.html1.濡備綍緇撴潫session?   
  • 浣犲彲浠ヤ嬌鐢╯ession鐨?nbsp;invalidate鏂規硶 .   
  • 涓嬮潰鏄竴涓粠action鏂規硶涓粨鏉焥ession鐨勪緥瀛? :   
  • public String logout() {    
      FacesContext fc 
    = FacesContext.getCurrentInstance();    
      HttpSession session 
    = (HttpSession) fc.getExternalContext().getSession(false);    
      session.invalidate();    
      
    return "login_page";    
    }
       

     

  • 涓嬮潰鐨勪唬鐮佺墖孌電ず渚嬩簡濡備綍鍦↗SP欏甸潰涓粨鏉焥ession:   
  • <% session.invalidate(); %>    
    <c:redirect url="loginPage.jsf" />    
       

  •   
  • 2.濡備綍鍦↗SP欏甸潰涓闂畐eb.xml涓殑鍒濆鍖栧弬鏁?   
  • 浣犲彲浠ヤ嬌鐢ㄩ瀹氫箟鐨凧SF EL鍙橀噺  initParam鏉ヨ闂?   
  • 渚嬪,濡傛灉浣犳湁:   
  •  

    <context-param>    
     
    <param-name>productId</param-name>    
     
    <param-value>2004Q4</param-value>    
    </context-param>    

     

  • 浣犲彲浠ヤ嬌鐢ㄥス #{initParam['productId']}鏉ヨ闂?nbsp;.渚嬪:   
  • Product Id: <h:outputText value="#{initParam['productId']}"/>   
  •   
  •   
  • 3.濡備綍浠巎ava浠g爜涓闂畐eb.xml 涓殑鍒濆鍖栧弬鏁?   
  • 浣犲彲浠ヤ嬌鐢╡xternalContext鐨?nbsp;getInitParameter 鏂規硶寰楀埌浠栦滑.渚嬪 濡傛灉浣犵殑鍙傛暟濡備笅:   
  •  

    <context-param>    
     
    <param-name>connectionString</param-name>    
     
    <param-value>jdbc:oracle:thin:scott/tiger@cartman:1521:O901DB</param-value>    
    </context-param>    

     

  • 浣犲彲浠ヤ嬌鐢ㄤ笅闈唬鐮佽闂甤onnectionString :   
  • FacesContext fc = FacesContext.getCurrentInstance();String connection = fc.getExternalContext().getInitParameter("connectionString");    
  •   
  •   
  • 4.濡備綍浠巄acking bean涓緱鍒板綋鍓嶉〉闈㈢殑URL?   
  • 浣犲彲浠ラ氳繃FacesContext寰楀埌涓涓狧ttp Request瀵硅薄鐨勫紩鐢?濡備笅:   
  • FacesContext fc = FacesContext.getCurrentInstance();HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();    
  • 鐒跺悗浣跨敤鏅氱殑request鏂規硶鏉ュ緱鍒拌礬寰勪俊鎭?榪樺彲浠ヤ嬌鐢ㄥ彟澶栦竴縐嶆柟娉?   
  • context.getViewRoot().getViewId();   
  • 灝嗚繑鍥炰綘褰撳墠JSP(JSF view IDs 鍩烘湰涓婂彧鏄疛SP path names)欏甸潰鐨勫悕瀛?   
  •   
  •   
  • 5.濡備綍娣誨姞涓婁笅鏂囪礬寰勫埌outputLink鐨刄RL涓?   
  • 鍦ㄥ綋鍓嶇殑JSF瀹炵幇涓?褰撳湪outputLink 涓畾涔夌殑璺緞浠?/'寮濮嬫椂,娌℃湁娣誨姞涓婁笅鏂囪礬寰勫埌URL涓?瑕佸譏琛ヨ闂璇峰湪URL涓嬌鐢?nbsp;#{facesContext.externalContext.requestContextPath} 鍓嶇紑.渚嬪:   
  • <h:outputLink value="#{facesContext.externalContext.requestContextPath}/myPage.faces">   
  •   
  •   
  • 6.濡備綍浣跨敤URL瀛楃涓叉潵浼犻掑弬鏁板埌JSF紼嬪簭涓?   
  • 濡傛灉浣犳湁涓嬮潰鐨刄RL: http://your_server/your_app/product.jsf?id=777, 浣犲彲浠ヤ嬌鐢ㄤ笅闈㈢殑浠g爜鏉ヨ闂墍浼犻掔殑鍙傛暟:     
  • FacesContext fc = FacesContext.getCurrentInstance();String id = (String) fc.getExternalContext().getRequestParameterMap().get("id");    
  • 鍦↗SF欏甸潰涓?浣犱篃鍙互浣跨敤棰勫畾涔夌殑鍙橀噺璁塊棶鍚屾牱鐨勫弬鏁?渚嬪:    
  • <h:outputText value="#{param['id']}" />   
  • 娉ㄦ剰: 浣犲繀欏葷洿鎺ヨ皟鐢ㄨJSF欏甸潰,騫朵笖浣跨敤servlet 鏄犲皠 (mapping).   
  •   
  •   
  • 7.濡備綍鍦ㄩ〉闈㈤噸鏂拌澆鍏ョ殑鏃跺欎繚鐣檋:inputSecret涓殑瀵嗙爜?   
  • 璁劇疆redisplay=true, it is false by default.   
  •     
  •   
  • 8.濡備綍浣跨敤h:outputText杈撳嚭HTML鏍囩?   
  •   
  • h:outputText鏈変竴涓?nbsp; escape 灞炴х敤鏉ュ鐞唄tml 鏍囩. 榛樿鍊間負true.榪欐剰鍛崇潃鎵鏈夌壒孌婄殑絎﹀悎閮借杞箟涓?&'浠g爜. 璇風湅涓嬮潰紺轟緥:  <h:outputText value="<b>This is a text</b>"/> 鎵撳嵃鐨勭粨鏋滄槸:  <b>This is a text</b>  鑰?nbsp;<h:outputText escape="false" value="<b>This is a text</b>"/>  鎵撳嵃鐨勭粨鏋滄槸:  This is a text  褰撶敤鎴風偣鍑籆ommand Link鍚庡浣曟樉紺虹‘璁ゅ璇濇?   
  • h:commandLink鎸囧畾浜?nbsp;onclick 灞炴т負鍐呴儴浣跨敤. 鍥犳浣犱笉鍙互浣跨敤濂逛簡, 璇ラ棶棰樺凡緇忓湪JSF1.2涓慨澶嶄簡,瀵逛簬JSF1.2浠ュ墠鐨勭増鏈?浣犲彲浠ュ湪onclick浠ュ墠浣跨敤  onmousedown 浜嬩歡  <script  language="javascript">  function ConfirmDelete(link) {    var delete = confirm('Do you want to Delete?');    if (delete == true) {      link.onclick();    }  }</script>   
  • <h:commandLink action="delete" onmousedown="return ConfirmDelete(this);">  <h:outputText value="delete it"/></h:commandLink>   
  •     
  •   
  • 9.鍦ㄨ皟鐢╒alueChangeListener 鏂規硶鍚庡浣曢噸鏂拌杞介〉闈?   
  • 鍦?nbsp;ValueChangeListener鐨勬渶鍚?璋冪敤  FacesContext.getCurrentInstance().renderResponse()   
  • 濡備綍瀹炵幇"璇風瓑寰?.."欏甸潰? 鍦ㄥ鎴風瀹炵幇鍙兘寰堢畝鍗?浣犲彲浠ュ寘瑁匤SP欏甸潰(鎴栬呬綘鎯寵闅愯棌鐨勪竴閮ㄥ垎)鍒頒竴涓猟iv涓?鐒跺悗浣犲彲浠ユ坊鍔犳洿澶歞iv,褰撶敤鎴風偣鍑繪彁浜ゆ寜閽椂榪欎簺div鍑虹幇.榪欎簺div鍙互鍖呭惈gif鍔ㄧ敾鍜屽叾浠栧唴瀹? 鍦烘櫙:褰撶敤鎴風偣鍑繪寜閽?璋冪敤JS鍑芥暟,璇ュ嚱鏁伴殣钘忛〉闈㈠茍涓旀樉紺?/span>"璇風瓑寰?.."div.浣犲彲浠ヤ嬌鐢–SS鏉ヨ嚜瀹氫箟澶栬:涓嬮潰鏄竴涓甯稿伐浣滅殑渚嬪瓙: <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>   
  • <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>    
    <f:loadBundle basename="demo.bundle.Messages" var="Message"/>    
    <html>    
    <head>    
      
    <title>Input Name Page</title>    
      
    <script>    
        function gowait() {    
          document.getElementById("main").style.visibility="hidden";    
          document.getElementById("wait").style.visibility="visible";    
        }    
       
    </script>    
           
     
    </head>    
     
    <body bgcolor="white">    
      
    <f:view>    
        
    <div id="main">    
           
    <h1><h:outputText value="#{Message.inputname_header}"/></h1>    
           
    <h:messages style="color: red"/>    
           
    <h:form id="helloForm">    
             
    <h:outputText value="#{Message.prompt}"/>    
             
    <h:inputText id="userName" value="#{GetNameBean.userName}" required="true">    
               
    <f:validateLength minimum="2" maximum="20"/>    
             
    </h:inputText>    
             
    <h:commandButton onclick="gowait()" id="submit"   
                   action
    ="#{GetNameBean.action}" value="Say Hello" />    
           
    </h:form>    
        
    </div>    
        
    <div id="wait" style="visibility:hidden; position: absolute; top: 0; left: 0">    
           
    <table width="100%" height ="300px">    
             
    <tr>    
               
    <td align="center" valign="middle">    
                 
    <h2>Please, wait</h2>    
               
    </td>    
             
    </tr>    
           
    </table>    
        
    </div>    
      
    </f:view>    
     
    </body>    
    </html>     
       

    濡傛灉浣犳兂鏈変竴涓姩鐢籫if鍥劇墖鍦?/span>"璇風瓑寰?.."涓?褰撹〃鍗曟彁浜ゅ悗璇ュ浘鐗囧簲璇ヤ粠鏂板姞杞?鍥犳,鍐嶄竴嬈℃寚瀹氬浘鐗囩殑id,騫朵笖娣誨姞緇忚繃涓孌墊椂闂村歡鏃跺悗閲嶆柊鍔犺澆鐨勪唬鐮?涓嬮潰鏄釜渚嬪瓙: <script>   

     

     function gowait() {    
       document.getElementById("main").style.visibility="hidden";    
       document.getElementById("wait").style.visibility="visible";    
       window.setTimeout('showProgress()', 500);    
     }    
      function showProgress(){    
       var wg = document.getElementById("waitgif");    
       wg.src=wg.src;    
     }    
    </script>    
    .    
    <img id="waitgif" src="animated.gif">   


    ]]>
    jsf緇撴潫sessionhttp://m.tkk7.com/Vincent-chenxj/articles/243401.htmlVincent-chenVincent-chenSat, 29 Nov 2008 05:06:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/243401.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/243401.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/243401.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/243401.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/243401.html 涓嬮潰鏄竴涓粠action鏂規硶涓粨鏉焥ession鐨勪緥瀛? :

     

    public String logout() {

      FacesContext fc 
    = FacesContext.getCurrentInstance();
      HttpSession session 
    = (HttpSession) fc.getExternalContext().getSession(false);
      session.invalidate();
      
    return "login_page";
    }
      

     

    涓嬮潰鐨勪唬鐮佺墖孌電ず渚嬩簡濡備綍鍦↗SP欏甸潰涓粨鏉焥ession:

    
    
    <% session.invalidate(); %>
    <c:redirect url="loginPage.jsf" /> 


    ]]>
    鐢熸垚Excel騫跺湪瀹㈡埛绔笅杞界殑JSF瀹炵幇http://m.tkk7.com/Vincent-chenxj/articles/242968.htmlVincent-chenVincent-chenThu, 27 Nov 2008 03:36:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242968.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242968.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242968.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242968.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242968.html闃呰鍏ㄦ枃

    ]]>
    JSF瀹炵幇鏂囦歡涓嬭澆http://m.tkk7.com/Vincent-chenxj/articles/242959.htmlVincent-chenVincent-chenThu, 27 Nov 2008 03:25:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242959.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242959.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242959.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242959.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242959.html 鐢ㄦ埛浠庨〉闈㈢偣鍑昏繛鎺ワ紙link錛夛紝涓嬭澆鐩稿叧鐨勬枃浠訛紝璇ユ枃浠跺瓨鍦ㄦ湇鍔″櫒绔紝鎴栬呯敱鏈嶅姟鍣ㄧ鐢熸垚鏂囦歡嫻侊紝娌℃湁鐗╃悊鏂囦歡錛涗笅杞藉悗欏甸潰涓嶈煩杞?br />
    JSP浠g爜錛?/strong>


    <h:commandLink actionListener="#{productBean.downloadAction}" styleClass="highLightLink">
       <h:outputText value="download"/>
       <f:param name="productId" value="#{productBean.id}"/>
    </h:commandLink>



    Backing bean璁捐鍙婁唬鐮侊細
    娉ㄦ剰榪欐槸涓狝ction listener鏂規硶錛屾病鏈夎繑鍥炲鹼紝騫朵笖鏈塲avax.faces.event.ActionEvent鍙傛暟


       public void downloadAction(ActionEvent event) {
        try {
          String fileName="D:\\temp\\images\\products\\" + this.id + ".xls";
          logger.debug("file name=" + fileName);
          ByteArrayOutputStream baos=this.serviceLocator.getFileService().downloadFile(fileName); //璋冪敤Service鏂規硶錛岃幏寰楁枃浠剁殑ByteArrayOutputStream
          HttpServletResponse response=FacesUtils.getServletResponse();
          response.setHeader("Content-disposition", "attachment; filename=" + id+ ".xls" ); //涓嶆槸鍐呭祵鏄劇ず(inline)錛岃屾槸浣滀負闄勪歡涓嬭澆
          response.setContentLength(baos.size());
          ServletOutputStream sos=response.getOutputStream();
          baos.writeTo(sos);
          baos.close();
          sos.flush();
        } catch (IOException ex) {      
          logger.debug(ex);
        }  
      }



    Service浠g爜錛?/strong>
    榪欎釜瀹炵幇鏄竴涓粠宸茬粡瀛樺湪鐨勭墿鐞嗘枃浠惰幏寰楄緭鍑烘祦鐨勮寖渚嬶紝鑷充簬鐢盨erver鍦ㄥ唴瀛樹腑鐢熸垚杈撳嚭嫻佷篃鏄竴鏍峰鐞嗭紝渚嬪鐢熸垚涓涓狤xcel鏂囦歡錛屽啀璁╃敤鎴蜂笅杞姐?br />

    public ByteArrayOutputStream downloadFile(String fileName) throws IOException {
        FileInputStream fis=new FileInputStream(fileName);
        BufferedInputStream bis=new BufferedInputStream(fis);
        ByteArrayOutputStream baos=new ByteArrayOutputStream();
        BufferedOutputStream bos=new BufferedOutputStream(baos);
        
        int i;
        while((i=bis.read())!=-1) {
          bos.write(i);
        }
        bos.flush();//鎻愪氦鏂囦歡嫻侊紝寰堝叧閿?br />     bis.close();
        return baos;
      }



    ]]>
    JSF 鏂囦歡涓婁紶http://m.tkk7.com/Vincent-chenxj/articles/242953.htmlVincent-chenVincent-chenThu, 27 Nov 2008 03:17:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242953.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242953.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242953.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242953.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242953.html鍚庡彴瀹炵幇綾伙細

     

    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;

    import javax.faces.context.FacesContext;

    import org.apache.myfaces.custom.fileupload.UploadedFile;


    public class Fileupload
    {
        
    private UploadedFile _upFile;
        
    private String _name = "";

       
    public UploadedFile getUpFile()
        
    {
            
    return _upFile;
        }


     

    public void setUpFile(UploadedFile upFile)    
        
    {
            _upFile 
    = upFile;
        }


        
    public String getName()
        
    {
            
    return _name;
        }


        
    public void setName(String name)
        
    {
            _name 
    = name;
        }


        
    public String upload() throws IOException
        
    {
            FacesContext facesContext 
    = FacesContext.getCurrentInstance();
            
    int start=_upFile.getName().lastIndexOf("\\")==-1?_upFile.getName().lastIndexOf("\\"):_upFile.getName().lastIndexOf("\\")+1;
            String file
    =_upFile.getName().substring(start,_upFile.getName().length());
            String path
    =Fileupload.class.getResource("/").getPath().substring(1,Fileupload.class.getResource("/").getPath().length());
            path
    =path.replace("%20"" ")+file;
      
    try {
       FileOutputStream keyFOS 
    = new FileOutputStream(path);
       keyFOS.write(_upFile.getBytes());
       keyFOS.close();
      }
     catch (Exception e) {
       System.out.println(
    "lalala");
      }

      
            facesContext.getExternalContext().getApplicationMap().put(
    "fileupload_bytes", _upFile.getBytes());
            facesContext.getExternalContext().getApplicationMap().put(
    "fileupload_type", _upFile.getContentType());
            facesContext.getExternalContext().getApplicationMap().put(
    "fileupload_name", _upFile.getName());
            
    return path;
        }


    public boolean isUploaded()
        
    {
            FacesContext facesContext 
    = FacesContext.getCurrentInstance();
            
    return facesContext.getExternalContext().getApplicationMap().get("fileupload_bytes")!=null;
        }

    }


     

    鍓嶅彴瀹炵幇錛歁yfaces

     

    <t:inputFileUpload id="fileupload"
                                   value
    ="#{action$fixing.myFile}"         
                                   storage
    ="file"
                                   styleClass
    ="fileUploadInput"
                                   maxlength
    ="200000"/>
          
    <h:commandButton value="#{prompt['Submit']}"
           action
    ="#{action$fixing.sel}" />

     

     

    鍚庡彴綆$悊Bean錛?/span>

    import org.apache.myfaces.custom.fileupload.UploadedFile;

     

    public class FixingAction{

    private UploadedFile myFile;

     

    public UploadedFile getMyFile() {
      return myFile;
     }

     

     

    public void setMyFile(UploadedFile myFile) {
      this.myFile = myFile;
     }


        public String sel(){
           Fileupload file=new Fileupload();

    String path=file.setUpFile(this.myFile);

    System.out.println("鏂囦歡瀛樻斁璺緞錛?+path);

    return null;

      }
    }


    ]]>
    jsf 鍙﹀瓨涓虹殑瀹炵幇http://m.tkk7.com/Vincent-chenxj/articles/242946.htmlVincent-chenVincent-chenThu, 27 Nov 2008 02:39:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242946.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242946.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242946.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242946.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242946.html 

    public String btnSaveXML_action() {
            
    // TODO: Process the action. Return value is a navigation
            
    // case name where null will return to the same page.
            try {
                
    //get the appId
                Integer appId = Integer.valueOf(txtMemory1.getText().toString());
                String appName 
    = datamanagementservice.getAppNameByAppId(appId);
                Document doc 
    = writeXML(appId, appName);
                TransformerFactory tFactory 
    = TransformerFactory.newInstance();
                Transformer transformer 
    = tFactory.newTransformer();
                DOMSource source 
    = new DOMSource(doc);

                
    //the file's loadpath
                String loadPath = "c:\\temp\\" + appName + ".xml";
                
    //if the file no exist then create it
                File f = new File("c:\\temp\\");
                f.mkdirs();
                StreamResult result 
    = new StreamResult(new java.io.File(loadPath));
                transformer.transform(source, result);

                
    //new a download file
                File t_file = new File(loadPath);
                
    long l;
                
    for (l = 0L; l == 0L; l = t_file.length()) {

                    t_file 
    = new File(loadPath);
                }

                InputStream in 
    = new FileInputStream(t_file);
                
    if (in != null{
                    String filename 
    = t_file.getName();
                    filename 
    = java.net.URLEncoder.encode(filename, "utf-8");

                    FacesContext.getCurrentInstance().responseComplete();
                    HttpServletResponse httpServletResponse 
    = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
                    httpServletResponse.reset();
                    httpServletResponse.setContentType(
    "application/x-msdownload");
                    String rrr 
    = "attachment; filename=" + filename;
                    httpServletResponse.setHeader(
    "Content-Disposition", rrr);
                    httpServletResponse.setContentLength((
    int) l);

                    
    byte b[] = new byte[2048];
                    
    for (int len = 0; (len = in.read(b)) > 0;) {
                        httpServletResponse.getOutputStream().write(b, 
    0, len);
                    }

                    in.close();
                }

            }
     catch (Exception e) {
                e.printStackTrace();
            }

            getRequestBean1().setSelectAppId((Integer) dropDown1.getSelected());

            
    return null;
        }


    ]]>
    JSF鍜孯ichfaces涓嬌鐢ㄦ鏋墮〉(Frameset)錛屽寘鎷簡PanelMenu http://m.tkk7.com/Vincent-chenxj/articles/242064.htmlVincent-chenVincent-chenSat, 22 Nov 2008 17:05:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242064.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242064.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242064.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242064.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242064.html絎竴縐嶏紝鏅氱殑鏂規硶:
    鎯沖湪JSF鎺т歡涓搷浣滄鏋墮〉Frameset錛屽彲浠ュ湪宸︽鏋墮〉錛堜換涓妗嗘灦欏碉級閲屽0鏄庝竴涓狥orm錛岃瀹氬ソ瀹冪殑target="mainFrame"錛堜換涓妗嗘灦欏電殑id錛夛紝榪欐牱褰撶偣鍑昏繖涓狥orm閲岄潰鐨凜ommandButton鎴栬匔ommandLink鐨勬椂鍊欙紝JSF澶勭悊濂戒笟鍔¢昏緫鍚庯紝灝卞彲浠ュ皢To-View-ID鎸囧畾鐨勯〉闈㈣漿鍒頒富妗嗘灦欏甸噷闈㈠幓鏄劇ず浜嗐?br />

    <h:form target="mainFrame">
    <h:commandButton action="index">
    </h:form

    mainFrame

    鐐瑰嚮宸﹁竟鐨刢ommandButton涔嬪悗錛宨ndex澶勭悊涔嬪悗鐨凾o-View-ID鎸囧畾鐨勯〉闈㈠氨浼氭樉紺哄湪mainFrame閲岄潰浜?

    絎簩縐嶆柟娉曪細
            <script>
                    
    function forward(p) {
                         window.parent.mainFrame.location.href
    ="usermanagement/" + p + ".faces"
    ;
                     }

            
    </script>
    娣誨姞涓涓煩杞嚱鏁幫紝鐒跺悗鍒嗘儏鍐墊坊鍔犺煩杞細
    褰撲笉闇瑕丄ction鐨勬椂鍊?
    <rich:panelMenuItem label="瑙掕壊淇℃伅緇存姢" onclick="forward('rolelist')" />
    榪欐牱灝卞彲浠ヨ煩杞簡

    褰撻渶瑕佸厛榪涜Action鎿嶄綔鍐嶈煩杞殑鏃跺?br />
    <rich:panelMenuItem label="鏂板緩瑙掕壊"
                                    action
    ="#{user.addRoleMain}" oncomplete="forward('roledetail')" />
        public String addRoleMain()
        
    {
            ClearRole();
            
    return null
    ;
        }

    榪欐牱錛屽湪Action瀹屾垚鍚庯紝鑿滃崟欏典笉浼氬彉錛屼富妗嗘灦欏典細璺寵漿鍒版寚瀹氶〉闈€?br />
    OK,涓婇潰涓ょ鏂規硶鍩烘湰鑳芥弧瓚沖紑鍙戦渶瑕佷簡銆?


    ]]>
    JSF(Java Server Faces)鐨凷tateHolder鐨勪綔鐢ㄥ拰浣跨敤鏂規硶 http://m.tkk7.com/Vincent-chenxj/articles/242063.htmlVincent-chenVincent-chenSat, 22 Nov 2008 17:04:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242063.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242063.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242063.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242063.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242063.html闃呰鍏ㄦ枃

    ]]>
    鍦↗SF鎺т歡涓搷浣滄鏋墮〉Frameset http://m.tkk7.com/Vincent-chenxj/articles/242051.htmlVincent-chenVincent-chenSat, 22 Nov 2008 16:42:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242051.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242051.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242051.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242051.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242051.html
    鎯沖湪JSF鎺т歡涓搷浣滄鏋墮〉Frameset錛屽彲浠ュ湪宸︽鏋墮〉錛堜換涓妗嗘灦欏碉級閲屽0鏄庝竴涓狥orm錛岃瀹氬ソ瀹冪殑target="mainFrame"錛堜換涓妗嗘灦欏電殑id錛夛紝榪欐牱褰撶偣鍑昏繖涓狥orm閲岄潰鐨凜ommandButton鎴栬匔ommandLink鐨勬椂鍊欙紝JSF澶勭悊濂戒笟鍔¢昏緫鍚庯紝灝卞彲浠ュ皢To-View-ID鎸囧畾鐨勯〉闈㈣漿鍒頒富妗嗘灦欏甸噷闈㈠幓鏄劇ず浜嗐?br />

    <h:form target="mainFrame">
    <h:commandButton action="index">
    </h:form

    mainFrame

    鐐瑰嚮宸﹁竟鐨刢ommandButton涔嬪悗錛宨ndex澶勭悊涔嬪悗鐨凾o-View-ID鎸囧畾鐨勯〉闈㈠氨浼氭樉紺哄湪mainFrame閲岄潰浜?


    ]]>
    JSF欏甸潰涓敮鎸佺殑Expression Language(EL) http://m.tkk7.com/Vincent-chenxj/articles/242050.htmlVincent-chenVincent-chenSat, 22 Nov 2008 16:39:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242050.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242050.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242050.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242050.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242050.html浠ヤ笅鏄彲浣跨敤鐨凟L甯擱噺鐨勫垪琛細




    ]]>
    鍚庢潵紼嬪簭鎺у埗鍓嶅彴UI鎺т歡鐨勬柟娉?http://m.tkk7.com/Vincent-chenxj/articles/242049.htmlVincent-chenVincent-chenSat, 22 Nov 2008 16:38:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242049.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242049.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242049.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242049.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242049.html絎竴縐嶆柟娉曪細
    JSF欏甸潰涓殑浠g爜錛?br />
    <h:form id="messageForm">
    <h:outputText id="outputMessage"/>
    <h:commandButton value="Get Message"
    actionListener
    ="#{testForm.sendMessage}"/>
    </h:form>
    鍚庡彴紼嬪簭錛?br />
    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鏄疪egistrationForm涓殑涓涓狧tmlInputText綾誨瀷鐨勪竴涓彉閲忥紝閫氳繃binding灞炴у皢鍓嶅彴UI鎺т歡鍜屽悗鍙板悓綾誨瀷鐨勫彉閲忕粦瀹氾紝灝卞彲浠ュ湪鍚庡彴鐩存帴鎿嶄綔浜嗐?/span>

    ]]>
    Java Server Faces Events And Listeners (JSF涓殑浜嬩歡涓庣洃鍚櫒)http://m.tkk7.com/Vincent-chenxj/articles/242048.htmlVincent-chenVincent-chenSat, 22 Nov 2008 16:37:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242048.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242048.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242048.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242048.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242048.htmlJSF鐨勪竴涓牳蹇冨氨鏄簨浠朵笌鐩戝惉銆侸SF浜嬩歡鍒嗕負浠ヤ笅鍑犵錛?br /> 1銆乂alue-change events錛堝兼敼鍙樹簨浠訛級

    <h:inputText valueChangeListener="#{myForm.processValueChanged}"/>
    <h:panelGrid binding="#{myForm.changePanel}" rendered="false">

    </h:panelGrid>


     

    public void processValueChanged(ValueChangeEvent event)
    {
    HtmlInputText sender 
    =
     (HtmlInputText)event.getComponent();
    sender.setReadonly(
    true
    );
    changePanel.setRendered(
    true
    );
    }

    褰搃nputText鐨勫兼敼鍙樼殑鏃跺欎細瑙﹀彂processValueChanged浜嬩歡錛屾浜嬫儏鍐呴儴閫氳繃鍙傛暟錛岃幏鍙朒tmlInputText鐨勬帶浠訛紝鐒跺悗璁懼畾readonly錛屽悓鏃惰瀹歱anelGrid鐨勬ā鍨媍hangePanel鐨勫睘鎬э紝鍥犱負panelGrid緇戝畾浜哻hangePanel榪欎釜妯″瀷銆?br />
    2銆丄ction events(鍔ㄤ綔浜嬩歡)

    <h:commandButton type="submit" value="Login" action="success"
    immediate
    ="true"/>

    涓婇潰榪欎釜鏄潤鎬乷utcome浜嬩歡錛屽湪faces-config.xml涓厤緗浉搴旂殑灞炴у悗錛岀偣鍑昏鎸夐挳浼氳漿鍚戠浉搴旂殑鏂規硶銆?br />

    <h:commandButton value = "Test Action Listener" actionListener = "#{testActionListener.doSomeAction}" />

    濡傛灉娣誨姞浜哸ctionListener灞炴х殑璇濓紝鐐瑰嚮涔嬪悗錛屽湪杞悜鍏朵粬欏甸潰涔嬪墠錛屼細瑙﹀彂鎸囧畾鐨勪簨浠訛紝澶勭悊涔嬪悗鍐嶈漿鍚戙?br /> 榪欓噷鐨刣oSomeAction鏂規硶鐨勫0鏄庢槸void doSomeAction(ActionEvent actionEvent)銆?br />

    <h:commandButton type="submit" value="Login"
    action
    ="#{loginForm.login}"/>

    涓婇潰榪欎釜鏄姩鎬乷utcome浜嬩歡錛屽綋鐐瑰嚮璇ユ寜閽箣鍚庝細鐩存帴瑙﹀彂loginForm涓殑login浜嬩歡錛宭ogin浜嬩歡榪斿洖鐨勬槸涓涓瓧絎︿覆錛屽湪login澶勭悊瀹岀浉搴旀搷浣滀箣鍚庨渶瑕佽繑鍥炰竴涓睘鎬т腑宸茬粡閰嶇疆榪囩殑瀛楃涓詫紝渚嬪success錛岀劧鍚嶫SF鏍規嵁faces-config.xml涓殑閰嶇疆錛岃煩杞埌鐩稿簲鐨勯〉闈€俵ogin鐨勫0鏄庝竴鑸槸String login();

    褰撶劧涔熷彲浠ラ氳繃紼嬪簭鏉ユ坊鍔犵洃鍚櫒錛屼笉榪囩洃鍚櫒綾婚渶瑕佸疄鐜癆ctionListener鎺ュ彛錛?br />

    UIComponent myComponent = new UIComponent();
    myComponent.addActionListener(
    new
     TestActionListener());
    myComponent.addActionListener(
    new
     CustomActionListener());


    3銆丏ata model events錛堟暟鎹ā鍨嬩簨浠訛級

    FacesContext facesContext = FacesContext.getCurrentInstance();
    dataTable 
    =
     (HtmlDataTable)facesContext.getApplication().createComponent(
    HtmlDataTable.COMPONENT_TYPE);
    DataModel myDataModel 
    = new
     ResultSetDataModel(myResultSet);
    myDataModel.addDataModelListener(
    new
     DataModelListener()
    {
    public void
     rowSelected(DataModelEvent e)
    {
    FacesContext.getCurrentInstance().getExternalContext().
    log(
    "row selected:" +
     e.getRowIndex());
    }

    }
    );
    dataTable.setValue(myDataModel);

    灝嗕笂闈㈢殑浠g爜鏀懼叆鍒濆鍖栫▼搴忎腑錛屽綋琛岀殑閫夋嫨鏀瑰彉鐨勬椂鍊欏氨浼氳Е鍙戠浉搴旂殑鏃ュ織鎵撳嵃銆?br /> 榪欐槸鍥犱負榪欐浠g爜緇檇ataTable鎺т歡瀹氫箟浜嗕竴涓暟鎹ā鍨嬶紝鏁版嵁鍜岀浉搴旂殑浜嬩歡鍏ㄩ儴瀛樺湪榪欎釜鏁版嵁妯″瀷閲岄潰錛岀劧鍚庡皢dataTable涓庤繖涓ā鍨嬭繘琛岀粦瀹氬嵆鍙嬌鐢ㄥ畠鎵鏈夌殑鏁版嵁鍜屼簨浠躲傜偣鍑籨ataTable涓婇潰鐨勪竴琛岃嚜鐒朵篃灝變細鍑哄彂鐩稿簲鐨勮閫夋嫨浜嬩歡銆?

    4.Phase events錛堥樁孌典簨浠訛級

    榪欎釜浜嬩歡鏄負浜嗘崟鎹変竴浜涢樁孌靛拰榪囩▼鑰岃瀹氱殑錛屾湁浠ヤ笅鍑犱釜闃舵鍙互鎹曟崏錛?br />

     

    ANY_PHASE 浠諱竴闃舵
    APPLY_REQUEST_VALUES  璇鋒眰澶勭悊闃舵鐨勫簲鐢ㄨ姹傚奸樁孌?br /> INVOKE_APPLICATION 璇鋒眰澶勭悊闃舵鐨勮皟鐢ㄧ▼搴忛樁孌?br /> PROCESS_VALIDATIONS 璇鋒眰澶勭悊闃舵鐨勫鐞嗛獙璇侀樁孌?br /> RENDER_RESPONSE  璇鋒眰澶勭悊闃舵鐨勬弿榪板搷搴旈樁孌?br /> RESTORE_VIEW 璇鋒眰澶勭悊闃舵鐨勬仮澶嶈鍥鵑樁孌?br /> UPDATE_MODEL_VALUES 璇鋒眰澶勭悊闃舵鐨勬洿鏂版ā鍨嬪奸樁孌?/span>

     

    鍏蜂綋鍙互鍙傝?/span>http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/api/javax/faces/event/PhaseId.html

    閫氳繃璁懼畾鍦ㄥ疄鐜扮被涓瀹氱浉搴旂殑PhaseId浠ュ強娣誨姞鍒癴aces-config.xml涓氨鍙互鎹曟崏鐩稿簲闃舵浜嬩歡騫舵坊鍔犲搷搴旂殑浠g爜

    瀹炵幇綾?/span>

     

    import javax.faces.event.PhaseEvent;
    import
     javax.faces.event.PhaseId;
    import
     javax.faces.event.PhaseListener;

    public class CustomPhaseListener implements
     PhaseListener
    {    
        
    public
     CustomPhaseListener()
        
    {
        }


        
    public void afterPhase(PhaseEvent event)
        
    {
            System.out.println(
    "After Phase->" +
     event.getPhaseId());    
        }


        
    public void beforePhase(PhaseEvent event)
        
    {
            System.out.println(
    "Before Phase->" +
     event.getPhaseId());
        }


        
    public PhaseId getPhaseId()
        
    {
            
    return PhaseId.ANY_PHASE;//閫夋嫨浜嬩歡鏍囪瘑鐨勫父閲忥紝姝や負浠諱竴闃舵

        }
        
    }


    鍦╢aces-config.xml涓坊鍔?br />

    <lifecycle>
        
    <phase-listener>
            net.javabeat.articles.jsf.events.actions.TestActionListener
        
    </phase-listener>
    </lifecycle>


    褰撶劧鍙互娣誨姞鏃犻檺涓殑鐩戝惉鍣?br />

    <lifecycle>
        
    <phase-listener>PhaseListener1</phase-listener>
        
    <phase-listener>PhaseListener2</phase-listener>
    </lifecycle>


    涓嬮潰鏄姹傚鐞嗙殑鐢熷懡鍛ㄦ湡錛屽ぇ瀹跺彲浠ョ洿瑙傜殑鐪嬩竴涓嬪悇涓樁孌墊墽琛岄『搴忥細
     
    鍚勪釜闃舵鐨勮鏄庝互鍙婃墍鑳借Е鍙戠殑浜嬩歡
     



    ]]>
    JSF涓庡悗鍙扮▼搴忕殑浜や簰 http://m.tkk7.com/Vincent-chenxj/articles/242045.htmlVincent-chenVincent-chenSat, 22 Nov 2008 16:21:00 GMThttp://m.tkk7.com/Vincent-chenxj/articles/242045.htmlhttp://m.tkk7.com/Vincent-chenxj/comments/242045.htmlhttp://m.tkk7.com/Vincent-chenxj/articles/242045.html#Feedback0http://m.tkk7.com/Vincent-chenxj/comments/commentRss/242045.htmlhttp://m.tkk7.com/Vincent-chenxj/services/trackbacks/242045.html濡傛灉Managed-Bean宸茬粡琚垱寤哄茍瀛樺湪錛屽垯鍙互閫氳繃涓嬮潰鐨勫艦寮忚闂畇ession鑼冨洿鍐呯殑Managed-Bean
    org.test.TestBean x = (org.test.TestBean) request.getSession().getAttribute("testBean");


    濡傛灉涓嶅瓨鍦紝鍒欓渶瑕佸厛璁塊棶涓涓婱anaged-Bean錛岃浠栬瑙﹀彂鑰屽垱寤?br />
    org.test.TestBean x = (org.test.TestBean) Util.getBean("testBean"); 

    //In Util.java:

    public static Object getBean(String expr){
    FacesContext context 
    =
     FacesContext.getCurrentInstance();    
    Application app 
    =
     context.getApplication(); 
    ValueBinding binding 
    = app.createValueBinding("#{" + expr + "}"
    );
    Object value 
    =
     binding.getValue(context);  
    return
     value;
    }


    涓篔SF鎸囧畾Action錛屽彲浠ヨ繖鏍峰啓錛?br />
                 <h:commandButton action="#{user.verify}" value="Say Hello!">                 
                 
    </h:commandButton>
    User綾諱腑鐨勪唬鐮?
        public String verify()
        
    {
            
    return "hello";
        }
    faces-config.xml涓?
     <managed-bean>
      
    <description>User Name Bean</description>
      
    <managed-bean-name>user</managed-bean-name>
      
    <managed-bean-class>demo.User</managed-bean-class>
      
    <managed-bean-scope>session</managed-bean-scope>
     
    </managed-bean>
     
    <navigation-rule>
      
    <from-view-id>/pages/inputUserName.jsp</from-view-id>
      
    <navigation-case>
       
    <from-outcome>hello</from-outcome>
       
    <to-view-id>/pages/hello.jsp</to-view-id>
      
    </navigation-case>
     
    </navigation-rule>
    榪欐牱錛岀偣鍑繪寜閽紝灝變細杞埌verify鏂規硶涓繘琛岄獙璇侊紝鐒跺悗榪斿洖鐩稿簲緇撴灉鐨勫瓧絎︿覆錛宩sf鏍規嵁榪斿洖鐨勭粨鏋滆繘琛岀浉搴旂殑欏甸潰璺寵漿銆?br />

    ]]>
    主站蜘蛛池模板: 午夜dj在线观看免费视频| 亚洲一区二区三区四区视频 | 国产成人免费全部网站| 无码精品国产一区二区三区免费 | 国产一区二区三区在线免费 | 亚洲 欧洲 视频 伦小说| 久热综合在线亚洲精品| 亚洲免费无码在线| 国产高清免费的视频| 色片在线免费观看| 亚洲免费视频网站| 在线人成免费视频69国产 | 亚洲无线码一区二区三区| 国产一区二区三区在线观看免费| 永久免费av无码不卡在线观看| 99久久精品免费视频| 黄页免费在线观看| 国产成年无码久久久免费| 色爽黄1000部免费软件下载| 亚洲国产成人精品无码区二本| 亚洲狠狠成人综合网| 亚洲国产高清在线精品一区| 亚洲首页在线观看| 精品亚洲aⅴ在线观看| 亚洲激情中文字幕| 久久亚洲日韩看片无码| 久久亚洲AV无码精品色午夜麻豆| 亚洲av无码av制服另类专区| 亚洲av丰满熟妇在线播放| 久久精品国产亚洲av成人| 亚洲AV色香蕉一区二区| 亚洲国产成人片在线观看| 国产AV无码专区亚洲AV毛网站 | 一级特黄a大片免费| 一级毛片在线免费视频| 特级毛片爽www免费版| 国产精品99爱免费视频| 最近免费mv在线观看动漫 | 亚洲视频精品在线观看| 2022年亚洲午夜一区二区福利| 亚洲成a人片在线观|