Developed using JSF (Java Server Faces)

xiaoxiao2021-03-06  56

Resources: instance http://www.crossbar.info/ myface http://www.myfaces.org/ Translator: FPWANG) JAVA Server Faces (JSF) technology provides Java developers based on network user interface Standard programming interface API and tag library. The Apache Struts frameworks Assist in leading Sun's JSF project. This allows the project to be easily transplanted from the popular Apache to the JSF standard. Just like the Struts framework, JSF defines a set of JSP tags that can generate an HTML form element that is bound to the Javabean property. From the perspective of the application developer, both frameworks are very similar, but JSFs may get more support. Because JSF is the standard of Java. In the future, there may be all J2EE application servers need to support JSF (Java Server Faces). Sun Inn the free download of Java Web Services Developer Pack 1.2 (http://java.sun.com/webservices/downloads/webservices), including JSF (JSF Specification Version 1.0, public review Reference implementation of Draft 2) (Early Access 4 - EA4). The EA4 version implements many new features: action, beans management and navigation rules. This article will focus on these new features and show how to get benefits from JSF development to establish a form, confirm user input, and bind user interface components to JavaBeaN properties. This article contains a network application consisting of four main parts: 1. JavaBean class (PBean.java), saving some text as a data model and related properties: font, size, color, placement location, etc. 2. Based on JSF Form (edit.jsp), user can assign a value for JavaBean attribute; 3. Java class (pbuilder.java), generate HTML page programs with a given text; 4. JSP page (view.jsp), Display the generated HTML page. Note: Source code download address: http://www.onjava.com/onjava/2003/09/03/EXAMPLES/USINGJSF-SRC.ZIP related documentation Original: Introducing JavaServer Faces (http://www.onjava.com/ Pub / A / ONJAVA / 2003/07/30 / JSF_INTRO.html translation: http://www.matrix.org.cn/forum_view.asp? forum_id = 14 & view_id = 658 JavaServer Faces (or JSF) is a server program Develop a new trend. It allows you to make your more easily design, your program can easily maintain, and may even make your work more interesting. Budi Kurniawan showed us JSF technology to explain why JSF is so useful and whether it has implemented the functions committed.

Figure 1: JSF-based form making JSF form When you develop network applications, the HTML form is the most common task. A good frame can save a lot of development time, because many daily program operations can be done automatically or to minimize only need to be done in the XML file. This is also possible to simplify network development using the JSP tag library. The Java Server Faces framework provides JSP tags for describing the form, managing form status, confirming user input, and error, binding user interface components with JavaBeaN properties, and many other functions that improve development efficiency. JSF also has a rich programming interface to establish a custom user interface (UI) component, custom verification class (verifier Validator), and server event listener. JSF contains two types of tag libraries to name the JSF core library and HTML base library, respectively. The former provides normal markers and some tags for registering the validator in the user interface components and event listeners. The latter includes a JSP tag for describing user interface components, such as buttons, text domains, check button, list, and more. File edit.jsp creates a form with these tags. The standard prefix of the two tag libraries is F and H, and the front of the edit.jsp file is defined: <% @ taglib prefix = "f" uri = "http://java.sun.com/jsf/core"; %> <% @ Taglib prefix = "h" URI = "http://java.sun.com/jsf/html";%> tag is a container tag, must contain all the same pages JSF tag. This tag does not generate any HTML content, but it triggers the internal mechanism of JSF. tag generates an HTML element

