Author Topic: Homework #2  (Read 378 times)


  • Administrator
  • Newbie
  • *****
  • Posts: 13
    • View Profile
Homework #2
« on: August 07, 2018, 11:04:32 PM »

This is time for homework #2, you all know how to build a web-based project. The deadline for this homework is 8/17/2018 11:00PM.

Please start it today, since it will take you time to get it done.

Here is specification for homework #2.

Please write a web application that contains following web pages:

- login.xhtml
- user-profile.xhtml
- dashboard.xhtml
- product-listing.xhtml

and contains following packages with give classes.

org.ocpc.ecommerce.model (these are models that hold the related information)
Authentican.class (id, username, password)
Product.class (id, name, price, description, numOfInventory)
User.class (id, firstName, lastName, lastLogin)



User has to be able to login with correct username and password which in this case would be
username: iman

- If user enters wrong login credential, you need to show that on the same login page with a red color; if user enters correct credential then you to redirect the user to the dashboard.

- In dashboard, it needs to be a link to the user profile page which show information about the user which is:
firstName: iman
lastName: reihanian

But user has to be able to save it; then, you need a save button. (you don't need to save it into database since you don't know it yet) After saving, it has to inform the user about the changes and show this message "Profile information changed." with green color.

- In dashboard, you need to create a link that navigates the user to product-listing page, and in product-listing page you need to have at least 4 products. (use table in JSF)

- In dashboard, you need to create a link that navigates the user to the login page and that link is named "log out".

- In dashboard, you need to show this message "Hi, Iman".

In all cases, you don't have to hard-code the messages into the JSF pages, but you need to bring them from the back-end which is the related class.

In all cases, you don't need to connect to database since you don't know how to do this yet, but you can hard-code them inside the back-end.

I know it is hard :) so I wish you all luck.

If there is any question about this homework, please discuss it here in this topic.

Please email your homework to TA.


« Last Edit: August 07, 2018, 11:07:44 PM by Iman »


  • Administrator
  • Newbie
  • *****
  • Posts: 13
    • View Profile
Re: Homework #2
« Reply #1 on: August 08, 2018, 02:32:36 PM »
You might need to use the maven structure that you can find in

In this case, you don't need to change the name of the project and just import it as it is like"JSFSample"


  • Administrator
  • Newbie
  • *****
  • Posts: 13
    • View Profile
Re: Homework #2
« Reply #2 on: August 10, 2018, 02:46:12 PM »

Here is a link to my github, you can find the source code that might help you for the homework #2.


  • Administrator
  • Newbie
  • *****
  • Posts: 13
    • View Profile
Re: Homework #2
« Reply #3 on: August 10, 2018, 10:07:33 PM »

Please read my last post about multi tier programming in

This is exactly why you are trying to implement different packages for different classes.

This is very critical to know why we are making package separate.


  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Homework #2
« Reply #4 on: August 12, 2018, 07:39:14 PM »
Hi Team,
I will appreciate if anybody can explain what does exactly DashboadView does:

if user is empty, it will create new User function, and User function has different attribute as first name and .... . How come in dashboard.xhtml we just have firstname? Hhow can we show other attributes?
Also, is there any relation between firstname, lastname and email attribute in DashboardView class and same attributes in Model -> User.class ?

package org.ocpc.ecommerce.view;
import javax.faces.bean.ManagedBean;
import org.ocpc.ecommerce.model.User;
public class DashboardView {
       private User user;
       public User getUser() {
             if(user == null) {               
                    user = new User();
                   // user.setLastName("reihanian");
             return user;
       public void setUser(User user) {
              this.user = user;


  • Administrator
  • Newbie
  • *****
  • Posts: 13
    • View Profile
Re: Homework #2
« Reply #5 on: August 20, 2018, 10:54:32 PM »
Hi Folks,

Because you guys were off last week and had a lot of time to practice, I will add a new part to the homework #2.

- You need to save the information which had to be "hard-code" in this homework to a file; going this way, you guys need to add a registration process to the homework which will take a new step to all packages and classes, after registration user can login inside the portal, so it has to be a file that can save and retrieve information - not hard codded. What I mean by that is, if the use didn't register before, you have to show a related message and put a link inside that message which is going to redirect the user to registration page.

- Since you all know about the concept of try-catch, your web software has to be bug-free.

Just to give you a little help, you might want to use the code below:

File file = new File("C:\\Users\\Iman\\Desktop\\test.txt");

BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while ((st = br.readLine()) != null)

"File" is the part of the IO package which will open a new world for the software (process) to communicate with a dynamic storage.

- Moving forward, if the file doesn't exist; then, the software has to make a file and start communicating with that file.

- You can use any structure you want to save, sort and retrieve data from the file, like:
Singly-Linked List
Doubly-Linked List
Skip List
Hash Table
Binary Search Tree
Cartesian Tree
Red-Black Tree
Splay Tree
AVL Tree
KD Tree
Bubble Sort
Insertion Sort
Selection Sort
Tree Sort
Shell Sort
Bucket Sort
Radix Sort
Counting Sort

- I am not picky on data structure for now, but that would be a plus point if you do that.
« Last Edit: August 20, 2018, 10:59:43 PM by Iman »