aspose file tools*
The moose likes JSP and the fly likes Help with update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Help with update" Watch "Help with update" New topic
Author

Help with update

Jaidev Arer
Ranch Hand

Joined: Mar 12, 2010
Posts: 38
Hi All,
I am developing an application where in i have 30 rows from the mysql database for a calender month. one of the field is read-write,so i have 30 update buttons. Now when a user updates (for ex:24th record's read-write field), i need to update the same on the database. But i am confused how to map the update to the corresponding records.
i have attached the image of the JSP.
in the attached image, requested field is read-write field. if the user updates that field for any particular date then that update has to be reflected on the database.
Please advise how to go on.
Thanks in advance.



[Thumbnail for jsp1.JPG]

Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3267
    
  52

"exxor user" please check your private messages regarding an important administrative matter.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
You can create each row as a separate HTML <form> with a hidden field which includes the row identifier (I'm sure there are lots of other ways to do something simailar). However, in a broader sense, what happens when a user updates values from multiple rows? How are they going to know they must press the update button after each change? This does not seem intuitive from a UI point of view.

Instead, why not create a single HTML <form> which contains one set of fields for each row (dynamically create the fields) where the field name contains the information you need to locate the row. Then you just need one update button, and the user can make edits to their heart's content, then click the update button when finished.
Jaidev Arer
Ranch Hand

Joined: Mar 12, 2010
Posts: 38
Thanks Mark.
Here its a day to day activity were user changes that particular field only when they require.if they change multiple column, yes they have to press update for the corresponding row.
i am stuck up at that point, how to hook up the row to the particular update button.
Please do advice.
Thanks again.
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

Instead, why not create a single HTML <form> which contains one set of fields for each row (dynamically create the fields) where the field name contains the information you need to locate the row. Then you just need one update button, and the user can make edits to their heart's content, then click the update button when finished.


I recommend this UI design too for your page...


Thanks,
Sherif
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
Jaidev Arer wrote:Thanks Mark.
Here its a day to day activity were user changes that particular field only when they require.if they change multiple column, yes they have to press update for the corresponding row.
i am stuck up at that point, how to hook up the row to the particular update button.
Please do advice.
Thanks again.


So you think the users will only change the value for the day they are interested in?
From experience I can tell you, you're in for a lot of trouble with that UI.

In any case, if you make each row/submit button a separate HTML Form, then just add a hidden field to the form which provides the identification information.

If you have a single HTML form/submit button with all the data rows in it, just change the name of the value field to include something that will allow you to identify it. For example, field_ROW1, field_ROW2, etc. Note: This is the name of the field, not the field's label.

There's probably many other ways you can accomplish this as well.
Jaidev Arer
Ranch Hand

Joined: Mar 12, 2010
Posts: 38
Thanks Mark.
We changed our design. We made a single update button in the new page we gave the option to select the date and the interested field and just one update button. That has made our life simple.
Thanks for the input.
Nishikant Nipane
Greenhorn

Joined: Mar 17, 2010
Posts: 3
Jaidev Arer wrote:Thanks Mark.
Here its a day to day activity were user changes that particular field only when they require.if they change multiple column, yes they have to press update for the corresponding row.
i am stuck up at that point, how to hook up the row to the particular update button.
Please do advice.
Thanks again.


Hi

Actually this can be done as follows:

1> Keep 2 Dimentional javascript array for every row like [rowId][index of column i.e. field] which will be populated on page load
2> For every filed in a row, which can change, call a Java script functin say change(rowid,index of column)..On onchange event of correosponding field...change correosponding value in 2 dimentional array...
3> On every Onclick of update button you can call Ajax call to update correosponding row.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with update