You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stephan Niedermeier <ma...@logabit.com> on 2003/09/05 18:40:08 UTC

Problems using Java code in Flow Scripts

Hello,

at first I would say that the concept of Control Flow is one of the best concepts I have ever heard in web development. The use of Flow Script is very easy and fantastic. But there is one big problem for me: It's not possible to use the Flow Script in professional applications! The reason: There are many, many problems of using Java-Code in the Flow Script. 

An example: Why cause the following lines a NullPointerException

function main() {

  importClass(Packages.foo.bar.User);

  user = new User();
  user.setName("Donald Duck");
  user.setPassword("foo");
  user.setActive(false);

  cocoon.sendPage("example.jxt",{"user", user});
}

and the following - without the user object as parameter for sendPage - not?

function main() {

  importClass(Packages.foo.bar.User);

  user = new User();
  user.setName("Donald Duck");
  user.setPassword("foo");
  user.setActive(false);

  cocoon.sendPage("example.jxt");
} 

My JXTemplate looks like the following lines:

<?xml version="1.0" encoding="ISO-8859-1"?>

<html>
<header>
<titleTest</title>
</header>
<body>

    <!-- commenting this doesn't solve the problem --->
    Name: ${user.name}
    
</body>
</html>

The object "user" exists at foo.bar and the pipeline works fine, because I had tested it with other calls from the Flow Script. And yes, I have already cleared the "works" directory.

But this is not just the only problem. There are many other strange problems using Flow Script: 

Sometimes - not anytime - after an error executing a Flow Script has occured, the Flow Script file is not longer readable and blocked. Why? Not closed Stream? Only restarting tomcat solves this problem.

Using JXForms with JavaBeans containing a String[] Array for example doesn't work. But there is no error message displayed. System, please speak with me! On the other hand, using collections works fine.

Sometimes, after I had placed many Java-Code into my Flow Script, the call of the function cocoon.sendPage() has no effect. No error message displayed, too!

Has anyone one of these problems, too?

It would be nice, if anyone can tell me how to solve these problems, because I love the use of Flow Script and I want to use it in all my future applications. But with these problems, there is no way to do that.

Thank you.

Stephan Niedermeier







Re: Problems using Java code in Flow Scripts

Posted by Stephan Niedermeier <ma...@logabit.com>.
Sorry, the first problem was my mistake. I have used , but : was needed.

cocoon.sendPage("example.jxt",{"user" : user});

But the other problems not resolved yet.

Thank you.

Stephan Niedermeier

  ----- Original Message ----- 
  From: Stephan Niedermeier 
  To: users@cocoon.apache.org 
  Sent: Friday, September 05, 2003 6:40 PM
  Subject: Problems using Java code in Flow Scripts


  Hello,

  at first I would say that the concept of Control Flow is one of the best concepts I have ever heard in web development. The use of Flow Script is very easy and fantastic. But there is one big problem for me: It's not possible to use the Flow Script in professional applications! The reason: There are many, many problems of using Java-Code in the Flow Script. 

  An example: Why cause the following lines a NullPointerException

  function main() {

    importClass(Packages.foo.bar.User);

    user = new User();
    user.setName("Donald Duck");
    user.setPassword("foo");
    user.setActive(false);

    cocoon.sendPage("example.jxt",{"user", user});
  }

  and the following - without the user object as parameter for sendPage - not?

  function main() {

    importClass(Packages.foo.bar.User);

    user = new User();
    user.setName("Donald Duck");
    user.setPassword("foo");
    user.setActive(false);

    cocoon.sendPage("example.jxt");
  } 

  My JXTemplate looks like the following lines:

  <?xml version="1.0" encoding="ISO-8859-1"?>

  <html>
  <header>
  <titleTest</title>
  </header>
  <body>

      <!-- commenting this doesn't solve the problem --->
      Name: ${user.name}
      
  </body>
  </html>

  The object "user" exists at foo.bar and the pipeline works fine, because I had tested it with other calls from the Flow Script. And yes, I have already cleared the "works" directory.

  But this is not just the only problem. There are many other strange problems using Flow Script: 

  Sometimes - not anytime - after an error executing a Flow Script has occured, the Flow Script file is not longer readable and blocked. Why? Not closed Stream? Only restarting tomcat solves this problem.

  Using JXForms with JavaBeans containing a String[] Array for example doesn't work. But there is no error message displayed. System, please speak with me! On the other hand, using collections works fine.

  Sometimes, after I had placed many Java-Code into my Flow Script, the call of the function cocoon.sendPage() has no effect. No error message displayed, too!

  Has anyone one of these problems, too?

  It would be nice, if anyone can tell me how to solve these problems, because I love the use of Flow Script and I want to use it in all my future applications. But with these problems, there is no way to do that.

  Thank you.

  Stephan Niedermeier







Re: Problems using Java code in Flow Scripts

Posted by Bruno Dumon <br...@outerthought.org>.
On Fri, 2003-09-05 at 18:40, Stephan Niedermeier wrote:
> Hello,
>  
> at first I would say that the concept of Control Flow is one of the
> best concepts I have ever heard in web development. The use of Flow
> Script is very easy and fantastic. But there is one big problem for
> me: It's not possible to use the Flow Script in professional
> applications! The reason: There are many, many problems of using
> Java-Code in the Flow Script. 
>  
> An example: Why cause the following lines a NullPointerException
>  
> function main() {
>  
>   importClass(Packages.foo.bar.User);
>  
>   user = new User();
>   user.setName("Donald Duck");
>   user.setPassword("foo");
>   user.setActive(false);
>  
>   cocoon.sendPage("example.jxt",{"user", user});

I think you got a typo here: {"user" : user}

note the colon between "user" and user.

As the other reply suggested, always use "var" when introducing new
variables. Otherwise your variable with belong to the global scope and
will cause implicit session creation.
 
-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


Re: Problems using Java code in Flow Scripts

Posted by Peter Velychko <v_...@ukr.net>.
Hello Stephan,

Friday, September 5, 2003, 7:40:08 PM, you wrote:

SN> Hello,

SN> at first I would say that the concept of Control Flow is one of the best concepts I have ever heard in web development. The use of Flow Script is very easy and fantastic. But there is one big
SN> problem for me: It's not possible to use the Flow Script in professional applications! The reason: There are many, many problems of using Java-Code in the Flow Script. 

SN> An example: Why cause the following lines a NullPointerException

SN> function main() {

SN>   importClass(Packages.foo.bar.User);

SN>   user = new User();
SN>   user.setName("Donald Duck");
SN>   user.setPassword("foo");
SN>   user.setActive(false);

SN>   cocoon.sendPage("example.jxt",{"user", user});
SN> }

The JavaScript has the following definition for variable:
var varName = someThing;

Try to use
var user = new User();


SN> and the following - without the user object as parameter for sendPage - not?

SN> function main() {

SN>   importClass(Packages.foo.bar.User);

SN>   user = new User();
SN>   user.setName("Donald Duck");
SN>   user.setPassword("foo");
SN>   user.setActive(false);

SN>   cocoon.sendPage("example.jxt");
SN> } 

SN> My JXTemplate looks like the following lines:

SN> <?xml version="1.0" encoding="ISO-8859-1"?>

SN> <html>
SN> <header>
SN> <titleTest</title>
SN> </header>
SN> <body>

SN>     <!-- commenting this doesn't solve the problem --->
SN>     Name: ${user.name}
    
SN> </body>
SN> </html>

SN> The object "user" exists at foo.bar and the pipeline works fine, because I had tested it with other calls from the Flow Script. And yes, I have already cleared the "works" directory.

SN> But this is not just the only problem. There are many other strange problems using Flow Script: 

SN> Sometimes - not anytime - after an error executing a Flow Script has occured, the Flow Script file is not longer readable and blocked. Why? Not closed Stream? Only restarting tomcat solves this
SN> problem.

SN> Using JXForms with JavaBeans containing a String[] Array for example doesn't work. But there is no error message displayed. System, please speak with me! On the other hand, using collections
SN> works fine.

SN> Sometimes, after I had placed many Java-Code into my Flow Script, the call of the function cocoon.sendPage() has no effect. No error message displayed, too!

SN> Has anyone one of these problems, too?

SN> It would be nice, if anyone can tell me how to solve these problems, because I love the use of Flow Script and I want to use it in all my future applications. But with these problems, there is no
SN> way to do that.

SN> Thank you.

SN> Stephan Niedermeier









-- 
Best regards,
Peter Velychko                            
v_peter@ukr.net


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