capable of containing user interface elements. Edit </ title> </ head> <body> <f: use_faces> <h: form formname = "pform"> ........ </ h: Form> </ f: Use_faces> </ body> </ html> The above JSP code generates the following HTML pieces: <html> <head> <title> Edit </ title> </ head> <body> <form Method = "post" action = "/ usingjsf / faces / edit.jsp"> ......... </ form> </ body> </ html> The next section of the application's JavaBean model. Managing Beans Like some other web frameworks, JSF separates the user interface from packaged data and application logic's object model. When the HTML user interface is generated by the JSF tag, the JSF framework obtains data from the JavaBean model and sets the properties of the HTML form user interface component. When the user submits the form, the JSF verifies the user input. If all normal JSF saves the user input to the JavaBean model and the HTTP request will go to the next page according to the "Navigation Rules". If an error occurs, the JSF returns to the form and returns an error message so that the user can correct the error input.</p> <p>Class PBEAN follows the JavaBean specification to implement the corresponding GET and SET methods for its properties (text, size, font, color, placement position, bold, slope, underscore). The user of each application of JSF creates an instance of a PBean, which is stored in a JSP session (session) and specifies the ID in the XML format profile named Faces-Config.xml. JSF will also initialize the property value of the JavaBean instance based on the data provided by the Faces-Config.xml file. The XML file may also contain other JSF configuration parameters, such as navigation rules, we will introduce later in the following chapters.</p> <p>The following XML program is broken contains the JavaBean managed by JSF: <? XML Version = "1.0"?> <! Doctype faces-config public "- // Sun microsystems, Inc.//dtd javaser Faces config 1.0 // En "" http://java.sun.com/dtd/web-facesconfig_1_0.dtd ";> <faces-config> ......... <management-bean> <management-bean-name> PBean </ managed-bean-name> <management-bean-class> com.devsphere.An-scope> session </ management-bean-scope> session </ management-bean-scope> session </ management-bean-scope> session </ managed-bean-scope> < Managed-proteTy> <property-name> text </ profy-name> <null-value /> </ management-property> <management-property> <property-name> size </ profy-name> <value> 3 < / value> </ managed-protety> <management-property> <property-name> font </ profy-name> <value> <value> arial </ value> <value> Courier New </ value> </ value> </ managed-protety> <management-property> <property-name> Color </ Property-Name> <value> green </ value> </ management-property> <management-property> <property-name> align </ profoyal-name> <value> left </ value> </ management-property> < Managed-proteTy> <property-name> bold </ property-name> <value> false </ value> </ management-property> <management-property> <property-name> Italic <</p> <p>/ Property-Name> <value> true </ value> </ management-protety> <management-property> <property-name> underline </ printy-name> <value> false </ value> </ managed-property> </ managed-bean> </ faces-config> The management bean created by JSF can be stored within the request (Session) or application according to the value of the <managed-bean-scope> element. The value of <managed-bean-scope> element can be empty. If an object already specifies the ID and register, JSF does not establish a JavaBean instance within a given range. User Interface Components and Verify Files Edit.jsp In <h: form> elements in edit.jsp contain multiple user interface components, we will introduce in detail later. The HTML code of each component is generated by the JSF component tag, for example: <h: infut_textArea>, which may also contain other JSF tags, such as: <f: validate_required> tag, the tag makes the JSF to confirm that the user entered information. . Handling the components entered by the user use attributes VALUEREF = "pBean.property" binds with the Javabean property. JSF Get and Set Management Bean Properties is already introduced earlier. Some JSF component tags do not handle any user input. For example <H: Output_Text> can be used to output a value of the text or JavaBean read-only properties. Each component has a unique ID, ID can be specified in the ID attribute or automatically generated by JSF. The user interface component to be verified requires the ID attribute to verify that the error can be displayed together with the <h: output_errors for = "id" />. Figure 2: Verifying the text field of the error text Domain Text Area JSF form allows the user to generate the PBUILDER.JAVA and display some text paragraphs displayed by View.jsp. Edit.jsp shows a label determined by <h: Output_Text> and use <H: Input_TextArea> to generate <textarea> HTML elements of 3 rows 30 columns. <f: validate_required> Tag registers a JSF verifier, if the user in the text domain is empty, the error signal is issued. The error message will be displayed in the <h: Output_ERRORS> tag, except that the tag does not do anything else except that the error is displayed. <h: Output_ERRORS> The value of the for attribute value is the same value as the ID attribute value of <H: Input_TextArea>.</p> <p><F: USE_Faces> <h: form formname = "pform"> <p> <h: output: "/> <br> <h: input_textarea id =" text "valueref =" pbean.text "ROWS = "3" cols = "30"> <f: validate_required /> <f: infut_textarea> <br> <h: output_errors for = "text" /> ......... </ h: Form> </ f: Use_faces> The above JSP code generates the following HTML pieces: <form method = "post" action = "/ usingjsf / faces / edit.jsp"> <p> text: <br> <textarea name = "Text" cols = "30" rows = "3"> javaServer Faces </ textarea> <br> ......... <</ form> <h: input_textarea> attribute valuef = "pbean.text "Make the JSF look up the ID of the JavaBean instance, and store the text entered into the text property of the JavaBean instance. When the HTML form is generated, the JSF inserts the TEXT attribute value into the <textarea> HTML element. The class PBean implements the GET and SET methods to allow JSF values ​​to obtain or modify attributes: public class pbean imports java.io.serializable {private string text; public string gettext () {returnization;} public void setxt (String text) { Thistext = text;} ........} In addition to <H: Input_TextArea>, JSF also provides a number of tags that generate a single line text domain (Text Field): l <intput_text> l <h: Input_Number > l <input_secret> (Password input) L <input_date> l <input_datetime> l <input_time> l <input_hidden> can be used to hide a single line text field component of the text field Edit.JSP file only Allow numbers between 1 to 7. This HTML code is generated by <h: infut_number>, which contains two validiar. <f: validate_required> tag has been introduced in front.</p> <p><f: validate_longrange> tag is to make the verifier confirms the number of users entered within a given range. If the range is exceeded, the verification error is reported to the user, and the error message is generated by <h: Output_ERRORS>. <f: USE_Faces> <h: form formname = "pform"> ........... <p> <h: output_text value = "size: [1-7]" /> <br> <h : input_number id = "size" valueref = "pBean.size" size = "2"> <f: validate_required /> <f: validate_longrange minimum = "1" maximum = "7" /> </ h: input_number> <br > <h: output_errors for = "size" /> ......... </ h: form> </ f: Use_faces> The above JSP code generates the following HTML pieces: <form method = "POST "Action =" / usingjsf / faces / edit.jsp "> ......... <p> size: [1-7] <br> <input type =" text "name =" size "id = "size" value = "3" size = "2"> <br> ......... </ form> The single line text domain is set to size, the type is shaped (int). The value of the value attribute in the size is the initial value indicating the generated HTML form digital input area. Assume that no verification error occurs, when the JSF receives user inputs that contain new JavaBean size attribute values, JavaBean will be refreshed. The size property of the <h: input_number> tag is the character length (2) defining a single line text domain, and does not have other operations for the JavaBeaN property.</p> <p>Public class pBean Implements java.io.serializable {........ private int size; public int getsize () {return size;} public void setsize (int size) {this.size = size;}. .......} In addition to <f: Validate_Required> tagged, JSF also provides several validator tags: l <validate_doublerange> L <validate_stringrange> L <validate_length> L <validator> The last one is a general-purpose tag, which can be used to register your own custom validator in the user interface components. You can also create your own verifier tag library. List List Box <h: selectone_listbox> and <H: SelectMany_Listbox> Tag Generate HTML Elements <SELECT>, web browsers will display <select> as a list. The former allows the user to make a single option, the latter is used for multiple selections. File edit.jsp uses the <h: SelectMany_Listbox> tag to generate a list of several font names.</p> <p>HTML <option> Element defines the options in the list, which is marked by JSF <h: selecttem> Generate: <f: Use_faces> <h: form formname = "pform"> ......... <p > <h: out: "/> <br> <h: selectmany_listbox id =" font "valueref =" pbean.font "> <h: selectitem itemvalue =" arial "itemlabel =" arial "/> < H: selectitem itemvalue = "Courier new" itemlabel = "Courier new" /> <h: selectitem itemvalue = "Times new Roman" itemlabel = "Times New Roman" /> </ h: SelectMany_Listbox> ....... ... </ h: form> </ f: Use_faces> The above code generates the following HTML pieces: <form method = "post" action = "/ usingjsf / faces / edit.jsp"> ...... .... <p> font: <br> <select name = "font" multiple size = "3"> <option value = "arial" successd> arial </ option> <option value = "Courier new" SELECTED> Courier New </ option> <option value = "Times New Roman"> Times New Roman </ option> </ select> ........ </ form> list is defined as font, type is character String array (String []). The first getFont () method uses the clone () method to copy the internal array and returns it, and the internal array must be protected from external access. The first setFont () method is replicated with the clone () method to copy the provided array and saved, and the array provided can be modified by the second setFont () method.</p> <p>Public class pbean imports java.io.Serializable {........ private string fontarray []; public string [] getFont () {return (String []) fontarray.clone ();} public void setFont (String fontArray []) {this.fontarray = (String []) fontarray.clone ();} public string getFont (int index) {return fontarray [index];} public void setFont (int index, string font) {ix (FontArray == NULL) FONTARRAY = New String [INDEX 1]; Else IF (FontArray.Length <= index) {string OldFontArray [] = fontArray; fontarray = new string [index 1]; for (int i = 0 I <oldfontarray.length; i ) fontArray [i] = OldfontArray [i];} fontArray [index] = font;} ........} JSF will be selected when generating an HTML form The HTML property is added to the list option, and the value of the list option is saved in the font array of the JavaBean model. Assuming that there is no verification error, JSF refreshes the JavaBeaN property when receiving the new user's new selection font. Drop-Down List <h: Selectone_Menu> tag is used to generate a drop-down list containing several color options.</p> <p><h: selectItem> tag is included in <h: selectone_menu>, as a drop-down list option: <f: use_faces> <h: form formname = "pform"> ......... <p> < H: Output_text value = "color:" /> <br> <h: selectone_menu id = "color" valueRef = "pbean.color"> <f: validate_required /> <h: selectitem itemvalue = "black" itemlabel = "Black "/> <H: selectitem itemvalue =" red "itemlabel =" red "/> <h: selectitem itemvalue =" blue "itemlabel =" blue "/> <h: selecttem itemvalue =" green "itemlabel =" green "/ > </ H: selectone_menu> <br> <h: Output_errors for = "color" /> ......... </ h: form> </ f: USE_Faces> The above JSP code generates the following HTML pieces: <form method = "post" action = "/ usingjsf / faces / edit.jsp"> ......... <p> color: <br> <select name = "color" size = "1"> <option value = "black"> black </ option> <option value = "red"> red </ option> <option value = "blue"> blue </ option> <option value = "green" Selected> Green </ option> </ select> <br> ........ </ form> The drop-down list is defined as a color, the type is a string (S TRING): Public Class Pbean Implements Java.io.Serializable {........ private string color; public string getColor () {return color;} public void setcolor (string color) {this.color = Color ;</p> <p>} ........} When the HTML form is generated, JSF adds the HTML property Selected to the value of the value as the JavaBean model Color property. Suppose there is no verification error, the JSF receives the JavaBeaN property after receiving the user input containing the new color value.</p> <p>Single ban button <h: selectone_radio> with the <h: selecttem> tag to generate a set of single tab: <f: use_faces> <h: form formname = "pform"> ....... ... <p> <h: Output_text value = "Alignment:" /> <br> <h: selectone_radio id = "align" valueref = "pbean.align" layout = "line_direction"> <f: validate_required /> < H: selectitem itemvalue = "left" itemlabel = "left" /> <h: selectitem itemvalue = "center" itemlabel = "center" /> <h: selecttem itemvalue = "right" itemlabel = "right" /> </ h : selectone_radio> <br> <h: Output_errors for = "align" /> .......... </ h: form> </ f: Use_faces> The above JSP code is generated as follows: <Form Method = "post" action = "/ usingjsf / faces / edit.jsp"> ......... <p> alignment: <br> <table border = "0"> <tr> <td> < Input type = "radio" check name = "align" value = "left"> Left </ td> <td> <input type = "radio" name = "align" value = "center"> center </ td> <CENTER> Center </ td> < TD> <input type = "Radio" name = " Align "value =" right "> Right </ td> </ tr> </ table> <br> ........ </ form> radio button defined as Align: Public Class PBean Implements Java .io.serializable {........ private string align;</p> <p>Public string getAlign () {return align (} public void setalign) {this.align = align;} ........} When the HTML form is generated, JSF adds HTML property Checked to JavaBean. The model of the Align property value of the model is in the same number of options. If there is no verification error, JSF refreshes the JavaBeaN property when the user input of the new placement location is received. The check button (checkbox) file edit.jsp contains three checkons generated by the <H: SelectBoolean_Checkbox> tag.</p> <p>These interface components are included in the table (Table) generated by <h: panel_grid> tag: <f: use_faces> <h: form formname = "pform"> ......... <P> <h: output_text value = "style:" /> <br> <h: panel_grid color color color color color color color color color color color color = "0" cellspacing = "5"> <h: panel_group> <h: selectBoolean_CheckBox ID = "bold" valueref = "pbean.bold" /> <h: output_text value = "bold" /> </ h: panel_group> <h: panel_group> <h: selectboolean_checkbox id = "italic" valueF = "pbean.italic" /> <H: Output_text value = "italic" /> <h: panel_group> <h: selectboolean_checkbox id = "underline" valueref = "pbean.underline" /> <h: output_text value = "underline "/> </ H: panel_group> </ h: form> </ f: Use_faces> The above code generates the following piece: <form method =" post " Action = "/ usingjsf / faces / edit.jsp"> ......... <p> style: <br> <table border = "0" cellspacing = "5"> <tr> <TD> <input type = "checkbox" name = "bold"> bold </ td> <TD> <input type = "checkbox" name = " Italic "Checked> Italic </ TD> <TD> <input type =</p> <p>"CheckBox" name = "underline"> underline </ td> </ tr> </ table> ........ </ form> 3 copies and types are boolean Bind, Italic, Underline Binds: Public Class Pbean Implements Java.io.Serializable {........ private boilean bold; public boolean isbold () {return bold;} public void setBold (Boolean Bold ) {this.bold = bold;} private boolean italic; public boolean isItalic () {return italic;} public void setItalic (boolean italic) {this.italic = italic;} private boolean underline; public boolean isUnderline () {return underline PUBLIC VOID SETUNDERLINE (Boolean underline) {this.underline = underline;} ........} When generating an HTML form, JSF adds the checkage attribute to each JavaBeaN property is true (TRUE). In the tab. If there is no verification error, JSF will refresh the JavaBeaN property after receiving the user input. In this example, the check button is independently generated separately. JSF also provides the <h: selectmany_checkboxlist> tag to generate a set of checkup buttons. It also provides <h: panel_list> and <h: panel_data> two tags for generating a table from a collection and array. Command button (Command Buttons) Faces-config.xml defines the navigation rule, determines what JSF does when the user clicks the command button in the web page, the page path is specified by the <from-tree-id> tag (/Edit.jsp) .</p> <p>Two navigation cases (Navigation Case): ......... <faces-config> <navigation-id> /edit.jsp </ from-tree-id> <navigation-case> <from-outcome> EditOutcome </ from-outcome> <to-tree-id> /EDit.jsp </ to-tree-id> </ navigation-case> <Navigation-Case> <from-outcome> ViewoutCome </ from-outcome> <to-tree-id> /view.jsp </ to-tree-id> </ navigation-case> </ navigation-rule> .. ....... </ faces-config> file edit.jsp contains two buttons generated by tag <h: command_button>. Each has a logo (ID), a label, a command name (not used here, but JSF needs) and an action or actionRef property: <f: use_faces> <h: form formName = "pform"> ... ....... <p> <h: command_button id = "view" label = "view" commandName = "viewcmd" action = "viewcome" /> <h: command_button id = "bolduppercase" label = "bold Upper Case / View "CommandName =" bolduppercasecmd "ActionRef =" PBean.BoldupPercaseAction "/> </ h: form> </ f: USE_FACES> The above JSP code generates the following HTML pieces: <form method =" post "action =" / usingjsf /faces/edit.jsp "> ......... <p> <input type =" submit "name =" view "value =" view "> <input type = Submit" Name = "bolduppercase "Value =" bold upper case / view "> </ form> JSF will verify the data in the form when the user is submitted to the user per time.</p> <p>If the validator does not make an error signal and there is no type of conversion error, the JSF will analyze the navigation code. For the first button, the JSF will get the value of the Action property, which matches the text of the <from-Outcome> element of the second navigation block. Therefore, JSF forwards the HTTP request to View.jsp, and the path of the file View.jsp is included in the <TO-Tree-id> element of the second navigation block. When the user clicks on the second button, JSF calls the getBoldUpperCaseAction () method of the PBean object. This method returns an instance of a boldupPercaseAction, BoldupPercaseAction is the internal class of the PBean. Next, JSF calls the invoke () method, which returns a result of the runtime decision rather than fixed HTML files: public class pbean imports java.io.serializable {........ public bolduppercaseAction getBoldUpperCaseAction () {return new BoldUpperCaseAction ();} public class BoldUpperCaseAction extends javax.faces.application.Action {public String invoke () {String ucText = getText () toUpperCase ();. if (isBold () && getText (). Equals (UcText)) Return "ViewOutcome"; Else {setBold (True); setText (UcText); return "editoutcome";}}}} If the value of the bold (bold) property is True (true) and all characters of the text For capital, JSF is forwarded to View.jsp with another button situation in accordance with the definition of the second navigation block. In addition, the invoke () method will set the bold property to true and change all the characters of the text to uppercase, and finally returns the string Editoutcome, so that the JSF will follow the definition of the first navigation block, keep edit.jsp as the current page.</p> <p>Processing form data comprises a static class pbuilder method PBean examples according to the attribute parameters and generates HTML object JavaBean: package com.devsphere.articles.usingjsf; public class PBuilder {public static String toHTML (PBean pbean) {StringBuffer buf = new StringBuffer (); Buf.append ("<p align = /"); buf.append (pBean.getalign ()); buf.append ("/"> "); buf.append (" <font size = / " "); Buf.append (pBean.getsize ()); buf.append (" / "color = /" "); buf.append (pBean.getColor ()); buf.append (" / "); Object Font [] = pBean.get (); if (font! = null && font.length> 0) {buf.Append ("face = /"); for (int J = 0; j <font.length; j ) ) {IF (j> 0) BUF.Append (','); buf.append (font [j]);} buf.append ("/");} buf.append (">"); if ( PBean.isbold ()) BUF.Append ("<b>"); if (PBean.isital ()) BUF.Append ("<i>"); if (PBean.Isunderline ()) BUF.Append "<u>"); string s = pBean.getText (); int n = s.Length (); for (int i = 0; i <n; i ) {char ch = S.Charat (i); switch (CASE '<': buf.append ("<"); Break; Case '>': buf.append (">"); Break; Case '&': buf.append ("&"); Break;</p> <p>Case '"': buf.append (" ""); break; default: buf.append (ch);}} f (pBean.isunderline ()) BUF.Append ("</ u>"); if (PBean .isitalic ()) buf.append ("</ i>"); if (PBean.isbold ()) BUF.Append ("</ b>"); buf.append ("</ font>"); BUF .append ("</ p>"); return buf.tostring ();}}} file view.jsp with <jsp: usebean> to get JSF management JavaBean instance, call PBUilder's ToHTML () method, and output HTML results. JSF's <h: command_hyperlink> tag is used to provide an overlink return: <% @ taglib prefix = "f" URI = "http://java.sun.com/jsf/core";%> <% @ Taglib prefix = "h" URI = "http://java.sun.com/jsf/html";%> <html> <head> <title> view </ title> </ head> <body> <jsp: usebean id = "pbean" scope = "session" class = "com.devsphere.Articles.usingjsf.pbean" /> <% = com.devsphere.articles.usingjsf.pbuilder.tohtml (PBean)%> <f : use_faces> <h: command_hyperlink label = "back to editing" href = "edit.jsp" /> </ f: use_facees> </ body> </ html> Figure 3: Configuring the page application displayed by View.jsp Display JSF The framework has a server-side server that implements the controller (a servlet) called FaceSservlet, which must intercept all JSP pages containing the JSF tag. This applet is configured in the application descriptor file Web.xml and maps the URL mode to / Faces / *. To activate this applet, the path in the JSP program must begin with "faces".</p> <p>Application Home INDEX.JSP calls response.sendredirect () Transfer the browser to the Faces / Edit.jsp page: <% response.sendredirect ("faces / edit.jsp");%> File Faces-config.xml path Description of the Descriptor File Web.xml describes that in the descriptor file also includes a listener registration and some reference descriptions for JSF implementation. The contents of the file web.xml are as follows: <? XML Version = "1.0"?> <! Doctype web-app public "- // sun microsystems, Inc.//dtd Web Application 2.3 // en" "http: / /java.sun.com/dtd/web-app_2_3.dtd ";> <web-app> <context-param> <param-name> javax.faces.Application.config_files </ param-name> <param-value> /Web-inf/faces-config.xml </ param-value> </ context-param> <context-param> <parame-name> com.sun.faces.savestateInClient </ param-name> <param-value> False </ param-value> </ context-param> <context-param> <parame-name> com.sun.faces.validatexml </ param-name> <param-value> true </ param-value> </ PAARM-VALUE> </ Context-param> <listener> <listener-class> com.sun.faces.config.configlistener </ listener-class> </ listener> <servlet> <servlet-name> FacesSrvlet </ servlet-name> <servlet-class > javax.faces.Webapp.Facesservlet </ servlet-class> <load-on-startup> 1 </ loading-on-startup> </ servlet> <servlet-maping> <servlet-name> FacesServlet </ servlet-name > <URL-PATTERN> / Faces / * </ url-pattern> </ servlet-mapping> </ web-app> When generating a form for the first time, JSF creates a object called component tree (Component Tree). Structure, which includes user interface components and validator (Validator) registered these components, and the like. When the user submits form data, the JSF performs some operations according to the information in the component tree, such as verifying the user input.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-83669.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="83669" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.047</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'oCXU3BotHeX_2FnAiAEas7k0oS6ae62Xf9wrJqoL4ToC015xRBHeO_2F5BPXY4NcBC5lsOZhXduqx5ra0WTaxXKLsA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>