You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by John Smith <se...@hotmail.com> on 2005/12/30 21:19:18 UTC
How to inject visit object into pojo
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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to inject visit object into pojo
Posted by John Smith <se...@hotmail.com>.
Dmitry, I can't find any information on ApplicationStateObjectProvider. Can
you send me an example?
----Original Message Follows----
From: Dmitry Gusev <dm...@gmail.com>
Reply-To: "Tapestry users" <ta...@jakarta.apache.org>
To: Tapestry users <ta...@jakarta.apache.org>
Subject: Re: How to inject visit object into pojo
Date: Sat, 31 Dec 2005 11:20:20 +0300
MIME-Version: 1.0
Received: from mail.apache.org ([209.237.227.199]) by
bay0-mc3-f6.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Sat, 31
Dec 2005 00:20:54 -0800
Received: (qmail 78084 invoked by uid 500); 31 Dec 2005 08:20:42 -0000
Received: (qmail 78073 invoked by uid 99); 31 Dec 2005 08:20:42 -0000
Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by
apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Dec 2005 00:20:42 -0800
Received: pass (asf.osuosl.org: domain of dmitry.gusev@gmail.com designates
64.233.162.198 as permitted sender)
Received: from [64.233.162.198] (HELO zproxy.gmail.com) (64.233.162.198)
by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Dec 2005 00:20:41 -0800
Received: by zproxy.gmail.com with SMTP id 8so2178855nzo for
<ta...@jakarta.apache.org>; Sat, 31 Dec 2005 00:20:20 -0800 (PST)
Received: by 10.36.5.14 with SMTP id 14mr5201769nze; Sat, 31 Dec 2005
00:20:20 -0800 (PST)
Received: by 10.36.159.1 with HTTP; Sat, 31 Dec 2005 00:20:20 -0800 (PST)
X-Message-Info: JGTYoYF78jG5ESbspB0TNKldSSYB6G2AHSTmeeZnuI0=
Mailing-List: contact tapestry-user-help@jakarta.apache.org; run by ezmlm
Precedence: bulk
List-Unsubscribe: <ma...@jakarta.apache.org>
List-Help: <ma...@jakarta.apache.org>
List-Post: <ma...@jakarta.apache.org>
List-Id: "Tapestry users" <tapestry-user.jakarta.apache.org>
Delivered-To: mailing list tapestry-user@jakarta.apache.org
X-ASF-Spam-Status: No, hits=0.0 required=10.0tests=HTML_MESSAGE,SPF_PASS
X-Spam-Check-By: apache.org
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com;
h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references;
b=BZ/h9+/u+cSNsukAjUEiVWqbyNcziIU+4PnrWZTrlvVdIBx9O9gCVTnfKRU86T9GFNxJ0Gi8/+amcpW39eA7RxjzyULeOXRqFUYl/TcZB4No8QvBoM38h0g12veh2zRl5ISD5v+9hpmkAkx+mgyvlquZbKcXqgFsj39tNAN5jtc=
References: <BA...@phx.gbl>
X-Virus-Checked: Checked by ClamAV on apache.org
Return-Path:
tapestry-user-return-30503-semerau=hotmail.com@jakarta.apache.org
X-OriginalArrivalTime: 31 Dec 2005 08:20:54.0260 (UTC)
FILETIME=[1E3BA340:01C60DE3]
You may create ApplicationStateObjectProvider to set the Visit object as a
property of a pojo via hivemind.
2005/12/30, John Smith <se...@hotmail.com>:
>
> 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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to inject visit object into pojo
Posted by Dmitry Gusev <dm...@gmail.com>.
You may create ApplicationStateObjectProvider to set the Visit object as a
property of a pojo via hivemind.
2005/12/30, John Smith <se...@hotmail.com>:
>
> 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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
Re: How to inject visit object into pojo
Posted by John Smith <se...@hotmail.com>.
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 <nw...@nwrk.dyndns.org>
Reply-To: "Tapestry users" <ta...@jakarta.apache.org>
To: Tapestry users <ta...@jakarta.apache.org>
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
tapestry-user@jakarta.apache.org; 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 tapestry-user-help@jakarta.apache.org; run by ezmlm
Precedence: bulk
List-Unsubscribe: <ma...@jakarta.apache.org>
List-Help: <ma...@jakarta.apache.org>
List-Post: <ma...@jakarta.apache.org>
List-Id: "Tapestry users" <tapestry-user.jakarta.apache.org>
Delivered-To: mailing list tapestry-user@jakarta.apache.org
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: <BA...@phx.gbl>
X-Mailer: Evolution 2.4.1
X-Virus-Checked: Checked by ClamAV on apache.org
Return-Path:
tapestry-user-return-30515-semerau=hotmail.com@jakarta.apache.org
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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to inject visit object into pojo
Posted by Mikaël Cluseau <nw...@nwrk.dyndns.org>.
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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to inject visit object into pojo
Posted by Raul Raja Martinez <do...@estudiowebs.com>.
There is a post in this list about injecting hivemind services into
pojos using hiveutils. The post title is "Injecting registry services to
POJOS" and "PROBLEM SOLVED | Re: Injecting registry services to POJOS".
Best Regards.
Raul Raja
John Smith wrote:
> 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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org