Question

In: Computer Science

Convert your "To Do List" application to use Hibernate in order to save its data. Then...

Convert your "To Do List" application to use Hibernate in order to save its data. Then add a web UI, so that it runs on the Tomcat web server. You will have to add JSP code for each of the web pages (show to-do list, add a to-do item, delete a to-do item). Your to-do-list application should already be well structured, separating the back-end from the front-end, so that adding a web UI is just a matter of adding a new front-end which would call the existing back-end.

Here's my code so far:

package assignment1;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.Random;
public class assignment4 {

  
public static void main(String[] args) {
ArrayList_Op();
LinkedList_Op();
HashTable_Op();
}

private static void ArrayList_Op() {
ArrayList<Integer> arr_list = new ArrayList<>();
Random rand = new Random();
for(int i=0; i<200000; i++)
{
arr_list.add(rand.nextInt(200000));
}
  
  
for(int i=0; i<200000; i++)
{
arr_list.remove(0);
}
  
}

private static void LinkedList_Op() {

LinkedList<Integer> list = new LinkedList<Integer>();
Random rand = new Random();
for(int i=0; i<200000; i++)
{
list.add(rand.nextInt(200000));
}
  
  
for(int i=0; i<200000; i++)
{
list.remove(0);
}
}

private static void HashTable_Op() {

Hashtable<Integer, Integer> hash = new Hashtable<>();
Random rand = new Random();
  
for(int i=0; i<200000; i++)
{
hash.put(i, rand.nextInt(200000));
}
  
for(int i=0; i<200000; i++)
{
hash.remove(i);
}
}
  
}


We're using Apache Web server, its already been downloded on the computer.

Solutions

Expert Solution

// This is the array that will hold the todo list items
let todoItems = [];

// This function will create a new todo object based on the
// text that was entered in the text input, and push it into
// the `todoItems` array
function addTodo(text) {
const todo = {
text,
checked: false,
id: Date.now(),
};

todoItems.push(todo);
console.log(todoItems);
}

// Select the form element
const form = document.querySelector('.js-form');
// Add a submit event listener
form.addEventListener('submit', event => {
// prevent page refresh on form submission
event.preventDefault();
// select the text input
const input = document.querySelector('.js-todo-input');

// Get the value of the input and remove whitespace
const text = input.value.trim();
if (text !== '') {
addTodo(text);
input.value = '';
input.focus();
}
});

function renderTodo(todo) {
// Select the first element with a class of `js-todo-list`
const list = document.querySelector('.js-todo-list');

// Use the ternary operator to check if `todo.checked` is true
// if so, assign 'done' to `isChecked`. Otherwise, assign an empty string
const isChecked = todo.checked ? 'done': '';
// Create an `li` element and assign it to `node`
const node = document.createElement("li");
// Set the class attribute
node.setAttribute('class', `todo-item ${isChecked}`);
// Set the data-key attribute to the id of the todo
node.setAttribute('data-key', todo.id);
// Set the contents of the `li` element created above
node.innerHTML = `
<input id="${todo.id}" type="checkbox"/>
<label for="${todo.id}" class="tick js-tick"></label>
<span>${todo.text}</span>
<button class="delete-todo js-delete-todo">
<svg><use href="#delete-icon"></use></svg>
</button>
`;

// Append the element to the DOM as the last child of
// the element referenced by the `list` variable
list.append(node);
}


Related Solutions

[Please use the data for this problem on the next few problems - aka save your...
[Please use the data for this problem on the next few problems - aka save your work!] Suppose a firm has 24 million shares of common stock outstanding at a price of $14.5 per share. The firm also has 100,000 bonds outstanding with a current price of $1057.5. The outstanding bonds have yield to maturity 7.8%. The firm's common stock beta is 1.2 and the corporate tax rate is 35%. The expected market return is 13% and the T-bill rate...
[Please use the data for this problem on the next few problems - aka save your...
[Please use the data for this problem on the next few problems - aka save your work!] Suppose a firm has 24 million shares of common stock outstanding at a price of $14.5 per share. The firm also has 100,000 bonds outstanding with a current price of $1057.5. The outstanding bonds have yield to maturity 7.8%. The firm's common stock beta is 1.2 and the corporate tax rate is 35%. The expected market return is 13% and the T-bill rate...
C# Create a console application named that creates a list of shapes, uses serialization to save...
C# Create a console application named that creates a list of shapes, uses serialization to save it to the filesystem using XML, and then deserializes it back: // create a list of Shapes to serialize var listOfShapes = new List<Shape> { new Circle { Colour = "Red", Radius = 2.5 }, new Rectangle { Colour = "Blue", Height = 20.0, Width = 10.0 }, new Circle { Colour = "Green", Radius = 8 }, new Circle { Colour = "Purple",...
In order to save for your retirement, you want to save $8,000 every year for 10...
In order to save for your retirement, you want to save $8,000 every year for 10 years, starting one year from now. The annual interest rate on your savings account is 7%. How much money will you have in your account in 10 years?
USE PYTHON Create a single list that contains the following collection of data in the order...
USE PYTHON Create a single list that contains the following collection of data in the order provided: [1121, "Jackie Grainger", 22.22, 1122, "Jignesh Thrakkar", 25.25, 1127, "Dion Green", 28.75, False, 24.32, 1132, "Jacob Gerber", "Sarah Sanderson", 23.45, 1137, True, "Brandon Heck", 1138, 25.84, True, 1152, "David Toma", 22.65, 23.75, 1157, "Charles King", False, "Jackie Grainger", 1121, 22.22, False, 22.65, 1152, "David Toma"] The data above represents employee information exported from an Excel spreadsheet. Whomever typed the data in originally didn't...
in order to save for your child's college education, you want to save $500 every month...
in order to save for your child's college education, you want to save $500 every month for 20 years, starting one month from now. The monthly interest rate on your savings account is 0.8%. How much money will you have in your account in 20 years?
Explain how airlines use 'Route Optimization' in order to save the cost.
Explain how airlines use 'Route Optimization' in order to save the cost.
Write two-page paper including your list of sources about your favorite economic concept and its application...
Write two-page paper including your list of sources about your favorite economic concept and its application in everyday life
List and describe the benefits and application of the methods for presenting and formatting financial data.
List and describe the benefits and application of the methods for presenting and formatting financial data.
Create a mockup of your web application that will display a list of favorites. Remember, this...
Create a mockup of your web application that will display a list of favorites. Remember, this can be a list of any favorite items, such as books, movies, restaurants, music, and so on. Your web application should contain at least 3 pages (HTML documents). Your mockup should contain mockups of each HTML document. You should follow a similar format as the sample mockup provided here. Your 5-6-page document should include the following: A description of the site's organizational structure. A...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT