You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "August, Terry" <Te...@Honeywell.com> on 2001/03/13 21:15:23 UTC

Selecting field after joining table

How do you access fields of two different peer classes once you have joined
two tables?  I have some code similar to the following:

under doBuildTemplate:

            criteria = new Criteria();
            int document_id = data.getParameters().getInt("documentid");
            criteria.add(DocumentPeer.DOCUMENT_ID, document_id);
            criteria.add(DocumentPeer.CATEGORY_ID, category_id);
            criteria.addJoin(DocurlPeer.DOCUMENT_ID,
DocumentPeer.DOCUMENT_ID);
            Object obj = DocumentPeer.doSelect(criteria).elementAt(0);
            Document doc = (Document)obj;
            context.put("document", doc);

in Velocity Screen:

        #formRow ("Link Title:" "documentname"
"$document.getDocumentName()")
        #formRow ("Link URL:" "docurlname" "***")

at the ***, I'd like to show something similar to $docurl.getDocurlName() if
I actually had a Docurl object.  However I do not.  I have a Document object
that cannot contain all of the data produced by the join.  Please help me
resolve this dilemma.  Thank you.

Terry

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Selecting field after joining table

Posted by Sean Legassick <se...@informage.net>.
In message 
<E9...@mtoex140.mto.allied.com>, 
"August, Terry" <Te...@Honeywell.com> writes
>at the ***, I'd like to show something similar to $docurl.getDocurlName() if
>I actually had a Docurl object.  However I do not.  I have a Document object
>that cannot contain all of the data produced by the join.  Please help me
>resolve this dilemma.  Thank you.

If you generate your Peer objects with objectModelType=complex then you 
should have a getDocurl() method in your Document class (or rather in 
the BaseDocument class from which Document is derived). This way you 
don't even need to specify the join in the criteria, all that is done 
for you...

-- 
Sean Legassick
sean@informage.net

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Selecting field after joining table

Posted by John McNally <jm...@collab.net>.
It's pretty hard to answer your question without more detail, but I
would either use a torque generated method or add one of my own to
Document and then in the template

$document.Docurl


John McNally

"August, Terry" wrote:
> 
> How do you access fields of two different peer classes once you have joined
> two tables?  I have some code similar to the following:
> 
> under doBuildTemplate:
> 
>             criteria = new Criteria();
>             int document_id = data.getParameters().getInt("documentid");
>             criteria.add(DocumentPeer.DOCUMENT_ID, document_id);
>             criteria.add(DocumentPeer.CATEGORY_ID, category_id);
>             criteria.addJoin(DocurlPeer.DOCUMENT_ID,
> DocumentPeer.DOCUMENT_ID);
>             Object obj = DocumentPeer.doSelect(criteria).elementAt(0);
>             Document doc = (Document)obj;
>             context.put("document", doc);
> 
> in Velocity Screen:
> 
>         #formRow ("Link Title:" "documentname"
> "$document.getDocumentName()")
>         #formRow ("Link URL:" "docurlname" "***")
> 
> at the ***, I'd like to show something similar to $docurl.getDocurlName() if
> I actually had a Docurl object.  However I do not.  I have a Document object
> that cannot contain all of the data produced by the join.  Please help me
> resolve this dilemma.  Thank you.
> 
> Terry
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org