开发者

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?


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:

  • http://www.sencha.com/examples/#editablegrid
  • http://demo.vaadin.com/sampler#TableClickListeners and http://demo.vaadin.com/sampler#FormAdvancedLayout

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


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.


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.


  • 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