Restoring document state

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Restoring document state

David McIntyre
In our application we've implemented a feature whereby if a user navigates away without saving while they're editing a document through Orbeon Forms, the document's unsaved changes will be restored if they reopen the document for editing at some later time.  We've been doing this since before the eXist state persistence mechanism was added, so what we did was to use an onbeforeunload event to dispatch a custom event to the model which in turn triggered a submission of the instance we want to restore later.

I'm now trying to update to a more recent version of Orbeon and I'm finding that the mechanism is no longer working.  If I dispatch the custom event manually (by adding a trigger for debugging) then the submission is fired, but when the event is dispatched within an onbeforeunload event handler, the submission is not fired.  I've tried adding an alert within the onbeforeunload handler and that gets hit.  On the other hand, I've tried putting an xxforms:script containing an alert in the model which responds to the custom event, and that does not gets hit when the custom event is dispatched by the onbeforeunload handler (but is hit when the custom event is dispatched by the debugging trigger, of course).

So, I have two questions.

* Is there something I need to do to be able to still use an onbeforeunload handler to dispatch custom events to the model to trigger a submission?
* Is there a way that I could instead use Orbeon's state persistence to save and later restore the state of the document?

The latter approach is appealing but is not easy: we wouldn't want to restore the entire user state, just the state of one instance document, and we'd need some way to identify whether the same user was editing the same document as before or a different document which happens to be based on the same form.  From what I can understand from the documentation, Orbeon can recognise when a user has returned to a page via the browser history, but we need to be able to say that a new request is for the same underlying document as some previous request.

Any thoughts?

Dave


--
Orion Signature

Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com


This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Restoring document state

Alessandro Vernet
Administrator
Dave,

I am not aware of a change that would break code running in you  
onbeforeunload handler.

Orbeon XForms state persistence is a fairly low level mechanism and we  
are storing data in eXist to alleviate memory requirements, allow the  
server to handle more users and to be configured with a long enough  
session. Providing a auto-save mechanism is outside of the scope of  
the XForms state handling system, and I think what you were are doing  
now is fine.

In general however, instead of saving data in the onbeforeunload  
handler, we save data at a regular interval. This would save users  
from a browser crash of a loss of power, but wouldn't save data  
entered between the time the data was last saved and the browser  
window is closed.

In your case, it would be really interesting to debug the code running  
in the onbeforeunload handler, and see what is happening there.

Alex

On Jan 20, 2009, at 1:11 PM, Dave McIntyre wrote:

> In our application we've implemented a feature whereby if a user  
> navigates away without saving while they're editing a document  
> through Orbeon Forms, the document's unsaved changes will be  
> restored if they reopen the document for editing at some later  
> time.  We've been doing this since before the eXist state  
> persistence mechanism was added, so what we did was to use an  
> onbeforeunload event to dispatch a custom event to the model which  
> in turn triggered a submission of the instance we want to restore  
> later.
>
> I'm now trying to update to a more recent version of Orbeon and I'm  
> finding that the mechanism is no longer working.  If I dispatch the  
> custom event manually (by adding a trigger for debugging) then the  
> submission is fired, but when the event is dispatched within an  
> onbeforeunload event handler, the submission is not fired.  I've  
> tried adding an alert within the onbeforeunload handler and that  
> gets hit.  On the other hand, I've tried putting an xxforms:script  
> containing an alert in the model which responds to the custom event,  
> and that does not gets hit when the custom event is dispatched by  
> the onbeforeunload handler (but is hit when the custom event is  
> dispatched by the debugging trigger, of course).
>
> So, I have two questions.
>
> * Is there something I need to do to be able to still use an  
> onbeforeunload handler to dispatch custom events to the model to  
> trigger a submission?
> * Is there a way that I could instead use Orbeon's state persistence  
> to save and later restore the state of the document?
>
> The latter approach is appealing but is not easy: we wouldn't want  
> to restore the entire user state, just the state of one instance  
> document, and we'd need some way to identify whether the same user  
> was editing the same document as before or a different document  
> which happens to be based on the same form.  From what I can  
> understand from the documentation, Orbeon can recognise when a user  
> has returned to a page via the browser history, but we need to be  
> able to say that a new request is for the same underlying document  
> as some previous request.
>
> Any thoughts?
>
> Dave
>
>
> --
> <orion150.gif>
>
> Dave McIntyreSoftware Developer
> [hidden email]
> P: +64 9 638 0600
> M: +64 21 212 8087
> F: +64 9 638 0699
> S: dave.mcintyre
> www.orionhealth.com
>
>
> This e-mail and any attachments are intended only for the person to  
> whom it is addressed and may contain privileged, proprietary, or  
> other data protected from disclosure under applicable law. If you  
> are not the addressee or the person responsible for delivering this  
> to the addressee you are hereby notified that reading, copying or  
> distributing this transmission is prohibited. If you have received  
> this e-mail in error, please telephone us immediately and remove all  
> copies of it from your system. Thank you for your co-operation.
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/
Twitter - http://twitter.com/avernet



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Restoring document state

