You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Colin Paul Adams <co...@colina.demon.co.uk> on 2004/07/23 00:14:19 UTC

Unfathomable behaviour from flowscript

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


Re: Flowscript errors when invoking the debugger

Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Colin" == Colin Paul Adams <co...@colina.demon.co.uk> writes:

    Colin> I have just discovered the flowscript debugger - so I
    Colin> decided to see for myself what was happening.

    Colin> However, when I try this, I press "Step out" from the first
    Colin> function. I get:

    Colin> "resource://org/apache/cocoon/forms/flow/javascript/Form.js",
    Colin> line 50: uncaught JavaScript exception: at handleForm
    Colin> (resource://org/apache/cocoon/forms/flow/javascript/Form.js,
    Colin> Line 249) at Form
    Colin> (resource://org/apache/cocoon/forms/flow/javascript/Form.js,
    Colin> Line 50): java.lang.NullPointerException

    Colin> org.apache.avalon.framework.CascadingRuntimeException:
    Colin> "resource://org/apache/cocoon/forms/flow/javascript/Form.js",
    Colin> line 50: uncaught JavaScript exception: at handleForm
    Colin> (resource://org/apache/cocoon/forms/flow/javascript/Form.js,
    Colin> Line 249) at Form
    Colin> (resource://org/apache/cocoon/forms/flow/javascript/Form.js,
    Colin> Line 50): java.lang.NullPointerException

    Colin> cause: java.lang.NullPointerException

This happens becayse Form.js contains many clasuses of the form:

try {
<do something
} finally {

}

without an intervening catch - adding a line

} catch (e) {

before all the finally's cures this (but then I get another error).
Still, I managed to debug my problem using cocoon.log.debug calls.
-- 
Colin Paul Adams
Preston Lancashire

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


Flowscript errors when invoking the debugger (was: Unfathomable behaviour from flowscript)

Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Colin" == Colin Paul Adams <co...@colina.demon.co.uk> writes:

>>>>> "Ugo" == Ugo Cei <u....@cbim.it> writes:
    Ugo> Colin Paul Adams wrote:
    >>>>>>>> "Ugo" == Ugo Cei <ug...@apache.org> writes:
    Ugo> Il giorno 23/lug/04, alle 00:14, Colin Paul Adams ha
    >>> scritto: >> What is the proper way to drop off the end of the
    >>> flowscript, >> and display another page?
    Ugo> cocoon.sendPage(whatever); return;
    >>> This is of no use to me, as whatever is invoked with a
    >>> .continue URI, thus making it impossible to use relative links
    >>> within whatever.

    Ugo> Then maybe:

    Ugo> cocoon.redirectTo("/absoluteURI"); return;


    Colin> That is what I was doing (although with a relative URI).

    Colin> I have just changed to using sendpage instead, but sending
    Colin> it to a page does includes a meta to do a redirect
    Colin> (http-equiv refrsh, with a relative URI specified).

    Colin> But I think this is probably the same thing. Certainly the
    Colin> behaviour appears to be the same.

    Colin> I am wondering if perhaps the browser is caching the page
    Colin> that is produced by the flowscript, since when it goes
    Colin> astray, I can hit the reload button and get the correct
    Colin> page.  -- Colin Paul Adams Preston Lancashire

I have just discovered the flowscript debugger - so I decided to see
for myself what was happening.

However, when I try this, I press "Step out" from the first
function. I get:

"resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 50: uncaught JavaScript exception: at handleForm (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line 249) at Form (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line 50): java.lang.NullPointerException

org.apache.avalon.framework.CascadingRuntimeException: "resource://org/apache/cocoon/forms/flow/javascript/Form.js", line 50: uncaught JavaScript exception: at handleForm (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line 249) at Form (resource://org/apache/cocoon/forms/flow/javascript/Form.js, Line 50): java.lang.NullPointerException

cause: java.lang.NullPointerException 

Am I doing anything illegitimate?
-- 
Colin Paul Adams
Preston Lancashire

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


Re: Unfathomable behaviour from flowscript

Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Ugo" == Ugo Cei <u....@cbim.it> writes:

    Ugo> Colin Paul Adams wrote:
    >>>>>>> "Ugo" == Ugo Cei <ug...@apache.org> writes:
    Ugo> Il giorno 23/lug/04, alle 00:14, Colin Paul Adams ha
    >> scritto: >> What is the proper way to drop off the end of the
    >> flowscript, >> and display another page?
    Ugo> cocoon.sendPage(whatever); return;
    >> This is of no use to me, as whatever is invoked with a
    >> .continue URI, thus making it impossible to use relative links
    >> within whatever.

    Ugo> Then maybe:

    Ugo> cocoon.redirectTo("/absoluteURI"); return;


That is what I was doing (although with a relative URI).

I have just changed to using sendpage instead, but sending it to a
page does includes a meta to do a redirect (http-equiv refrsh, with a
relative URI specified).

But I think this is probably the same thing. Certainly the behaviour
appears to be the same.

I am wondering if perhaps the browser is caching the page that is
produced by the flowscript, since when it goes astray, I can hit the
reload button and get the correct 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


Re: Unfathomable behaviour from flowscript

Posted by Ugo Cei <u....@cbim.it>.
Colin Paul Adams wrote:
>>>>>>"Ugo" == Ugo Cei <ug...@apache.org> writes:
> 
> 
>     Ugo> Il giorno 23/lug/04, alle 00:14, Colin Paul Adams ha scritto:
>     >> What is the proper way to drop off the end of the flowscript,
>     >> and display another page?
> 
>     Ugo> cocoon.sendPage(whatever); return;
> 
> This is of no use to me, as whatever is invoked with a .continue URI,
> thus making it impossible to use relative links within whatever.

Then maybe:

cocoon.redirectTo("/absoluteURI");
return;


	Ugo


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


Re: Unfathomable behaviour from flowscript

Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Ugo" == Ugo Cei <ug...@apache.org> writes:

    Ugo> Il giorno 23/lug/04, alle 00:14, Colin Paul Adams ha scritto:
    >> What is the proper way to drop off the end of the flowscript,
    >> and display another page?

    Ugo> cocoon.sendPage(whatever); return;

This is of no use to me, as whatever is invoked with a .continue URI,
thus making it impossible to use relative links within whatever.
-- 
Colin Paul Adams
Preston Lancashire

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


Re: Unfathomable behaviour from flowscript

Posted by Ugo Cei <ug...@apache.org>.
Il giorno 23/lug/04, alle 00:14, Colin Paul Adams ha scritto:

> What is the proper way to drop off the end of the flowscript, and
> display another page?

cocoon.sendPage(whatever);
return;

-- 
Ugo Cei - http://beblogging.com/