Denys
Denys

Reputation: 4557

editing data from an html table

I'm doing a Java ee "online shop" project for my uni, and one of the requirements is that an admin user should be able to edit products details.

I have a html table that represents all products in my online store. The content for the table is taken from the database table.

It looks like:

<forEach var="product" items="${productList}" varStatus="iter">
      <tr class="${((iter.index % 2) == 1) ? 'lightBlue' : 'white'} tableRow">
          <td>${product.name}</td>
          <td>${product.price}</td>
          <td>${product.description}</td>
      </tr>
</foreach>

Is there a way of editing data in my database table, using this html table without such things as JavaScript?

Upvotes: 0

Views: 3601

Answers (5)

Jovan MSFT
Jovan MSFT

Reputation: 14600

You can use JQuery plugins to implement inline editing and just implement Ajax responses on the server side. See http://www.codeproject.com/KB/java/J2EE-Editable-Web-Table.aspx as an example

Upvotes: 0

Srikanth Venkatesh
Srikanth Venkatesh

Reputation: 2812

  • You can make use of servlets for redirecting the page to edit mode.
  • Make use of java beans and DAO to save the edited data in database.

Upvotes: 0

Kyaw Thura
Kyaw Thura

Reputation: 110

I am not Java guru. But I think you would need two template to edit the product detail.

First template is just the same as yours. Second template should have input boxes based on your spec.

You can use variable (mode) to test whether it is in Edit mode or not. When admin click Edit button, change the mode to Edit and render your html table again with second template.

Hope you get the general idea.

Upvotes: 0

Tadas Šubonis
Tadas Šubonis

Reputation: 1600

Yes....

Just make a link to a new form (HTML form) that would load all product data into text fields (or appropriate input type) and submit button for data saving. Of course handle all those submitted changes on the server. Or I misunderstood question?

Also take a look at these:

These make life a lot of easier for Java programmer when making some content management systems :).

Upvotes: 1

Jai
Jai

Reputation: 3609

Not from a static html table per say that I know of, but you could provide a button that says edit, which leads to opening of an HTML form for your needs -

http://www.w3schools.com/html/html_forms.asp

Then use POST or GET request to send the data to the server.

Upvotes: 0

Related Questions