This is exactly what I needed. Thank you.
I just added get and set methods for the ApplicationStateManager to my DAO
interface like this:
public void setApplicationStateManager(ApplicationStateManager manager);
public ApplicationStateManager getApplicationStateManager();
Then in my DAO implementation class I just get the visit object using:
Visit visit = (Visit)appStateManager.get("visit");
and Hivemind just autowired it no problem. I suppose I could have injected
it other ways too, but this works just fine. Thanks.
----Original Message Follows----
From: Mikaël Cluseau <[EMAIL PROTECTED]>
Reply-To: "Tapestry users" <[email protected]>
To: Tapestry users <[email protected]>
Subject: Re: How to inject visit object into pojo
Date: Sun, 01 Jan 2006 19:18:37 +0100
MIME-Version: 1.0
Received: from mail.apache.org ([209.237.227.199]) by
bay0-mc2-f11.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Sun, 1
Jan 2006 10:19:12 -0800
Received: (qmail 74884 invoked by uid 500); 1 Jan 2006 18:19:08 -0000
Received: (qmail 74866 invoked by uid 99); 1 Jan 2006 18:19:08 -0000
Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by
apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Jan 2006 10:19:08 -0800
Received: neutral (asf.osuosl.org: local policy)
Received: from [212.247.154.204] (HELO swip.net) (212.247.154.204) by
apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Jan 2006 10:19:07 -0800
Received: from nwrk.dyndns.org ([83.179.138.221] verified) by
mailfe07.swip.net (CommuniGate Pro SMTP 5.0.2) with ESMTP id 68204212 for
[email protected]; Sun, 01 Jan 2006 19:18:43 +0100
Received: by nwrk.dyndns.org (Postfix, from userid 1002)id D3C422C0950; Sun,
1 Jan 2006 19:18:39 +0100 (CET)
X-Message-Info: JGTYoYF78jEHjJx36Oi8+Z3TmmkSEdPtfpLB7P/ybN8=
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:[EMAIL PROTECTED]>
List-Help: <mailto:[EMAIL PROTECTED]>
List-Post: <mailto:[email protected]>
List-Id: "Tapestry users" <tapestry-user.jakarta.apache.org>
Delivered-To: mailing list [email protected]
X-ASF-Spam-Status: No, hits=0.0 required=10.0tests=
X-Spam-Check-By: apache.org
X-T2-Posting-ID: idJlPVtVmv7YZVNaIuydT4dsY2HV8u+7xk70IW54owk=
X-Cloudmark-Score: 0.000000 []
References: <[EMAIL PROTECTED]>
X-Mailer: Evolution 2.4.1
X-Virus-Checked: Checked by ClamAV on apache.org
Return-Path:
[EMAIL PROTECTED]
X-OriginalArrivalTime: 01 Jan 2006 18:19:12.0249 (UTC)
FILETIME=[DD83CE90:01C60EFF]
It's not that easy because injection works with Tapestry-handled object
(via annotation or specification).
You need your "visit" state object, and to access a state objet you must
have an access to the "tapestry.state.ApplicationStateManager" service
point. I see to solutions:
1. The simplest: pass your user as a parameter to your "create"
function, or to some kind of «prepareForCommit».
2. My prefered: use HiveMind to provide a DAO that will take the
responsibility of setting the user on the created objet. You'll
have to inject the tapestry.state.ApplicationStateManager
service to this DAO in your hivemodule.xml.
Hivedoc:
http://jakarta.apache.org/tapestry/tapestry/hivedocs/service/tapestry.state.ApplicationStateManager.html
Interface:
http://jakarta.apache.org/tapestry/tapestry/apidocs/org/apache/tapestry/engine/state/ApplicationStateManager.html
Hope this helps.
Le vendredi 30 décembre 2005 à 13:19 -0700, John Smith a écrit :
> I apologize for just mooching help off this list, but I haven't been able
to
> figure this out other places.
>
> For my database layer, I want to always write in the database the
username
> of the user that is changing the record. So if I create a new record, I
want
> to write who created it (created_by).
>
> The db code I have is several layers removed from tapestry, but the db
code
> is managed by hivemind.
>
> I want to inject the Visit object into the db code and then use the Visit
> object to get the username and write that into the "created_by" field of
the
> db table.
>
> Tapestry pages can easily just inject application state objects into
pages,
> but this is not a page. But I am betting that it is not that hard, if I
only
> knew how to do it.
>
> thanks
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]