Ryan Puddephatt-3
In reply to this post by David McIntyre
Orion Signature

Dave,

                Could it be that the submission is being sent but not completed before the unload. I’ve worked with it before and found that it was intermittently successful. In the end we went for warning the user their unsaved changes would be lost when they left the page and it was unsaved

 

Unfortunately there aren’t any ways to test the page as your leaving it

 

Just my 2c

 

Ryan

 

-----------------------------------------------

Ryan Puddephatt

Connectivity Developer

Fidessa LatentZero

1 Old Jewry

London EC2R 8DN

Office: +44 (0) 20 7105 1000

Direct: +44 (0) 20 7105 1821

Blackberry: +44 (0) 79 8539 2458

Fax: +44 (0) 20 7105 1818

Email: [hidden email]

Web: http://www.latentzero.com

 

From: Dave McIntyre [mailto:[hidden email]]
Sent: 20 January 2009 21:11
To: [hidden email]
Subject: [ops-users] Restoring document state

 

In our application we've implemented a feature whereby if a user navigates away without saving while they're editing a document through Orbeon Forms, the document's unsaved changes will be restored if they reopen the document for editing at some later time.  We've been doing this since before the eXist state persistence mechanism was added, so what we did was to use an onbeforeunload event to dispatch a custom event to the model which in turn triggered a submission of the instance we want to restore later.

I'm now trying to update to a more recent version of Orbeon and I'm finding that the mechanism is no longer working.  If I dispatch the custom event manually (by adding a trigger for debugging) then the submission is fired, but when the event is dispatched within an onbeforeunload event handler, the submission is not fired.  I've tried adding an alert within the onbeforeunload handler and that gets hit.  On the other hand, I've tried putting an xxforms:script containing an alert in the model which responds to the custom event, and that does not gets hit when the custom event is dispatched by the onbeforeunload handler (but is hit when the custom event is dispatched by the debugging trigger, of course).

So, I have two questions.

* Is there something I need to do to be able to still use an onbeforeunload handler to dispatch custom events to the model to trigger a submission?
* Is there a way that I could instead use Orbeon's state persistence to save and later restore the state of the document?

The latter approach is appealing but is not easy: we wouldn't want to restore the entire user state, just the state of one instance document, and we'd need some way to identify whether the same user was editing the same document as before or a different document which happens to be based on the same form.  From what I can understand from the documentation, Orbeon can recognise when a user has returned to a page via the browser history, but we need to be able to say that a new request is for the same underlying document as some previous request.

Any thoughts?

Dave

--


Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com

 

This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


_______________________________________________________________________
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

_____________________________________________________________________
This e-mail has been scanned for viruses by Verizon Business Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: RE: Restoring document state

David McIntyre
Ryan,

Thanks for that, but I don't think that's the problem: we're not hitting a break point in the code that the submission invokes, so the submission is not even starting, let alone completing. 

