cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Colin Paul Adams <co...@colina.demon.co.uk>
Subject Unfathomable behaviour from flowscript
Date Thu, 22 Jul 2004 22:14:19 GMT
The following is a cut-down version of a flowscript function that I am
using to display a form:

function dbxmlevents2xml ( form ) {

    var finish_page = "calendar.html"

    // Get the documentURI parameter from the sitemap which contains the
    //  location of the file to be edited.

    cocoon.session.setMaxInactiveInterval ( 300 ) // Five minutes
    var documentURI = cocoon.parameters["documentURI"]

    try {

        // <snipped code to load, display and save the form

	}
    catch ( e if e instanceof java.lang.IllegalArgumentException && e.message == "call
on closed handle" ) {
	  finish_page = "closed-handle.html"
    } catch ( e ) {
	cocoon.log.error ( "Exception occured: " + e )
	if ( transaction != null ) {
	   try {
	      transaction.abort ()	      
	   } catch ( e ) {}
	}
    } finally {
	accessor.close ()
    }
    cocoon.redirectTo ( finish_page )
}

The idea is that after the form is edited and saved, calendar,html
will be displayed.
The first catch clause is present, because, when the form is saved,
if the user then presses the back button from the calendar.html page,
I have a problem.

The reason I have a problem, is that although I am using the CForms
binding to XML file, the XML file is actually stored in a Berkeley DB
XML database, and the snipped code includes calls to methods on
objects (accessor and transaction, amongst other - visible in the
catcxh handlers) which read and write to and from the database and a
variable holding the XML text.

Now when the form is saved to the database, theses objects are no
longer valid - hence the catch for a
java.lang.IllegalArgumentException (this is also thrown if the users
session expires).

So, if one of these nasty situations occurs, closed-handle.html is
displayed, informing the user what has happened, and inviting the user
to select a link to calendar.html (the form edits data in the
calendar).
On the calendar.html page is a link that invokes the edit function all
over again.

Unfortunately, this does not work properly. When the user selects this
last link, (s)he sees the closed-handle.html page again, istead of the
page which displays the form.
If the user then cycles through the links again, everything starts
working.

In fact, this cycle happens even if there is no error: i.e.:

User selects the edit link - saves the form - calendar.html is
displayed - user selects the edit link again (to make some further
changes), and gets presented with  closed-handle.html. And this
bi-modal cycle can continue indefinitely.

I diagnose that cocoon.redirectTo does not terminate the flowscript
(and so continuations are being left lying around, though I can't
fathom out exactly what.

What is the proper way to drop off the end of the flowscript, and
display another page?
-- 
Colin Paul Adams
Preston Lancashire

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message