cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andre Juffer <ajuf...@sun3.oulu.fi>
Subject Re: How can i acces to Class from a Class name ?
Date Mon, 05 Feb 2007 19:00:14 GMT
Manuel Mata wrote:
> Hi i'm using cocoon with hibernate and flowscript/jx
> just like hibernate tutorial in wiki. Everything works
> fine but this.
> 
> I have a javascript function which takes an id
> parameter
> from the request and i need to recover the object with
> hibernate API, but this code doesn't work.
> 
> function perfil_detail(){
> 	openHibernateSession();
> 	var id = Request.getParameter("id");
> 	var perfil =
> hs.load(Packages.mypackage.MyClass.class, new
> java.lang.Long(id));


Instead you could also use

var perfil = hs.createQuery("mypackage.MyClass as myClass where id = " + 
id).uniqueResult();

Note that in Java you would normally do something like

MyClass myClass = (MyClass) hs.createQuery("mypackage.MyClass as myClass 
where id = " + id).uniqueResult();

This is required since createQuery returns an Object and not a MyClass. 
This could mean that you would need another class that in turn would 
query the database.


> 	cocoon.sendPage(
> 		"perfil.detail.display",
> 		{perfil : perfil}
> 	);
> }
> 
> The hibernate Session.load takes a Class parameter
> first so, how can i get that Class object in
> flowscript?
> 
> I get this error:
> 
> org.mozilla.javascript.EcmaError: missing name after .
> operator
> SyntaxError -
> file:/C:/cocoon-2.1.9/build/webapp/.../perfiles.js -
> 28:67
> 
> I searched on docs but dont find anything related to
> this. Can anyone help ?
> 
> Thx in advance.
> 
> 
> 		
> ______________________________________________ 
> LLama Gratis a cualquier PC del Mundo. 
> Llamadas a fijos y móviles desde 1 céntimo por minuto. 
> http://es.voice.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


-- 
Andre H. Juffer              | Email: Andre.Juffer@oulu.fi
The Biocenter and            | WWW: www.biochem.oulu.fi/Biocomputing/
     the Dep. of Biochemistry | Fax: +358-8-553-1141
University of Oulu, Finland  | Phone: +358-8-553 1161
Triacle Biocomputing         | WWW: www.triacle-bc.com

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


Mime
View raw message