This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Reloading the page data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Reloading the page data" Watch "Reloading the page data" New topic
Author

Reloading the page data

Marc Heruela
Ranch Hand

Joined: Jul 23, 2009
Posts: 38
Hello guys,

I just want to clarify something. In my jsp page, I have a grid where all records are displayed.
Each row corresponds to one record. When I wanna edit a certain record, I will have to click
a radio button (the radio button carries the value of the username, which is unique), and click edit.
I will then be redirected to the userForm.jsp where the user corresponding to the record I have clicked
is displayed. I can now edit the record. When I save the record, I will first check if ever sombody else
has edited the record i am editing while I was editing it. In short, I implement timestamping of records.
Now, if somebody else has edited it, I will then be asked to refreshed the page in order to load the new record.
Is this not possible? When I reload the page, the data isn't really reloaded. It's just prompt me this message:


To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.


Is what I am asking not possible? Like it is part of struts design? Or have I implemented it wrongly?

Here's a snippet of my action class that retrieves the data from the database:



Basically, from the previous page (where all records are listed in the grid) the name of the radio button is "username" and it carries a unique username value
which will used to query to the database as shown above.

Please advise.

-marckun


-marckun
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Marc Heruela wrote: When I reload the page, the data isn't really reloaded. It's just prompt me this message:

To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.

Is what I am asking not possible? Like it is part of struts design? Or have I implemented it wrongly?

Google the same error message and you get plenty of links discussing this issue(Its not an issue, its how FF warns you about the repetition of previous action which leads to unnseeasry duplication of data entry at server side, mainly beacuse of several users has a habit of double clicking the same action button, like submit )


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

i dont know why you confuse with refresh the page?. as per your requirement , just updte the data and forward it to the page.

Marc Heruela
Ranch Hand

Joined: Jul 23, 2009
Posts: 38
Sagar Rohankar wrote:
Marc Heruela wrote: When I reload the page, the data isn't really reloaded. It's just prompt me this message:

To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.

Is what I am asking not possible? Like it is part of struts design? Or have I implemented it wrongly?

Google the same error message and you get plenty of links discussing this issue(Its not an issue, its how FF warns you about the repetition of previous action which leads to unnseeasry duplication of data entry at server side, mainly beacuse of several users has a habit of double clicking the same action button, like submit )



seetharaman venkatasamy wrote:i dont know why you confuse with refresh the page?. as per your requirement , just updte the data and forward it to the page.



hmmm.. i wasn't really complaining about the messages prompted (and i think it is not an error). What I wanna ask is that, after I refresh the page,

The data in the form is not really updated, it does not load the new data from the database. Like after I forcefully edit the data in the database,

when I refreshed the page, it doesnt do anything. Like the same data are still there:

for instance:

displayed data on first load: xxxx

i edit it to: xxxxyyyy (but i did not save this change to the database)

then i change value in the database via command line: xxxx ->>>> aaaaa

when i reload page value is still: xxxxyyyy

it does not really reload the data.

-marckun

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Marc Heruela wrote:
for instance:

displayed data on first load: xxxx

i edit it to: xxxxyyyy (but i did not save this change to the database)

then i change value in the database via command line: xxxx ->>>> aaaaa

when i reload page value is still: xxxxyyyy

it does not really reload the data.

Considering above example, please check and debug the underlying JDBC code which fetch the data, put some print statement to check which data is actually going to transfer to JSP before and after manual data insertion.
Marc Heruela
Ranch Hand

Joined: Jul 23, 2009
Posts: 38
Sagar Rohankar wrote:
Marc Heruela wrote:
for instance:

displayed data on first load: xxxx

i edit it to: xxxxyyyy (but i did not save this change to the database)

then i change value in the database via command line: xxxx ->>>> aaaaa

when i reload page value is still: xxxxyyyy

it does not really reload the data.

Considering above example, please check and debug the underlying JDBC code which fetch the data, put some print statement to check which data is actually going to transfer to JSP before and after manual data insertion.


Sorry it took me pretty long to reply.. i was away for awhile.

Anyways, while trying to figure this thing out, iv noticed some weird stuff..

scenario: i have a form that will get data from the database, with a submit button.

Case 1: (IE8)
- on first load of the form, i did this:
a: delete or manually remove the data from the textfields.
b: click "Refresh" button.
c: DATA IS RESTORED

- on first load of the form, i also did this:
a: delete or manually remove the data from the textfields.
b: Went to the "Address Bar" and hit it (in short, i sent the same request to the database)
c: DATA IS RESTORED

- on first load of the form, i did this:
a: modify the data such that when submitted, it wont pass the validation (STRUTS2 VALIDATION)
b: click "Submit", sure enough, the form is not submitted, the error message is displayed
c: the updated/modified invalid (unpersisted) data are still in the form (as expected)
e: click on "Refresh", ie prompted me a message that the form will be resubmitted.
f: i click OK, and the DATA IS NOT RESTORED. Meaning the same invalid modified/updated (unpersisted) data is still in the form.
g: when i went to the "Address bar" and hit it, the form is cleared (to my horror).

Case 2: (FIREFOX 3.5)
- on first load of the form, i did this:
a: delete or manually remove the data from the textfields.
b: click "Refresh" button.
c: DATA IS NOT RESTORED, TEXTFIELD REMAINS BLANK.

- on first load of the form, i also did this:
a: delete or manually remove the data from the textfields.
b: Went to the "Address Bar" and hit it (in short, i sent the same request to the database)
c: DATA IS RESTORED.

- on first load of the form, i did this:
a: modify the data such that when submitted, it wont pass the validation (STRUTS2 VALIDATION)
b: click "Submit", sure enough, the form is not submitted, the error message is displayed
c: the updated/modified invalid (unpersisted) data are still in the form (as expected)
e: click on "Refresh", firefox prompted me a message that the form will be resubmitted.
f: i click OK, and the DATA IS NOT RESTORED. Meaning the same invalid modified/updated (unpersisted) data is still in the form.
g: when i went to the "Address bar" and hit it, the form is cleared (to my horror).

can you please enlighten me?

thanks,
-marckun
 
Don't get me started about those stupid light bulbs.
 
subject: Reloading the page data
 
Similar Threads
querystring values and GET method
How i write the code so that at on submit as well as at onload we call same servlet i
Populating fields with data on clicking radio button
checking 2 records with Javascript
Create a Different selectOneListbox Depending On the Radio Button Clicked