cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robby Pelssers" <robby.pelss...@ciber.com>
Subject RE: RE: RE: classes in block / usage in flowscript
Date Thu, 04 Jun 2009 20:57:59 GMT
Patrick,

I re-read your question again:
> So your suggestion would be to include all Classes into Spring to get
> access through getComponent("someBean"); !? 

I do not advise to configure all classes as spring beans of course.  Only the ones which have
a more static behavior.

A good use case can be found on my blog:

http://robbypelssers.blogspot.com/2009/06/cocoon-22-block-handling-all-file.html

Cheers,
Robby

-----Original Message-----
From: Patrick Heiden [mailto:patrickheiden@gmx.de] 
Sent: Thursday, June 04, 2009 4:04 PM
To: users@cocoon.apache.org
Subject: Re: RE: RE: classes in block / usage in flowscript

Thanks Robby,

that was much of help to me!

Cheers and a nice day,
Patrick
-------- Original-Nachricht --------
> Datum: Thu, 4 Jun 2009 15:28:58 +0200
> Von: "Robby Pelssers" <robby.pelssers@ciber.com>
> An: users@cocoon.apache.org
> Betreff: RE: RE: classes in block / usage in flowscript

> Hi Patrick,
> 
> If I'm not mistaken I think that some packages of the jdk are imported by
> default so you don't need to explicitly import.
> 
> http://cocoon.apache.org/2.1/userdocs/flow/java.html
> 
> But my advise is to import the ones you need explicitly.
> 
> Cheers,
> Robby
> 
> -----Original Message-----
> From: Patrick Heiden [mailto:patrickheiden@gmx.de] 
> Sent: Thursday, June 04, 2009 3:19 PM
> To: users@cocoon.apache.org
> Subject: Re: RE: classes in block / usage in flowscript
> 
> Hello Robby,
> 
> thx for the fast reply!
> ...
> 
> > The proper way to access java from flowscript is to import the classes
> > at the top:
> > 
> > importClass(Packages.com.mycompany.util.MyClass);
> 
> alright, i can get with that, but all i've done was
> 
> importPackage(Packages.some.package.inside.blockStructure);
> 
> and your following statement was also working!
> 
> > 
> > 
> > then you can do this:
> > var myclass = new MyClass();
> > 
> > This should work if at least that package is included in the classpath.
> 
> .. the confusing thing to me is, that it is possible to get new Objects
> like java.io.ByteArrayOutputStream WITHOUT importing that class / package!
> So why it is not possible with classes defined inside my block?
> 
> > 
> > And if you want to access beans, you should not use this construction,
> > neither is importing the class needed.
> > 
> > Then you just do:
> > var mybean = cocoon.getComponent("nameOfBean");
> 
> So your suggestion would be to include all Classes into Spring to get
> access through getComponent("someBean"); !? I could go with that too, even if
> my beans would have prototype scope, no problem - but my question remains:
> WHY ist isn't possible to instantiate the classes inside block like other
> classes inside my classpath?
> 
> Cheers and much thanks,
> Patrick
> 
> > 
> > Cheers,
> > Robby
> > 
> > -----Original Message-----
> > From: Patrick Heiden [mailto:patrickheiden@gmx.de] 
> > Sent: Thursday, June 04, 2009 1:09 PM
> > To: users@cocoon.apache.org
> > Subject: classes in block / usage in flowscript
> > 
> > Hello together,
> > 
> > I am a little bit wondering about following issue.
> > Assume we have a Java-class inside a cocoon-block (i.e. like the demo
> > bean out of the tutorial).
> > 
> > When I get a new instance of this class through
> > 
> > ...
> > var foo = new some.package.inside.block.MyClass();
> > ...
> > 
> > then i get this error:
> > 
> > ...
> > Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "some" is
> > not defined.
> > (file:///home/pepemuck/_opt/devel/ISAC_DEV/isacBlocks/isacTermBlock/./sr
> > c/main/resources/COB-INF/flow/MyFlowScript.js
> > 
> > There is no Problem to get instances like
> > java.io.ByteArrayOutputStream() or the like.
> > 
> > So why is this error thrown when I want to get new Objects out of a
> > package-hierarchy inside the package-hosting block?
> > 
> > By the way - instantiation via 
> > 
> > ...
> > var foo = MyClass();
> > ...
> > 
> > works perfectly well!
> > 
> > 
> > Any hints to understand WHY this happens?
> > 
> > Thanks upfront
> > 
> > with best regards,
> > Patrick
> > -- 
> > GMX FreeDSL mit DSL 6.000 Flatrate und Telefonanschluss nur 17,95
> > Euro/mtl.!
> > http://dslspecial.gmx.de/freedsl-aktionspreis/?ac=OM.AD.PD003K11308T4569
> > a
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
> 
> -- 
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org

-- 
GMX FreeDSL mit DSL 6.000 Flatrate und Telefonanschluss nur 17,95 Euro/mtl.!
http://dslspecial.gmx.de/freedsl-aktionspreis/?ac=OM.AD.PD003K11308T4569a

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


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


Mime
View raw message