We worked around the problem you mention by having both an onbeforeunload event (which fires the submission to back up the document) and an onunload event (which blocks for a while if the submission hasn't completed).

I've managed to get things working reliably in Firefox by removing a call to ORBEON.xforms.Server.executeNextRequest(true);.  However, I'm still struggling to get it to work in IE.

Dave


Ryan Puddephatt wrote:
Orion Signature

Dave,

                Could it be that the submission is being sent but not completed before the unload. I’ve worked with it before and found that it was intermittently successful. In the end we went for warning the user their unsaved changes would be lost when they left the page and it was unsaved

 

Unfortunately there aren’t any ways to test the page as your leaving it

 

Just my 2c

 

Ryan

 

-----------------------------------------------

Ryan Puddephatt

Connectivity Developer

Fidessa LatentZero

1 Old Jewry

London EC2R 8DN

Office: +44 (0) 20 7105 1000

Direct: +44 (0) 20 7105 1821

Blackberry: +44 (0) 79 8539 2458

Fax: +44 (0) 20 7105 1818

Email: [hidden email]

Web: http://www.latentzero.com

 

From: Dave McIntyre [[hidden email]]
Sent: 20 January 2009 21:11
To: [hidden email]
Subject: [ops-users] Restoring document state

 

In our application we've implemented a feature whereby if a user navigates away without saving while they're editing a document through Orbeon Forms, the document's unsaved changes will be restored if they reopen the document for editing at some later time.  We've been doing this since before the eXist state persistence mechanism was added, so what we did was to use an onbeforeunload event to dispatch a custom event to the model which in turn triggered a submission of the instance we want to restore later.

I'm now trying to update to a more recent version of Orbeon and I'm finding that the mechanism is no longer working.  If I dispatch the custom event manually (by adding a trigger for debugging) then the submission is fired, but when the event is dispatched within an onbeforeunload event handler, the submission is not fired.  I've tried adding an alert within the onbeforeunload handler and that gets hit.  On the other hand, I've tried putting an xxforms:script containing an alert in the model which responds to the custom event, and that does not gets hit when the custom event is dispatched by the onbeforeunload handler (but is hit when the custom event is dispatched by the debugging trigger, of course).

So, I have two questions.

* Is there something I need to do to be able to still use an onbeforeunload handler to dispatch custom events to the model to trigger a submission?
* Is there a way that I could instead use Orbeon's state persistence to save and later restore the state of the document?

The latter approach is appealing but is not easy: we wouldn't want to restore the entire user state, just the state of one instance document, and we'd need some way to identify whether the same user was editing the same document as before or a different document which happens to be based on the same form.  From what I can understand from the documentation, Orbeon can recognise when a user has returned to a page via the browser history, but we need to be able to say that a new request is for the same underlying document as some previous request.

Any thoughts?

Dave

--



Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a moz-do-not-send="true" href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com

 

This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


_______________________________________________________________________
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

_____________________________________________________________________
This e-mail has been scanned for viruses by Verizon Business Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com

--
Orion Signature

Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com


This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: RE: Restoring document state

Alessandro Vernet
Administrator
Dave,

On Jan 21, 2009, at 12:55 PM, Dave McIntyre wrote:

> Thanks for that, but I don't think that's the problem: we're not  
> hitting a break point in the code that the submission invokes, so  
> the submission is not even starting, let alone completing.
>
> We worked around the problem you mention by having both an  
> onbeforeunload event (which fires the submission to back up the  
> document) and an onunload event (which blocks for a while if the  
> submission hasn't completed).
>
> I've managed to get things working reliably in Firefox by removing a  
> call to ORBEON.xforms.Server.executeNextRequest(true);.  However,  
> I'm still struggling to get it to work in IE.
You'll let us know what you find. I assumed that it wasn't possible to  
reliably do an Ajax request when the user closes the browser window.  
But that assumption is based on, well... nothing! So if you find a  
solution to this problem, I'd be quite interested to read about it.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
Personal Blog: http://avernet.blogspot.com/
Twitter - http://twitter.com/avernet



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Re: RE: Restoring document state

Ryan Puddephatt-3
In reply to this post by David McIntyre
Orion Signature

Dave,

                I see, nice workaround I’ll be sure to remember that next time I’m using onbeforeunload.

 

Is it possible that some of the unload has already begun in IE and its not firing any new javascript events?

 

Thanks

 

Ryan

 

-----------------------------------------------

Ryan Puddephatt

Connectivity Developer

Fidessa LatentZero

1 Old Jewry

London EC2R 8DN

Office: +44 (0) 20 7105 1000

Direct: +44 (0) 20 7105 1821

Blackberry: +44 (0) 79 8539 2458

Fax: +44 (0) 20 7105 1818

Email: [hidden email]

Web: http://www.latentzero.com

 

From: Dave McIntyre [mailto:[hidden email]]
Sent: 21 January 2009 20:55
To: [hidden email]
Subject: [ops-users] Re: RE: Restoring document state

 

Ryan,

Thanks for that, but I don't think that's the problem: we're not hitting a break point in the code that the submission invokes, so the submission is not even starting, let alone completing. 

We worked around the problem you mention by having both an onbeforeunload event (which fires the submission to back up the document) and an onunload event (which blocks for a while if the submission hasn't completed).

I've managed to get things working reliably in Firefox by removing a call to ORBEON.xforms.Server.executeNextRequest(true);.  However, I'm still struggling to get it to work in IE.

Dave


Ryan Puddephatt wrote:

Dave,

                Could it be that the submission is being sent but not completed before the unload. I’ve worked with it before and found that it was intermittently successful. In the end we went for warning the user their unsaved changes would be lost when they left the page and it was unsaved

 

Unfortunately there aren’t any ways to test the page as your leaving it

 

Just my 2c

 

Ryan

 

-----------------------------------------------

Ryan Puddephatt

Connectivity Developer

Fidessa LatentZero

1 Old Jewry

London EC2R 8DN

Office: +44 (0) 20 7105 1000

Direct: +44 (0) 20 7105 1821

Blackberry: +44 (0) 79 8539 2458

Fax: +44 (0) 20 7105 1818

Email: [hidden email]

Web: http://www.latentzero.com

 

From: Dave McIntyre [[hidden email]]
Sent: 20 January 2009 21:11
To: [hidden email]
Subject: [ops-users] Restoring document state

 

In our application we've implemented a feature whereby if a user navigates away without saving while they're editing a document through Orbeon Forms, the document's unsaved changes will be restored if they reopen the document for editing at some later time.  We've been doing this since before the eXist state persistence mechanism was added, so what we did was to use an onbeforeunload event to dispatch a custom event to the model which in turn triggered a submission of the instance we want to restore later.

I'm now trying to update to a more recent version of Orbeon and I'm finding that the mechanism is no longer working.  If I dispatch the custom event manually (by adding a trigger for debugging) then the submission is fired, but when the event is dispatched within an onbeforeunload event handler, the submission is not fired.  I've tried adding an alert within the onbeforeunload handler and that gets hit.  On the other hand, I've tried putting an xxforms:script containing an alert in the model which responds to the custom event, and that does not gets hit when the custom event is dispatched by the onbeforeunload handler (but is hit when the custom event is dispatched by the debugging trigger, of course).

So, I have two questions.

* Is there something I need to do to be able to still use an onbeforeunload handler to dispatch custom events to the model to trigger a submission?
* Is there a way that I could instead use Orbeon's state persistence to save and later restore the state of the document?

The latter approach is appealing but is not easy: we wouldn't want to restore the entire user state, just the state of one instance document, and we'd need some way to identify whether the same user was editing the same document as before or a different document which happens to be based on the same form.  From what I can understand from the documentation, Orbeon can recognise when a user has returned to a page via the browser history, but we need to be able to say that a new request is for the same underlying document as some previous request.

Any thoughts?

Dave


--


Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com

 

This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


_______________________________________________________________________
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

_____________________________________________________________________
This e-mail has been scanned for viruses by Verizon Business Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com

 

--


Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com

 

This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


_______________________________________________________________________
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

_____________________________________________________________________
This e-mail has been scanned for viruses by Verizon Business Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws