You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by michael shek sia lim <mi...@eigentechnology.com> on 2002/12/13 14:30:05 UTC
adding Javascript
Dear All,
If a javascript is to be added to my Turbine application, where can I find
the <head> </head> pair in the setup so that I can achieve what I intend
to do?
cheers
michael
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: AW: AW: adding Javascript
Posted by michael shek sia lim <mi...@eigentechnology.com>.
Thanks to all of you who offered help. I tried adding a script directly
to the template as suggested by Colin and IT WORKED.
best wishes
michael
> In my Layout/default.vm I have a reference to both a CSS file and
> global.js
>
> <SCRIPT SRC = "$context_path/javascripts/global.js"></SCRIPT>
> <link href="$context_path/stylesheets/foo.css" rel="stylesheet"
> type="text/css">
>
> Furthermore when I have javascript specific to a template I include it
> at the top of *that* template.
>
> Works for us.
>
> /c
>
>
> You might not even need the class, I think most if not all of the
> methods that are added are now in the standard TemplatePageAttributes
> (although I haven't specifically checked).
>
> Cheers,
>
> Scott
> --
> Scott Eade
> Backstage Technologies Pty. Ltd.
> http://www.backstagetech.com.au
> .Mac Chat/AIM: seade at mac dot com
>
>> From: "Marc Lustig" <ma...@marclustig.com>
>> Reply-To: "Turbine Users List" <tu...@jakarta.apache.org> Date:
>> Sat, 14 Dec 2002 03:07:09 +0100
>> To: "Turbine Users List" <tu...@jakarta.apache.org>
>> Subject: AW: AW: adding Javascript
>>
>> Michael,
>>
>> I use
>>
>> $page.setScript("JavaScript",
>> "text/javascript",$content.getURI("resources/global.js"))
>>
>> and this class:
>>
>> package de.geoconnect.audiotex.turbineext;
>>
>> import org.apache.turbine.util.template.TemplatePageAttributes;
>> import org.apache.turbine.util.RunData;
>> import org.apache.ecs.html.Script;
>> import org.apache.ecs.html.Link;
>> import org.apache.ecs.html.Style;
>>
>> public class ExtTemplatePageAttributes extends TemplatePageAttributes
>> { private RunData data = null;
>>
>> /**
>> * Default constructor. The init method must be called before use */
>> public ExtTemplatePageAttributes()
>> {
>> super();
>> }
>>
>> /**
>> * Construct a new instance with the given RunData object.
>> *
>> * @param data a RunData instance
>> */
>> public ExtTemplatePageAttributes(RunData data)
>> {
>> super(data);
>> this.data = data;
>> }
>>
>> /**
>> * Initialise this instance with the given RunData object.
>> * (ApplicationTool method)
>> *
>> * @param data Assumed to be a RunData instance
>> */
>> public void init(Object data)
>> {
>> super.init(data);
>>
>> // we blithely cast to RunData as the runtime error thrown
>> // if data is null or not RunData is appropriate.
>> this.data = (RunData)data;
>> }
>>
>> /**
>> * Refresh method - does nothing
>> */
>> public void refresh()
>> {
>> // empty
>> }
>>
>> /**
>> * Adds a LINK to a javascript file to the HEAD of the page.
>> *
>> * @param url A String.
>> * @return A TemplatePageAttributesEx (self).
>> */
>> public TemplatePageAttributes setScript(String url)
>> {
>> data.getPage().getHead().addElement(new Script().setSrc(url)
>> .setType("text/javascript").setLanguage("JavaScript"));
>> return this;
>> }
>> public TemplatePageAttributes setScript(String lang, String type,
>> String url)
>> {
>> data.getPage().getHead().addElement(new Script()
>> .setLanguage(lang).setType(type).setSrc(url));
>> return this;
>> }
>> /**
>> * Adds a LINK to a CSS stylesheet to the HEAD of the page, allowing
>> the * media type to be specified.
>> *
>> * @param url The value for the <code>href</code> attribute.
>> * @param media The value for the <code>media</code> attribute. *
>> @return a <code>TemplatePageAttributes</code> (self).
>> */
>> public TemplatePageAttributes setStyleSheet(String url, String media)
>> {
>> data.getPage().getHead().addElement(new
>> Link().setRel("stylesheet")
>> .setType("text/css").setMedia(media).setHref(url));
>> return this;
>> }
>>
>> // /**
>> // * Adds a STYLE element to the HEAD of the page.
>> // *
>> // * @param styleText The content of the style element.
>> // * @param media The value for the <code>media</code> attribute.
>> // * @return a <code>TemplatePageAttributes</code> (self).
>> // */
>> // public TemplatePageAttributes setStyleElement(String styleText,
> String
>> media)
>> // {
>> // Style style = new Style("text/css", styleText);
>> // style.setMedia(media);
>> // data.getPage().getHead().addElement(style);
>> // return this;
>> // }
>>
>> /**
>> * Adds a STYLE element to the HEAD of the page with the provided
>> content.
>> *
>> * @param styleText The contents of the <code>style</code> tag. *
>> @return a <code>TemplatePageAttributes</code> (self).
>> */
>> public TemplatePageAttributes setStyle(String styleText)
>> {
>> data.getPage().getHead().addElement(new Style("text/css",
>> styleText));
>> return this;
>> }
>>
>> }
>>
>>
>> You have to register the class in your TR.props.
>>
>> Marc
>>
>>
>>
>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
>>> Gesendet: Samstag, 14. Dezember 2002 01:20
>>> An: turbine-user@jakarta.apache.org
>>> Betreff: Re: AW: adding Javascript
>>>
>>>
>>> The discussion in the link below does not seem to be conclusive. Is
>>> there any other solution to Javascript used in conjunction with
>>> Velocity?
>>>
>>> cheers
>>> michael
>>>
>>>
>>>
>>>
>>>
>>>> Hi,
>>>> it is described in the list archive.
>>>> Start here for example:
>>>>
>>> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg07518.html
>>>>
>>>> Marc
>>>>
>>>>
>>>>> -----Ursprüngliche Nachricht-----
>>>>> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
>>>>> Gesendet: Freitag, 13. Dezember 2002 14:30
>>>>> An: turbine-user@jakarta.apache.org
>>>>> Betreff: adding Javascript
>>>>>
>>>>>
>>>>> Dear All,
>>>>>
>>>>> If a javascript is to be added to my Turbine application, where can
>>>>> I find the <head> </head> pair in the setup so that I can achieve
>>>>> what I intend to do?
>>>>>
>>>>> cheers
>>>>> michael
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> To unsubscribe, e-mail:
>>>>> <ma...@jakarta.apache.org>
>>>>> For additional commands, e-mail:
>>>>> <ma...@jakarta.apache.org>
>>>>>
>>>>
>>>>
>>>> --
>>>> To unsubscribe, e-mail:
>>>> <ma...@jakarta.apache.org> For additional
>>>> commands, e-mail: <ma...@jakarta.apache.org>
>>>
>>>
>>>
>>>
>>> --
>>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@jakarta.apache.org>
>>
>>
>> --
>> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org> For additional
> commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: AW: AW: adding Javascript
Posted by Colin Chalmers <co...@maxware.nl>.
In my Layout/default.vm I have a reference to both a CSS file and global.js
<SCRIPT SRC = "$context_path/javascripts/global.js"></SCRIPT>
<link href="$context_path/stylesheets/foo.css" rel="stylesheet"
type="text/css">
Furthermore when I have javascript specific to a template I include it at
the top of *that* template.
Works for us.
/c
You might not even need the class, I think most if not all of the methods
that are added are now in the standard TemplatePageAttributes (although I
haven't specifically checked).
Cheers,
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
.Mac Chat/AIM: seade at mac dot com
> From: "Marc Lustig" <ma...@marclustig.com>
> Reply-To: "Turbine Users List" <tu...@jakarta.apache.org>
> Date: Sat, 14 Dec 2002 03:07:09 +0100
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Subject: AW: AW: adding Javascript
>
> Michael,
>
> I use
>
> $page.setScript("JavaScript",
> "text/javascript",$content.getURI("resources/global.js"))
>
> and this class:
>
> package de.geoconnect.audiotex.turbineext;
>
> import org.apache.turbine.util.template.TemplatePageAttributes;
> import org.apache.turbine.util.RunData;
> import org.apache.ecs.html.Script;
> import org.apache.ecs.html.Link;
> import org.apache.ecs.html.Style;
>
> public class ExtTemplatePageAttributes extends TemplatePageAttributes {
> private RunData data = null;
>
> /**
> * Default constructor. The init method must be called before use
> */
> public ExtTemplatePageAttributes()
> {
> super();
> }
>
> /**
> * Construct a new instance with the given RunData object.
> *
> * @param data a RunData instance
> */
> public ExtTemplatePageAttributes(RunData data)
> {
> super(data);
> this.data = data;
> }
>
> /**
> * Initialise this instance with the given RunData object.
> * (ApplicationTool method)
> *
> * @param data Assumed to be a RunData instance
> */
> public void init(Object data)
> {
> super.init(data);
>
> // we blithely cast to RunData as the runtime error thrown
> // if data is null or not RunData is appropriate.
> this.data = (RunData)data;
> }
>
> /**
> * Refresh method - does nothing
> */
> public void refresh()
> {
> // empty
> }
>
> /**
> * Adds a LINK to a javascript file to the HEAD of the page.
> *
> * @param url A String.
> * @return A TemplatePageAttributesEx (self).
> */
> public TemplatePageAttributes setScript(String url)
> {
> data.getPage().getHead().addElement(new Script().setSrc(url)
> .setType("text/javascript").setLanguage("JavaScript"));
> return this;
> }
> public TemplatePageAttributes setScript(String lang, String type, String
> url)
> {
> data.getPage().getHead().addElement(new Script()
> .setLanguage(lang).setType(type).setSrc(url));
> return this;
> }
> /**
> * Adds a LINK to a CSS stylesheet to the HEAD of the page, allowing the
> * media type to be specified.
> *
> * @param url The value for the <code>href</code> attribute.
> * @param media The value for the <code>media</code> attribute.
> * @return a <code>TemplatePageAttributes</code> (self).
> */
> public TemplatePageAttributes setStyleSheet(String url, String media)
> {
> data.getPage().getHead().addElement(new Link().setRel("stylesheet")
> .setType("text/css").setMedia(media).setHref(url));
> return this;
> }
>
> // /**
> // * Adds a STYLE element to the HEAD of the page.
> // *
> // * @param styleText The content of the style element.
> // * @param media The value for the <code>media</code> attribute.
> // * @return a <code>TemplatePageAttributes</code> (self).
> // */
> // public TemplatePageAttributes setStyleElement(String styleText,
String
> media)
> // {
> // Style style = new Style("text/css", styleText);
> // style.setMedia(media);
> // data.getPage().getHead().addElement(style);
> // return this;
> // }
>
> /**
> * Adds a STYLE element to the HEAD of the page with the provided
> content.
> *
> * @param styleText The contents of the <code>style</code> tag.
> * @return a <code>TemplatePageAttributes</code> (self).
> */
> public TemplatePageAttributes setStyle(String styleText)
> {
> data.getPage().getHead().addElement(new Style("text/css",
> styleText));
> return this;
> }
>
> }
>
>
> You have to register the class in your TR.props.
>
> Marc
>
>
>
>
>> -----Ursprüngliche Nachricht-----
>> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
>> Gesendet: Samstag, 14. Dezember 2002 01:20
>> An: turbine-user@jakarta.apache.org
>> Betreff: Re: AW: adding Javascript
>>
>>
>> The discussion in the link below does not seem to be conclusive. Is there
>> any other solution to Javascript used in conjunction with Velocity?
>>
>> cheers
>> michael
>>
>>
>>
>>
>>
>>> Hi,
>>> it is described in the list archive.
>>> Start here for example:
>>>
>> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg07518.html
>>>
>>> Marc
>>>
>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
>>>> Gesendet: Freitag, 13. Dezember 2002 14:30
>>>> An: turbine-user@jakarta.apache.org
>>>> Betreff: adding Javascript
>>>>
>>>>
>>>> Dear All,
>>>>
>>>> If a javascript is to be added to my Turbine application, where can I
>>>> find the <head> </head> pair in the setup so that I can achieve what I
>>>> intend to do?
>>>>
>>>> cheers
>>>> michael
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> To unsubscribe, e-mail:
>>>> <ma...@jakarta.apache.org>
>>>> For additional commands, e-mail:
>>>> <ma...@jakarta.apache.org>
>>>>
>>>
>>>
>>> --
>>> To unsubscribe, e-mail:
>>> <ma...@jakarta.apache.org> For additional
>>> commands, e-mail: <ma...@jakarta.apache.org>
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Join Tables
Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
Sorry Folks,
I may not be very clear in my previous questions. What I want to know is
what to code in a .vm file in order to get data from a pair of joint
tables.
Table A
ID
data1
data2
data3
Table B
ID
LINK_ID <--- joint to ID in Table A
data4
data5
I want to get all data in Table B when ID(A) = LINK_ID(B). Assuming that
the java code are there already. I only know how to get data from one
Table, i.e. $someVector.somedata.
thanks
michael
> The Criteria howto gives very good explanation to the Java code. I
> wonder if there is another example given on how to display data from a
> pair of joint tables through a .vm file.
>
>
> best wishes
> michael
>
>
>> The Criteria howto explains that part.
>>
>> -----Original Message-----
>> From: Eigen Technology Pty Ltd [mailto:michael@eigentechnology.com]
>> Sent: Sunday, December 15, 2002 1:06 AM
>> To: turbine-user@jakarta.apache.org
>> Subject: RE: Join Tables
>>
>>
>> thanks Quinton,
>>
>> I have read the Peers documentation that comes with TDK. The excerpt I
>> included was from there. However, this Peers doco says that the
>> subclassing bit is out-of-date.
>>
>> "Note: some information here is out of date (Subclassing). The Class
>> Hierarchy document provides more current information regarding mapping
>> a hierarchy in the OM/Peer system."
>>
>>
>> And I don't know where to get an up-to-date one. I just realized that
>> by including the FOREIGN key in the schema will get TDK to include
>> most of the codes. Now I need an example using Velocity to extract
>> data from a pair of joined table. There is no such example in the
>> Peers doco.
>>
>> best wishes
>> michael
>>
>>
>>
>>
>>
>>
>>
>>
>>> Read the Criteria Howto for Torque. It explains how to perform
>>> joins.
>>
>>> http://jakarta.apache.org/turbine/torque/criteria-howto.html
>>>
>>> You should also read over the Peers Howto. You will find a link to
>>> this from the above URL. The Peers Howto should probably be read
>>> first.
>>>
>>> -----Original Message-----
>>> From: Eigen Technology Pty Ltd [mailto:michael@eigentechnology.com]
>>> Sent: Sunday, December 15, 2002 12:30 AM
>>> To: turbine-user@jakarta.apache.org
>>> Subject: Join Tables
>>>
>>>
>>> hi,
>>>
>>> could anyone point me to an document that gives instructions to join
>>> tables.
>>>
>>> I read the documentation that came with TDK, it is a bit unclear ...
>>>
>>> public Vector doSelectWithCategory (Criteria crit) throws Exception {
>>> crit.addJoin (ItemPeer.CATEGORY_ID, CategoryPeer.CATEGORY_ID);
>>>
>>> addSelectColumns ( criteria );
>>> CategoryPeer.addSelectColumns ( criteria )
>>>
>>> // BasePeer returns a Vector of Value (Village) arrays. The
>>> array
>>
>>> // order follows the order columns were placed in the Select clause.
>>>
>>> Vector rows = BasePeer.doSelect(criteria);
>>>
>>> Vector results = new Vector();
>>>
>>> // populate the object(s)
>>> for ( int i=0; i<rows.size(); i++ )
>>> {
>>> Record row = (Record)rows.elementAt(i);
>>>
>>> MyItem itm = row2Object (row,
>>> 1,
>>> Class.forName
>>> ("com.mycompany.om.MyItem"))
>>>
>>> MyCategory cat = CategoryPeer.row2Object
>>> (row,
>>> numColumns+1,
>>> Class.forName
>>> ("com.mycompany.om.MyCategory"))
>>>
>>> itm.setCategory (cat);
>>> results.add (itm);
>>> }
>>>
>>> return results;
>>>
>>> }
>>>
>>> best wishes
>>> michael
>>>
>>>
>>>
>>>
>>> --
>>> To unsubscribe, e-mail:
>>> <ma...@jakarta.apache.org>
>>> For additional commands, e-mail:
>>> <ma...@jakarta.apache.org>
>>>
>>>
>>>
>>> --
>>> To unsubscribe, e-mail:
>>> <ma...@jakarta.apache.org> For additional
>>> commands, e-mail: <ma...@jakarta.apache.org>
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@jakarta.apache.org>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org> For additional
> commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Join Tables
Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
The Criteria howto gives very good explanation to the Java code. I wonder
if there is another example given on how to display data from a pair of
joint tables through a .vm file.
best wishes
michael
> The Criteria howto explains that part.
>
> -----Original Message-----
> From: Eigen Technology Pty Ltd [mailto:michael@eigentechnology.com]
> Sent: Sunday, December 15, 2002 1:06 AM
> To: turbine-user@jakarta.apache.org
> Subject: RE: Join Tables
>
>
> thanks Quinton,
>
> I have read the Peers documentation that comes with TDK. The excerpt I
> included was from there. However, this Peers doco says that the
> subclassing bit is out-of-date.
>
> "Note: some information here is out of date (Subclassing). The Class
> Hierarchy document provides more current information regarding mapping a
> hierarchy in the OM/Peer system."
>
>
> And I don't know where to get an up-to-date one. I just realized that by
> including the FOREIGN key in the schema will get TDK to include most of
> the codes. Now I need an example using Velocity to extract data from a
> pair of joined table. There is no such example in the Peers doco.
>
> best wishes
> michael
>
>
>
>
>
>
>
>
>> Read the Criteria Howto for Torque. It explains how to perform joins.
>
>> http://jakarta.apache.org/turbine/torque/criteria-howto.html
>>
>> You should also read over the Peers Howto. You will find a link to
>> this from the above URL. The Peers Howto should probably be read
>> first.
>>
>> -----Original Message-----
>> From: Eigen Technology Pty Ltd [mailto:michael@eigentechnology.com]
>> Sent: Sunday, December 15, 2002 12:30 AM
>> To: turbine-user@jakarta.apache.org
>> Subject: Join Tables
>>
>>
>> hi,
>>
>> could anyone point me to an document that gives instructions to join
>> tables.
>>
>> I read the documentation that came with TDK, it is a bit unclear ...
>>
>> public Vector doSelectWithCategory (Criteria crit) throws Exception {
>> crit.addJoin (ItemPeer.CATEGORY_ID, CategoryPeer.CATEGORY_ID);
>>
>> addSelectColumns ( criteria );
>> CategoryPeer.addSelectColumns ( criteria )
>>
>> // BasePeer returns a Vector of Value (Village) arrays. The array
>
>> // order follows the order columns were placed in the Select clause.
>>
>> Vector rows = BasePeer.doSelect(criteria);
>>
>> Vector results = new Vector();
>>
>> // populate the object(s)
>> for ( int i=0; i<rows.size(); i++ )
>> {
>> Record row = (Record)rows.elementAt(i);
>>
>> MyItem itm = row2Object (row,
>> 1,
>> Class.forName
>> ("com.mycompany.om.MyItem"))
>>
>> MyCategory cat = CategoryPeer.row2Object
>> (row,
>> numColumns+1,
>> Class.forName
>> ("com.mycompany.om.MyCategory"))
>>
>> itm.setCategory (cat);
>> results.add (itm);
>> }
>>
>> return results;
>>
>> }
>>
>> best wishes
>> michael
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@jakarta.apache.org>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org> For additional
>> commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Join Tables
Posted by Quinton McCombs <qm...@nequalsone.com>.
The Criteria howto explains that part.
-----Original Message-----
From: Eigen Technology Pty Ltd [mailto:michael@eigentechnology.com]
Sent: Sunday, December 15, 2002 1:06 AM
To: turbine-user@jakarta.apache.org
Subject: RE: Join Tables
thanks Quinton,
I have read the Peers documentation that comes with TDK. The excerpt I
included was from there. However, this Peers doco says that the
subclassing bit is out-of-date.
"Note: some information here is out of date (Subclassing). The Class
Hierarchy document provides more current information regarding mapping a
hierarchy in the OM/Peer system."
And I don't know where to get an up-to-date one. I just realized that by
including the FOREIGN key in the schema will get TDK to include most of
the codes. Now I need an example using Velocity to extract data from a
pair of joined table. There is no such example in the Peers doco.
best wishes
michael
> Read the Criteria Howto for Torque. It explains how to perform joins.
> http://jakarta.apache.org/turbine/torque/criteria-howto.html
>
> You should also read over the Peers Howto. You will find a link to
> this from the above URL. The Peers Howto should probably be read
> first.
>
> -----Original Message-----
> From: Eigen Technology Pty Ltd [mailto:michael@eigentechnology.com]
> Sent: Sunday, December 15, 2002 12:30 AM
> To: turbine-user@jakarta.apache.org
> Subject: Join Tables
>
>
> hi,
>
> could anyone point me to an document that gives instructions to join
> tables.
>
> I read the documentation that came with TDK, it is a bit unclear ...
>
> public Vector doSelectWithCategory (Criteria crit) throws Exception {
> crit.addJoin (ItemPeer.CATEGORY_ID, CategoryPeer.CATEGORY_ID);
>
> addSelectColumns ( criteria );
> CategoryPeer.addSelectColumns ( criteria )
>
> // BasePeer returns a Vector of Value (Village) arrays. The array
> // order follows the order columns were placed in the Select clause.
>
> Vector rows = BasePeer.doSelect(criteria);
>
> Vector results = new Vector();
>
> // populate the object(s)
> for ( int i=0; i<rows.size(); i++ )
> {
> Record row = (Record)rows.elementAt(i);
>
> MyItem itm = row2Object (row,
> 1,
> Class.forName
> ("com.mycompany.om.MyItem"))
>
> MyCategory cat = CategoryPeer.row2Object
> (row,
> numColumns+1,
> Class.forName
> ("com.mycompany.om.MyCategory"))
>
> itm.setCategory (cat);
> results.add (itm);
> }
>
> return results;
>
> }
>
> best wishes
> michael
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org> For additional
> commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Join Tables
Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
thanks Quinton,
I have read the Peers documentation that comes with TDK. The excerpt I
included was from there. However, this Peers doco says that the
subclassing bit is out-of-date.
"Note: some information here is out of date (Subclassing). The Class
Hierarchy document provides more current information regarding mapping a
hierarchy in the OM/Peer system."
And I don't know where to get an up-to-date one. I just realized that by
including the FOREIGN key in the schema will get TDK to include most of
the codes. Now I need an example using Velocity to extract data from a
pair of joined table. There is no such example in the Peers doco.
best wishes
michael
> Read the Criteria Howto for Torque. It explains how to perform joins.
> http://jakarta.apache.org/turbine/torque/criteria-howto.html
>
> You should also read over the Peers Howto. You will find a link to this
> from the above URL. The Peers Howto should probably be read first.
>
> -----Original Message-----
> From: Eigen Technology Pty Ltd [mailto:michael@eigentechnology.com]
> Sent: Sunday, December 15, 2002 12:30 AM
> To: turbine-user@jakarta.apache.org
> Subject: Join Tables
>
>
> hi,
>
> could anyone point me to an document that gives instructions to join
> tables.
>
> I read the documentation that came with TDK, it is a bit unclear ...
>
> public Vector doSelectWithCategory (Criteria crit) throws Exception {
> crit.addJoin (ItemPeer.CATEGORY_ID, CategoryPeer.CATEGORY_ID);
>
> addSelectColumns ( criteria );
> CategoryPeer.addSelectColumns ( criteria )
>
> // BasePeer returns a Vector of Value (Village) arrays. The array
> // order follows the order columns were placed in the Select clause.
>
> Vector rows = BasePeer.doSelect(criteria);
>
> Vector results = new Vector();
>
> // populate the object(s)
> for ( int i=0; i<rows.size(); i++ )
> {
> Record row = (Record)rows.elementAt(i);
>
> MyItem itm = row2Object (row,
> 1,
> Class.forName
> ("com.mycompany.om.MyItem"))
>
> MyCategory cat = CategoryPeer.row2Object
> (row,
> numColumns+1,
> Class.forName
> ("com.mycompany.om.MyCategory"))
>
> itm.setCategory (cat);
> results.add (itm);
> }
>
> return results;
>
> }
>
> best wishes
> michael
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org> For additional
> commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Join Tables
Posted by Quinton McCombs <qm...@nequalsone.com>.
Read the Criteria Howto for Torque. It explains how to perform joins.
http://jakarta.apache.org/turbine/torque/criteria-howto.html
You should also read over the Peers Howto. You will find a link to this
from the above URL. The Peers Howto should probably be read first.
-----Original Message-----
From: Eigen Technology Pty Ltd [mailto:michael@eigentechnology.com]
Sent: Sunday, December 15, 2002 12:30 AM
To: turbine-user@jakarta.apache.org
Subject: Join Tables
hi,
could anyone point me to an document that gives instructions to join
tables.
I read the documentation that came with TDK, it is a bit unclear ...
public Vector doSelectWithCategory (Criteria crit) throws Exception {
crit.addJoin (ItemPeer.CATEGORY_ID, CategoryPeer.CATEGORY_ID);
addSelectColumns ( criteria );
CategoryPeer.addSelectColumns ( criteria )
// BasePeer returns a Vector of Value (Village) arrays. The array
// order follows the order columns were placed in the Select clause.
Vector rows = BasePeer.doSelect(criteria);
Vector results = new Vector();
// populate the object(s)
for ( int i=0; i<rows.size(); i++ )
{
Record row = (Record)rows.elementAt(i);
MyItem itm = row2Object (row,
1,
Class.forName
("com.mycompany.om.MyItem"))
MyCategory cat = CategoryPeer.row2Object
(row,
numColumns+1,
Class.forName
("com.mycompany.om.MyCategory"))
itm.setCategory (cat);
results.add (itm);
}
return results;
}
best wishes
michael
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Join Tables
Posted by Eigen Technology Pty Ltd <mi...@eigentechnology.com>.
hi,
could anyone point me to an document that gives instructions to join tables.
I read the documentation that came with TDK, it is a bit unclear ...
public Vector doSelectWithCategory (Criteria crit) throws Exception
{
crit.addJoin (ItemPeer.CATEGORY_ID, CategoryPeer.CATEGORY_ID);
addSelectColumns ( criteria );
CategoryPeer.addSelectColumns ( criteria )
// BasePeer returns a Vector of Value (Village) arrays. The array
// order follows the order columns were placed in the Select clause.
Vector rows = BasePeer.doSelect(criteria);
Vector results = new Vector();
// populate the object(s)
for ( int i=0; i<rows.size(); i++ )
{
Record row = (Record)rows.elementAt(i);
MyItem itm = row2Object (row,
1,
Class.forName
("com.mycompany.om.MyItem"))
MyCategory cat = CategoryPeer.row2Object
(row,
numColumns+1,
Class.forName
("com.mycompany.om.MyCategory"))
itm.setCategory (cat);
results.add (itm);
}
return results;
}
best wishes
michael
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
AW: AW: AW: adding Javascript
Posted by Marc Lustig <ma...@marclustig.com>.
> -----Ursprüngliche Nachricht-----
> Von: Scott Eade [mailto:seade@backstagetech.com.au]
> Gesendet: Samstag, 14. Dezember 2002 07:58
> An: turbine-user
> Betreff: Re: AW: AW: adding Javascript
>
>
> You might not even need the class, I think most if not all of the methods
> that are added are now in the standard TemplatePageAttributes (although I
> haven't specifically checked).
You are right. It has been implemented meanwhile. No extension of
TemplatePageAttributes needed anymore.
Marc
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: AW: AW: adding Javascript
Posted by Scott Eade <se...@backstagetech.com.au>.
You might not even need the class, I think most if not all of the methods
that are added are now in the standard TemplatePageAttributes (although I
haven't specifically checked).
Cheers,
Scott
--
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
.Mac Chat/AIM: seade at mac dot com
> From: "Marc Lustig" <ma...@marclustig.com>
> Reply-To: "Turbine Users List" <tu...@jakarta.apache.org>
> Date: Sat, 14 Dec 2002 03:07:09 +0100
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Subject: AW: AW: adding Javascript
>
> Michael,
>
> I use
>
> $page.setScript("JavaScript",
> "text/javascript",$content.getURI("resources/global.js"))
>
> and this class:
>
> package de.geoconnect.audiotex.turbineext;
>
> import org.apache.turbine.util.template.TemplatePageAttributes;
> import org.apache.turbine.util.RunData;
> import org.apache.ecs.html.Script;
> import org.apache.ecs.html.Link;
> import org.apache.ecs.html.Style;
>
> public class ExtTemplatePageAttributes extends TemplatePageAttributes {
> private RunData data = null;
>
> /**
> * Default constructor. The init method must be called before use
> */
> public ExtTemplatePageAttributes()
> {
> super();
> }
>
> /**
> * Construct a new instance with the given RunData object.
> *
> * @param data a RunData instance
> */
> public ExtTemplatePageAttributes(RunData data)
> {
> super(data);
> this.data = data;
> }
>
> /**
> * Initialise this instance with the given RunData object.
> * (ApplicationTool method)
> *
> * @param data Assumed to be a RunData instance
> */
> public void init(Object data)
> {
> super.init(data);
>
> // we blithely cast to RunData as the runtime error thrown
> // if data is null or not RunData is appropriate.
> this.data = (RunData)data;
> }
>
> /**
> * Refresh method - does nothing
> */
> public void refresh()
> {
> // empty
> }
>
> /**
> * Adds a LINK to a javascript file to the HEAD of the page.
> *
> * @param url A String.
> * @return A TemplatePageAttributesEx (self).
> */
> public TemplatePageAttributes setScript(String url)
> {
> data.getPage().getHead().addElement(new Script().setSrc(url)
> .setType("text/javascript").setLanguage("JavaScript"));
> return this;
> }
> public TemplatePageAttributes setScript(String lang, String type, String
> url)
> {
> data.getPage().getHead().addElement(new Script()
> .setLanguage(lang).setType(type).setSrc(url));
> return this;
> }
> /**
> * Adds a LINK to a CSS stylesheet to the HEAD of the page, allowing the
> * media type to be specified.
> *
> * @param url The value for the <code>href</code> attribute.
> * @param media The value for the <code>media</code> attribute.
> * @return a <code>TemplatePageAttributes</code> (self).
> */
> public TemplatePageAttributes setStyleSheet(String url, String media)
> {
> data.getPage().getHead().addElement(new Link().setRel("stylesheet")
> .setType("text/css").setMedia(media).setHref(url));
> return this;
> }
>
> // /**
> // * Adds a STYLE element to the HEAD of the page.
> // *
> // * @param styleText The content of the style element.
> // * @param media The value for the <code>media</code> attribute.
> // * @return a <code>TemplatePageAttributes</code> (self).
> // */
> // public TemplatePageAttributes setStyleElement(String styleText, String
> media)
> // {
> // Style style = new Style("text/css", styleText);
> // style.setMedia(media);
> // data.getPage().getHead().addElement(style);
> // return this;
> // }
>
> /**
> * Adds a STYLE element to the HEAD of the page with the provided
> content.
> *
> * @param styleText The contents of the <code>style</code> tag.
> * @return a <code>TemplatePageAttributes</code> (self).
> */
> public TemplatePageAttributes setStyle(String styleText)
> {
> data.getPage().getHead().addElement(new Style("text/css",
> styleText));
> return this;
> }
>
> }
>
>
> You have to register the class in your TR.props.
>
> Marc
>
>
>
>
>> -----Ursprüngliche Nachricht-----
>> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
>> Gesendet: Samstag, 14. Dezember 2002 01:20
>> An: turbine-user@jakarta.apache.org
>> Betreff: Re: AW: adding Javascript
>>
>>
>> The discussion in the link below does not seem to be conclusive. Is there
>> any other solution to Javascript used in conjunction with Velocity?
>>
>> cheers
>> michael
>>
>>
>>
>>
>>
>>> Hi,
>>> it is described in the list archive.
>>> Start here for example:
>>>
>> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg07518.html
>>>
>>> Marc
>>>
>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
>>>> Gesendet: Freitag, 13. Dezember 2002 14:30
>>>> An: turbine-user@jakarta.apache.org
>>>> Betreff: adding Javascript
>>>>
>>>>
>>>> Dear All,
>>>>
>>>> If a javascript is to be added to my Turbine application, where can I
>>>> find the <head> </head> pair in the setup so that I can achieve what I
>>>> intend to do?
>>>>
>>>> cheers
>>>> michael
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> To unsubscribe, e-mail:
>>>> <ma...@jakarta.apache.org>
>>>> For additional commands, e-mail:
>>>> <ma...@jakarta.apache.org>
>>>>
>>>
>>>
>>> --
>>> To unsubscribe, e-mail:
>>> <ma...@jakarta.apache.org> For additional
>>> commands, e-mail: <ma...@jakarta.apache.org>
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
AW: AW: adding Javascript
Posted by Marc Lustig <ma...@marclustig.com>.
Michael,
I use
$page.setScript("JavaScript",
"text/javascript",$content.getURI("resources/global.js"))
and this class:
package de.geoconnect.audiotex.turbineext;
import org.apache.turbine.util.template.TemplatePageAttributes;
import org.apache.turbine.util.RunData;
import org.apache.ecs.html.Script;
import org.apache.ecs.html.Link;
import org.apache.ecs.html.Style;
public class ExtTemplatePageAttributes extends TemplatePageAttributes {
private RunData data = null;
/**
* Default constructor. The init method must be called before use
*/
public ExtTemplatePageAttributes()
{
super();
}
/**
* Construct a new instance with the given RunData object.
*
* @param data a RunData instance
*/
public ExtTemplatePageAttributes(RunData data)
{
super(data);
this.data = data;
}
/**
* Initialise this instance with the given RunData object.
* (ApplicationTool method)
*
* @param data Assumed to be a RunData instance
*/
public void init(Object data)
{
super.init(data);
// we blithely cast to RunData as the runtime error thrown
// if data is null or not RunData is appropriate.
this.data = (RunData)data;
}
/**
* Refresh method - does nothing
*/
public void refresh()
{
// empty
}
/**
* Adds a LINK to a javascript file to the HEAD of the page.
*
* @param url A String.
* @return A TemplatePageAttributesEx (self).
*/
public TemplatePageAttributes setScript(String url)
{
data.getPage().getHead().addElement(new Script().setSrc(url)
.setType("text/javascript").setLanguage("JavaScript"));
return this;
}
public TemplatePageAttributes setScript(String lang, String type, String
url)
{
data.getPage().getHead().addElement(new Script()
.setLanguage(lang).setType(type).setSrc(url));
return this;
}
/**
* Adds a LINK to a CSS stylesheet to the HEAD of the page, allowing the
* media type to be specified.
*
* @param url The value for the <code>href</code> attribute.
* @param media The value for the <code>media</code> attribute.
* @return a <code>TemplatePageAttributes</code> (self).
*/
public TemplatePageAttributes setStyleSheet(String url, String media)
{
data.getPage().getHead().addElement(new Link().setRel("stylesheet")
.setType("text/css").setMedia(media).setHref(url));
return this;
}
// /**
// * Adds a STYLE element to the HEAD of the page.
// *
// * @param styleText The content of the style element.
// * @param media The value for the <code>media</code> attribute.
// * @return a <code>TemplatePageAttributes</code> (self).
// */
// public TemplatePageAttributes setStyleElement(String styleText, String
media)
// {
// Style style = new Style("text/css", styleText);
// style.setMedia(media);
// data.getPage().getHead().addElement(style);
// return this;
// }
/**
* Adds a STYLE element to the HEAD of the page with the provided
content.
*
* @param styleText The contents of the <code>style</code> tag.
* @return a <code>TemplatePageAttributes</code> (self).
*/
public TemplatePageAttributes setStyle(String styleText)
{
data.getPage().getHead().addElement(new Style("text/css",
styleText));
return this;
}
}
You have to register the class in your TR.props.
Marc
> -----Ursprüngliche Nachricht-----
> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
> Gesendet: Samstag, 14. Dezember 2002 01:20
> An: turbine-user@jakarta.apache.org
> Betreff: Re: AW: adding Javascript
>
>
> The discussion in the link below does not seem to be conclusive. Is there
> any other solution to Javascript used in conjunction with Velocity?
>
> cheers
> michael
>
>
>
>
>
> > Hi,
> > it is described in the list archive.
> > Start here for example:
> >
> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg07518.html
> >
> > Marc
> >
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
> >> Gesendet: Freitag, 13. Dezember 2002 14:30
> >> An: turbine-user@jakarta.apache.org
> >> Betreff: adding Javascript
> >>
> >>
> >> Dear All,
> >>
> >> If a javascript is to be added to my Turbine application, where can I
> >> find the <head> </head> pair in the setup so that I can achieve what I
> >> intend to do?
> >>
> >> cheers
> >> michael
> >>
> >>
> >>
> >>
> >> --
> >> To unsubscribe, e-mail:
> >> <ma...@jakarta.apache.org>
> >> For additional commands, e-mail:
> >> <ma...@jakarta.apache.org>
> >>
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org> For additional
> > commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: AW: adding Javascript
Posted by michael shek sia lim <mi...@eigentechnology.com>.
The discussion in the link below does not seem to be conclusive. Is there
any other solution to Javascript used in conjunction with Velocity?
cheers
michael
> Hi,
> it is described in the list archive.
> Start here for example:
> http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg07518.html
>
> Marc
>
>
>> -----Ursprüngliche Nachricht-----
>> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
>> Gesendet: Freitag, 13. Dezember 2002 14:30
>> An: turbine-user@jakarta.apache.org
>> Betreff: adding Javascript
>>
>>
>> Dear All,
>>
>> If a javascript is to be added to my Turbine application, where can I
>> find the <head> </head> pair in the setup so that I can achieve what I
>> intend to do?
>>
>> cheers
>> michael
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@jakarta.apache.org>
>>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org> For additional
> commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: adding Javascript
Posted by michael shek sia lim <mi...@eigentechnology.com>.
Also, would appreciate if anyone knows howto pass info between .vm when using
<SELECT>
<OPTION ...>
</SELECT>
type of tricks.
thanks
michael
> Dear All,
>
> If a javascript is to be added to my Turbine application, where can I
> find the <head> </head> pair in the setup so that I can achieve what I
> intend to do?
>
> cheers
> michael
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org> For additional
> commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
AW: adding Javascript
Posted by Marc Lustig <ma...@marclustig.com>.
Hi,
it is described in the list archive.
Start here for example:
http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg07518.html
Marc
> -----Ursprüngliche Nachricht-----
> Von: michael shek sia lim [mailto:michael@eigentechnology.com]
> Gesendet: Freitag, 13. Dezember 2002 14:30
> An: turbine-user@jakarta.apache.org
> Betreff: adding Javascript
>
>
> Dear All,
>
> If a javascript is to be added to my Turbine application, where can I find
> the <head> </head> pair in the setup so that I can achieve what I intend
> to do?
>
> cheers
> michael
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>