AppFUSE learning notes - view layers

xiaoxiao2021-03-06  19

1. Program Description The view layer is mainly composed of JSP web pages, and also includes Resource Bundle resource files and ActionForm Beans, Validation, etc. These components provide support for international, receiving user input form data, form validation, and error handling. The files related to the user's view layer are: UserList.jsp: User list page, used to manage other users of users with administrative privileges. Userform.jsp: User Information page, used to increase, delete, modified Userform.java: Actionform Bean Validation.xml corresponding to user information form: Validation file Bundle resource file, Chinese The ApplicationResource_zh_cn.properties default.jsp: Sitemesh file JavaScript, CSS file for the composite web page

2. The JSP page related to the user includes the user list and user information. General information such as HEAD and FOOT is placed in head.jsp, foot.jsp, so userlist.jsp and userform.jsp only contains labels related to the business. The following describes the main labeling features: : Judging whether the specified message exists. If you specify the Message property to True, retrieve the properties key from the Request range for the ActionMessages object of Globals.Message_Key. If the property is not specified, the default retrieval property key is the actionMessages object of Globals.Error_Key. In this system, a SUCCESS message is retrieved, an Error message is retrieved. : JSTL tag. A message used to output the resource bundle. : Used to retrieve the inner objects in the Struts framework, such as ActionFormbean, ActionForward, ActionMapping. Here is used here to define an ActionForward variable on the JSP page to facilitate other references. Forward is the Global-Forward defined in Struts-Config.xml. : JSTL tag. Used to define a variable to facilitate reference to other places. : JSTL tag. Used to display a value of an EL expression on a page, such as displaying a variable defined by . EL is a simple expressive language adopted by JSTL, which provides a simple way to access and operate application data. : jstl tag. The tag for processing conditions, controls the output web page content according to a particular logic condition, or loop all elements in the collection. : Display Tag's label for displaying the LIST returned by the control layer. It can be convenient to customize the table, sort, export data, etc. : Used to define the HTML form. The Struts HTML tag can complete the same function as the standard HTML element, and the Struts framework automatically maps the data in the form to the corresponding ActionForm Bean.

Custom Tags: When you initially run Ant New, AppFuse automatically generates a label file based on the item name you typed, you will see this label in userform.jsp. : It is used to display the prompt text before the form input field, add some special styles to the text, such as automatically add "*", etc. before the required item. : There is a country in Userform, which is used to display the country's drop-down list. : Used to display the value of constant in constant class org.appfuse.constants on a page. 3. Actionform Bean ActionForm Bean is a form data transfer object provided by Struts, which is used to pass HTML form data between the view layer and the control layer. The control layer can read the form data input from the ActionForm Bean, or the data from the model layer can also be stored in the ActionForm bean and then returned to the view. User form Actionform Bean is Userform. Userform inherits Baseform. Baseform is a sub-object of ActionForm, which extends three general methods: toString (), Equals (Object O) and hashcode (). And define a verification, which is used to allow the user that the form does not have to verify when you click the "Delete" or "Cancel" button. Userform defines the properties corresponding to the fields in the user information form.

4. Validator Verify the Frame Validator Verification Framework is responsible for data verification, using XML-based configuration files to configure verification rules. Its related documents are: validation.xml: The verification rules required for the ActionForm configuration for specific Struts forms. Validator-rules.xml: Frame comes with files, including a set of generic validation rules. Validator-rules-custom.xml: Custom verification rules. This system defines a rule that verifies if two specified input domain values ​​are equal. Used to verify the password and confirm that the password is equal. In fact, this method will be modified slightly, and "=" becomes "<,>" to verify that a domain cannot be greater than / less than another domain, very practical. Resource Bundle: Defines the prompt text that is displayed when the verification fails. Most of the RESource Bundle is used in ErrorS prefix for the error prompt for Validator. Below is the Userform authentication rule configured in validation.xml

转载请注明原文地址:https://www.9cbs.com/read-41433.html

New Post(0)