This documentation is for WSO2 Application Server version 5.0.1. View documentation for the latest release.

The Polling Station Sample

This sample depicts the behavior of a simple voting system. It has two perspectives: a user perspective and an administration perspective.

The user perspective:

  • Is the default perspective
  • Allows a user to vote for a particular poll
  • Allows a user to view the results of a poll

In the administration perspective, an authorized administrator can:

  • Create new polls
  • Start polls (which have been stopped)
  • Stop polls (which are currently active)
  • Create accounts for new administrators

Only one vote per poll is allowed for a particular IP address and the poll results can be compared using the bar graphs and the relevant percentages of votes each choice has received. If you try voting again using the same IP, you will be directed to the poll results page which includes the line, "We have already received a vote for this poll from your IP address. Therefore, you are not eligible for voting" below the results graph.

Deploying the Service

To build the samples you need Apache Ant build tool.

1. Install the WSO2 Application Server. 

2. In a command prompt, switch to the Chad directory.

For example, cd <AS_HOME>\samples\Chad

3. From there, type ant.

4. Run the WSO2 Application Server start script.

5. Check the WSO2 Application Server instance using this URL: https://localhost:9443/carbon.

6. You now have the Chad service deployed on WSO2 Application Server. If you go to the Deployed Services window in the Application Server's Management Console, you will see the "Chad" service deployed.

Running the Web-based Client

1. Start the WSO2 Application Server if it is not running and ensure that the Chad service is running as explained in step 6 above.

2. To run the chad client visit http://localhost:9763/Chad. This is the web-based UI of chad application.

Note:
Using mozilla firefox is recommended when running this sample.

3. The user view of the Chad system appears.

If there are no Active polls, the page shows "No polls present". An active poll is a poll open for voting. A normal user can vote using the "Vote" action. He/she can also see poll results by clicking on the particular poll title.

Login to the Chad system as Administrator using the default username and password given. Admin has access to the following features:

  • Create a new poll.
  • Stop voting or remove a poll. If you click on the name of a poll in the active polls- lists that are open for voting, you can see the poll results.

Vote types available are "Single Choice" where only one choice can be voted and "Multiple Choice" where the user can vote for one or more choices. Once a poll is created, it is automatically open for voting. Voting is open until explicitly closed using stop option.

The menu item "All Polls" lists all created polls.

To see Poll results, click on the particular poll listed on any of the Polls lists pages. You will get a page as shown below.

Using the "Stop" action, you can close voting. Once closed noone can vote for that particular poll. Once stopped, the Start link will appear under 'Action' column replacing both Stop and Vote action links. Start action reopens a poll for voting.

Vote action takes you to a page as shown below, using which one can vote for his/her preferred choice. This can happen for either a single type vote or a multiple type vote . For single type voting:

For multiple type voting:

  • Stopped polls : List polls that are closed for voting (polls that one cannot vote for)
  • Administrators - Allow the user to add new administrators

Using this option, you can add new administrators and check the list of current administrators.

The WSDL file of the sample can be found in <AS_HOME>\samples\Chad\wsdl directory.