A Complete Run Procedure of JSF Web Applications – Develop Java Web Applications to Access Databases

8.1.6.5  A Complete Run Procedure of JSF Web Applications

As we mentioned, a UI component represented by a JSF tag in a JSP page can be bound to a Java bean’s property or method. To separate the presentation and business logic, we can use JSP pages to present our GUI and Java beans to store our data to perform business-related logic. Therefore, we can divide methods into two categories: data access methods (business methods) and action methods. Data access methods should be located at the Java bean side, and action methods should be located at the JSF page side. Each data access method defined in the Java bean can be called by

an associated action method defined in an action attribute of a submit button tag in the JSP page if that submit button has been bound to the action attribute.

Here, we use a login process to illustrate the operational procedure using the JSF technique. Two JSP pages, LogIn.jsp and Selection.jsp, and a Java bean class, LogInBean.java, are involved in this procedure. Two JSP pages work as views and are used to display the input and out-put login information, and the Java bean works as a model to handle the database-related processing and business logic. The functional procedure of this example application is:

1) When the user enters a username/password pair into the Username/Password input text fields in the LogIn.jsp page and clicks on the LogIn button, a query request is sent to the Web server with all form data (Username and Password) for processing.

2) After the server receives the request, if the validation passes, all form data (Username and Password) will be stored in the associated properties of the Java bean.

3) The action method that is bound to the LogIn button will call the data access method defined in the Java bean to perform the database query to find the matching login informa-tion in the LogIn Table.

4) If the data access method is successful, the next page, Selection.jsp, should be displayed.

To run this procedure using the JSF technique, we need to have a clear picture of JSF pages and Java beans and the page-to-page navigation schedule.

Leave a Comment



                    Blog, Contribute ,Privacy,Terms of Use,Trademarks,© estherknow 2024