Monday, 1 August 2016

First Simple JSF Application

Hello everybody!

The very first and very simple JSF project that we are going to develop will take the user name from the client and display it on the other page.

The project structure will be like below. After creating the JSF project, we will simply add two xhtml files and alter web.xml file. That's all.




To create the index.xhtml file, follow the steps like you are to create a html file and then change the extension  to xhtml. You can choose the custom page template for JSF that you own created at that stage. To see how to create a custom page template you can go here. Final version of your index.xhtml file will look like this:

As you can see above, we have a form which asks user to enter a user name as an input. Our input text element will take a parameter from a user and store it in "#{clientName}". Clicking on the commandButton element, the form will call the "responsepage"

responsepage.xhtml will look like below. In this page we will display the user name that we store in "#{clientName}".

As a last step, we will change <welcome-file-list> in web.xml file. So that when the application starts, it will know which file to look for.
When you run the project, you will see the window below.


Hope to see you in the next blog post!

Selen

No comments:

Post a Comment