cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Rusnak <>
Subject Re: Getting database connection in flow script
Date Thu, 28 Oct 2004 22:48:00 GMT
I solved the problem getting database connection so that I created
Registrator java class which implements Serviceable interface. Then
the flowscript loads Registrator class by method cocoon.createObject()
in order to allow accessing Avalon services.

Now I need to solve another problem. When the user with the specified
username exists in the database, Registrator class thows
RegistrationException and the form shall be displayed again with an
error message at the corresponding textfield. I have following questions:

1. Is it possible to specify exception class in catch clause? Currently
   I use instanceof operator.

2. How to setup errorMessage for the specific widget?

Here is the script:

registration() {

    var form = new Form("forms/registration.xml")
    var success

    do {
        success = true

        var model = form.getModel()

        var registrator = cocoon.createObject("Registrator")

        try {
            registrator.register(model.username, model.password)
        } catch(e) {
            if(e instanceof RegistrationException) {
                success = false
            } else throw e
    } while(!success)


Antonio Gallardo wrote:
> Servus Martin!
> Martin Rusnak dijo:
>>Dear All,
>>I am using CForms/flow-script. When the form is submited, I usually call
>>a methods in my database utility classes from flow-script to perform a
>>DB queries. For that I need to obtain a database connection from the
>>pool. I tried the method: Database.getConnection("connection-id"), but
>>it returns ScriptableConnection class. Is it possible to get reference
>>to java.sql.Connection in flow-script?
> I never used directly java.sql.* in JSFlow, but I think it should work.
>>What is the preferred way to
>>handle database calls in flow-script?
> Well, I think the "prefered" way depends of how much you will use
> databases. There are diferent approach:
> The olders are:
> 1-ESQL tranformer
> 2-ESQL logicsheet in XSP
> 3-Modular DB Actions -
> The "newer" approach is using a O/R mapping tool - i.e.:Apache OJB,
> Hibernate, etc. This approach is particular powerful because allow you to
> have better SoC + all the advantage that a O/R tool + better abstraction.
> You can find more info in section 7. "Databases" at:
> Best Regards,
> Antonio Gallardo.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message