Introducing Java Server Faces (JSF) - JSF in the Real World (Page 4 of 4 )
So to put the theories discussed till now into practice, I will be creating a simple login module with two navigation cases. If the validation succeeds it will show the welcome page or else it will show the login page again. The components of this application are:
Login.jspx: the login page view. It uses JSF UI Components such as Input Text and the command button.
Login.java: the managed bean for Login.jspx. It contains the event handler for the submit button.
Welcome.jsp: the page to be shown when the validation succeeds.
faces-config.xml: the descriptor that contains the navigation case.
So here is the code of Login.jspx. This file uses the XHTML format, hence the .jspx extension.
Since the file uses the XHTML format, the root tag is jsp:root indicating that XHTML has to be the output. Next each component is bound with its reference in the managed bean using the binding attribute. Finally the commandButton Component is bound to the Listener using the action attribute.
The commandButton1_action() contains the logic to be executed when the submit button is clicked. All others are getters and setters for the UI Components. In essence the managed bean is a JavaBean.
Next is the Welcome.jspx. It just contains a "Welcome" message.
That brings us to the end of this discussion. What I have discussed is just the tip of the iceberg known as JSF. There are certain pieces that I have not explained completely, especially the UI Components. These pieces will be the focus of the next discussion. Till then...
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.