A basic JSF application to manage Freeradius-2

Now it is time to examine xhtml files. First of all, you need to have a welcome file list. Please add a figure like following;


You can find my web.xml file in jsfapplication/src/main/webapps/webinf.

Webapp folder is where you add your xhtml files.

-Right click to the webapps folder.

-Click new

-Click HTML File

-Choose xhml file format then enter the name of the xhtml file. This will be where you write your html code with Primefaces themes.

We must be careful when we write tags. We must put h before tag names else the themes will not be seen. Such as;

    <title>ADD USER</title>

In my xhtml files, i used panels, datatables, outputlabels, inputtexts, command buttons and select check boxes. You can find my xhtml files in jsfapplication/main/webapp.

Now let’s examine the necessary tables for our database. As i mentioned in my first article, there is a one-to-many relationship between a user and role. That is why i created a cross table that has the id of a user and the id of a role. The structure is

    roleId NOT NULL

And we need the role table like following;

roleName VARCHAR(100)

And for the users, we are going to use radcheck table.

For this relationship, i created an extra dao to manage the actions more efficiently.The queries for the cross table( the insertions and deletions) are done in this dao. And we use this table to get the roles of all the users. To prevent the dublicates, i used maps and sets in the dao of user.

Finally, i will explain the unit tests. First of all my reference book was junit recipes by rainsberger, a very straightforward textbook that explains how to write test classes of a jsf project.

First, you need to add Groovy plugin and dependencies.Add the dependency like following;


Add the plugin like following;

Go to Files-Settings-Plugins and if there is no groovy, please press + button to add Groovy.

After that you should be getting a package under your base package called groovy. That package will be the place for your test classes.

You can write test classes or methods for everything in your project. For constructors, functions, queries, objects, getters and setters, etc. The main idea is that you should test what is not supposed to happen. If it does, the test class is working; which means there is something wrong with your testcase.

The structure is easy. When you right click to your class and say create test, it will automatically be opened. Your test class should be extended to GroovyTestCase . And the return types of your functions will be in the format of

assertEquals(<expected parameter>,<actual parameter>)

You can examine my test classes that i have written for possible errors in jsfapplication/main/java/Groovy.

That will be all for my project. If you have any concerns,  please reach out to me i would be happy to get the critizations from you. Enjoy your coding!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s