You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kevin Fightmaster <kf...@gmail.com> on 2006/03/28 17:34:45 UTC
Resetting state of Injected Objects
Problem:
When I submit a form which persists a new object to the database and I
return back to the form to create a new object but the old object values are
still there. I'm using @InjectObject in my code and I'm not sure how to tell
the class to reset the value.
Artifacts:
[PAGE CLASS]
public abstract class AddPerson extends PersonPersistenceAbstract {
...
@InjectObject("spring:Person")
public abstract Person getPerson();
...
public void detach() {
if (log.isDebugEnabled())
log.debug("Page Detaching");
super.detach();
}
}
[PAGE SPECIFICATION]
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification class="
org.fightmaster.person.presentation.page.AddPerson">
<inject property="listPerson" type="page" object="ListPerson"/>
<component id="personForm" type="Form">
<binding name="listener" value="listener:onSubmit"/>
</component>
<component id="firstname" type="TextField">
<binding name="value" value="ognl:person.firstname"/>
</component>
<component id="middlename" type="TextField">
<binding name="value" value="ognl:person.middlename"/>
</component>
<component id="lastname" type="TextField">
<binding name="value" value="ognl:person.lastname"/>
</component>
</page-specification>
[SPRING BEAN XML]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="Person.Hibernate.Annotation.SessionFactory" class="
org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configurationClass" value="
org.hibernate.cfg.AnnotationConfiguration"/>
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
</bean>
...
<bean id="Person" class="
org.fightmaster.person.business.hibernate.PersonImpl" singleton="false">
...
</bean>
...
</beans>
Specs:
Tapestry 4
Hibernate 3
Spring 1.1
Java 1.5
Tomcat 5.5
Summary:
The setup works as far as persistence goes. My objects are persisted to the
database. My issue has to do with session and why I can't get my Person
object to reset for the next request. Thanks for any guidance.
Kevin
RE: Resetting state of Injected Objects
Posted by James Carman <ja...@carmanconsulting.com>.
I have integrated the Spring classes into a HiveMind module. You can
download the jars inside an example (via SVN) application at
www.carmanconsulting.com/svn/public/tapernate-example/trunk
All the jars you need are in there. It should build using JD5 and Ant 1.6+.
The source code is available in the hivemind JavaForge project.
-----Original Message-----
From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com]
Sent: Tuesday, March 28, 2006 3:36 PM
To: Tapestry users; amirsguard-tapestry@yahoo.com; Kevin Fightmaster
Subject: Re: Resetting state of Injected Objects
Opps I did'nt read Howars blog, I guess he did update the spring-tapestry
bridge to correct this; read the blog http://howardlewisship.com/blog/
But this issue still remains, if you inject a HttpRequest you would still
have
the same problem.
--- amirsguard-tapestry@yahoo.com wrote:
> I am not too sure on how to integerating hibernate and hivemind (or if
there
> is a need to), maybe someone else can comment on this.
>
> What I did is create my own InjectObjectWorker class with the fix, and
> packaged
> it with my source code (it's a hack, I'm hoping future releases would
solve
> it). The classloader will pick up the one with the source code, not the
one
> in
> the jar file (in effect it shadows the original).
>
>
> --- Kevin Fightmaster <kf...@gmail.com> wrote:
>
> > Probably lack of knowledge on how I would go about doing that ;-).
> >
> > On a more 'meta' note: I like using hibernate and haven't done enough
> > research on hivemind to know how easy it is to integrate the two. So I
need
> > Spring to act as my IoC and integration point with hibernate. I've tried
> > hard to maintain tier code that wasnt tightly integrated with other
tiers.
> > The code in this page class doesn't require any context but hivemind.
I'm
> > always open to more elegant solutions I just dont have enough
> > tapestry/hivemind knowledge yet to come up with it. If I could write a
> > wrapper to the InjectObjectWorker object and have that setup in a config
> > that may be a more elegant solution.
> >
> > Thanks for the dialog,
> > Kevin
> >
> >
> > On 3/28/06, amirsguard-tapestry@yahoo.com
<am...@yahoo.com>
> > wrote:
> > >
> > > Well if you are going that route why not just inject the spring
context
> > > and query it for your object directly?
> > >
> > > --- Kevin Fightmaster <kf...@gmail.com> wrote:
> > >
> > > > I'm glad other folks are having the same issues. And thanks for the
> > > > feedback.
> > > > I'm hesitant to modify Tapestry classes. Then I might have to worry
> > > about
> > > > unexpected impacts of changing the code and maintainability with
> > > updates.
> > > > The work around im using.. but don't like all that much is to use
the
> > > > @InjectObject method as just a template to get a handle to the right
> > > class.
> > > > Then creating a newInstance to work with on the page.
> > > >
> > > > @InjectObject("spring:Person")
> > > > public abstract Person getPersonTemplate();
> > > > public abstract Person getPerson();
> > > > public abstract void setPerson(Person person);
> > > >
> > > > public void pageBeginRender(PageEvent arg0) {
> > > > if (getPerson() == null) {
> > > > try {
> > > >
> setPerson(getPersonTemplate().getClass().newInstance());
> > > > } catch (InstantiationException e) {
> > > > ...
> > > > } catch (IllegalAccessException e) {
> > > > ... }
> > > > }
> > > > }
> > > > ....
> > > > public void detach() {
> > > > if (log.isDebugEnabled())
> > > > log.debug("Page Detaching");
> > > > setPerson(null);
> > > > super.detach();
> > > > }
> > > > I wouldnt call it the most elegant code and I hate having to
try/catch
> > > now.
> > > > Maybe a better alternative will come down the road.
> > > >
> > > >
> > > >
> > > > On 3/28/06, amirsguard-tapestry@yahoo.com
> <am...@yahoo.com>
> > > > wrote:
> > > > >
> > > > > This is a broder issue than spring, this has to do with the way
> > > > > InjectObjectWorker works. If there is any doubt just log the
enhanced
> > > > > class's source code and examine how the injected object is passed
to
> > > the
> > > > > object (or just examine the injectObject method).
> > > > >
> > > > > The same problem occurs with any injected object.
> > > > >
> > > > > --- Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > > > >
> > > > > > I would reccomend using Howard's spring stuff
> > > > > > http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
> > > > > >
> > > > > > On 3/28/06, amirsguard-tapestry@yahoo.com <
> > > amirsguard-tapestry@yahoo.com
> > > > > >
> > > > > > wrote:
> > > > > > >
> > > > > > > Kevin,
> > > > > > >
> > > > > > > I think this is a bug, I had the same problem.
> > > > > > >
> > > > > > > What is happening is that when the page is being enhanced
> > > (subclass
> > > > > > > created)
> > > > > > > the reference to the injected object (a spring object in your
> > > case) is
> > > > >
> > > > > > > passed
> > > > > > > through the constructor. Now since the page is pooled, the
next
> > > time a
> > > > > > > request
> > > > > > > is made the requested is serviced with this cached page along
> with
> > > the
> > > > >
> > > > > > > original
> > > > > > > (stale) injected object.
> > > > > > >
> > > > > > > I had to modify InjectObjectWorker class so that the reference
is
> > > not
> > > > > > > passed
> > > > > > > through the constructor but rather as a getter object that
looks
> > > up
> > > > > > > spring's
> > > > > > > application context every time. Take a look at this class's
> inject
> > > > > object
> > > > > > > method.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Amir
> > > > > > >
> > > > > > > --- Kevin Fightmaster < kfightmaster@gmail.com> wrote:
> > > > > > >
> > > > > > > > Problem:
> > > > > > > > When I submit a form which persists a new object to the
> > > database
> > > > > and
> > > > > > > I
> > > > > > > > return back to the form to create a new object but the old
> > > object
> > > > > values
> > > > > > > are
> > > > > > > > still there. I'm using @InjectObject in my code and I'm not
> sure
> > > how
> > > > > to
> > > > > > > tell
> > > > > > > > the class to reset the value.
> > > > > > > >
> > > > > > > > Artifacts:
> > > > > > > > [PAGE CLASS]
> > > > > > > > public abstract class AddPerson extends
> > > PersonPersistenceAbstract {
> > > > > > > > ...
> > > > > > > > @InjectObject("spring:Person")
> > > > > > > > public abstract Person getPerson();
> > > > > > > > ...
> > > > > > > > public void detach() {
> > > > > > > > if (log.isDebugEnabled ())
> > > > > > > > log.debug("Page Detaching");
> > > > > > > > super.detach();
> > > > > > > > }
> > > > > > > > }
> > > > > > > >
> > > > > > > > [PAGE SPECIFICATION]
> > > > > > > > <!DOCTYPE page-specification PUBLIC
> > > > > > > > "-//Apache Software Foundation//Tapestry Specification 4.0
> > > //EN"
> > > > > > > > "
http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> > > > > > > > <page-specification class="
> > > > > > > > org.fightmaster.person.presentation.page.AddPerson">
> > > > > > > > <inject property="listPerson" type="page"
> > > object="ListPerson"/>
> > > > > > > > <component id="personForm" type="Form">
> > > > > > > > <binding name="listener" value="listener:onSubmit"/>
> > > > > > > > </component>
> > > > > > > > <component id="firstname" type="TextField">
> > > > > > > > <binding name="value" value="ognl:person.firstname"/>
> > > > > > > > </component>
> > > > > > > > <component id="middlename" type="TextField">
> > > > > > > > <binding name="value" value="ognl:person.middlename"/>
> > > > > > > > </component>
> > > > > > > > <component id="lastname" type="TextField">
> > > > > > > > <binding name="value" value="ognl:person.lastname"/>
> > > > > > > > </component>
> > > > > > > > </page-specification>
> > > > > > > >
> > > > > > > > [SPRING BEAN XML]
> > > > > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > > > > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > > > > > > > " http://www.springframework.org/dtd/spring-beans.dtd">
> > > > > > > > <beans>
> > > > > > > > <bean id="Person.Hibernate.Annotation.SessionFactory"
class="
> > > > > > > >
> > > > > > >
> > > > >
> > >
> org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
> > > > > > > ">
> > > > > > > > <property name="configurationClass" value="
> > > > > > > > org.hibernate.cfg.AnnotationConfiguration "/>
> > > > > > > > <property name="configLocation" value="classpath:
> > > > > hibernate.cfg.xml
> > > > > > > "/>
> > > > > > > > </bean>
> > > > > > > > ...
> > > > > > > > <bean id="Person" class="
> > > > > > > > org.fightmaster.person.business.hibernate.PersonImpl "
> > > > > singleton="false">
> > > > > > > > ...
> > > > > > > > </bean>
> > > > > > > > ...
> > > > > > > > </beans>
> > > > > > > >
> > > > > > > > Specs:
> > > > > > > > Tapestry 4
> > > > > > > > Hibernate 3
> > > > > > > > Spring 1.1
> > > > > > > > Java 1.5
> > > > > > > > Tomcat 5.5
> > > > > > > >
> > > > > > > > Summary:
> > > > > > > > The setup works as far as persistence goes. My objects are
> > > persisted
> > > > > to
> > > > > > > the
> > > > > > > > database. My issue has to do with session and why I can't
get
> my
> > > > > Person
> > > > > > > > object to reset for the next request. Thanks for any
guidance.
> > > > > > > >
> > > > > > > >
> > > > > > > > Kevin
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail:
> > > tapestry-user-unsubscribe@jakarta.apache.org
> > > > > > > For additional commands, e-mail:
> > > tapestry-user-help@jakarta.apache.org
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Jesse Kuhnert
> > > > > > Tacos/Tapestry, team member/developer
> > > > > >
> > > > > > Open source based consulting work centered around
> > > > > > dojo/tapestry/tacos/hivemind. http://opennotion.com
> > > > > >
> > > > >
> > > > >
> > > > >
---------------------------------------------------------------------
> > > > > 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
>
>
---------------------------------------------------------------------
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: Resetting state of Injected Objects
Posted by am...@yahoo.com.
Opps I did'nt read Howars blog, I guess he did update the spring-tapestry
bridge to correct this; read the blog http://howardlewisship.com/blog/
But this issue still remains, if you inject a HttpRequest you would still have
the same problem.
--- amirsguard-tapestry@yahoo.com wrote:
> I am not too sure on how to integerating hibernate and hivemind (or if there
> is a need to), maybe someone else can comment on this.
>
> What I did is create my own InjectObjectWorker class with the fix, and
> packaged
> it with my source code (it's a hack, I'm hoping future releases would solve
> it). The classloader will pick up the one with the source code, not the one
> in
> the jar file (in effect it shadows the original).
>
>
> --- Kevin Fightmaster <kf...@gmail.com> wrote:
>
> > Probably lack of knowledge on how I would go about doing that ;-).
> >
> > On a more 'meta' note: I like using hibernate and haven't done enough
> > research on hivemind to know how easy it is to integrate the two. So I need
> > Spring to act as my IoC and integration point with hibernate. I've tried
> > hard to maintain tier code that wasnt tightly integrated with other tiers.
> > The code in this page class doesn't require any context but hivemind. I'm
> > always open to more elegant solutions I just dont have enough
> > tapestry/hivemind knowledge yet to come up with it. If I could write a
> > wrapper to the InjectObjectWorker object and have that setup in a config
> > that may be a more elegant solution.
> >
> > Thanks for the dialog,
> > Kevin
> >
> >
> > On 3/28/06, amirsguard-tapestry@yahoo.com <am...@yahoo.com>
> > wrote:
> > >
> > > Well if you are going that route why not just inject the spring context
> > > and query it for your object directly?
> > >
> > > --- Kevin Fightmaster <kf...@gmail.com> wrote:
> > >
> > > > I'm glad other folks are having the same issues. And thanks for the
> > > > feedback.
> > > > I'm hesitant to modify Tapestry classes. Then I might have to worry
> > > about
> > > > unexpected impacts of changing the code and maintainability with
> > > updates.
> > > > The work around im using.. but don't like all that much is to use the
> > > > @InjectObject method as just a template to get a handle to the right
> > > class.
> > > > Then creating a newInstance to work with on the page.
> > > >
> > > > @InjectObject("spring:Person")
> > > > public abstract Person getPersonTemplate();
> > > > public abstract Person getPerson();
> > > > public abstract void setPerson(Person person);
> > > >
> > > > public void pageBeginRender(PageEvent arg0) {
> > > > if (getPerson() == null) {
> > > > try {
> > > >
> setPerson(getPersonTemplate().getClass().newInstance());
> > > > } catch (InstantiationException e) {
> > > > ...
> > > > } catch (IllegalAccessException e) {
> > > > ... }
> > > > }
> > > > }
> > > > ....
> > > > public void detach() {
> > > > if (log.isDebugEnabled())
> > > > log.debug("Page Detaching");
> > > > setPerson(null);
> > > > super.detach();
> > > > }
> > > > I wouldnt call it the most elegant code and I hate having to try/catch
> > > now.
> > > > Maybe a better alternative will come down the road.
> > > >
> > > >
> > > >
> > > > On 3/28/06, amirsguard-tapestry@yahoo.com
> <am...@yahoo.com>
> > > > wrote:
> > > > >
> > > > > This is a broder issue than spring, this has to do with the way
> > > > > InjectObjectWorker works. If there is any doubt just log the enhanced
> > > > > class's source code and examine how the injected object is passed to
> > > the
> > > > > object (or just examine the injectObject method).
> > > > >
> > > > > The same problem occurs with any injected object.
> > > > >
> > > > > --- Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > > > >
> > > > > > I would reccomend using Howard's spring stuff
> > > > > > http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
> > > > > >
> > > > > > On 3/28/06, amirsguard-tapestry@yahoo.com <
> > > amirsguard-tapestry@yahoo.com
> > > > > >
> > > > > > wrote:
> > > > > > >
> > > > > > > Kevin,
> > > > > > >
> > > > > > > I think this is a bug, I had the same problem.
> > > > > > >
> > > > > > > What is happening is that when the page is being enhanced
> > > (subclass
> > > > > > > created)
> > > > > > > the reference to the injected object (a spring object in your
> > > case) is
> > > > >
> > > > > > > passed
> > > > > > > through the constructor. Now since the page is pooled, the next
> > > time a
> > > > > > > request
> > > > > > > is made the requested is serviced with this cached page along
> with
> > > the
> > > > >
> > > > > > > original
> > > > > > > (stale) injected object.
> > > > > > >
> > > > > > > I had to modify InjectObjectWorker class so that the reference is
> > > not
> > > > > > > passed
> > > > > > > through the constructor but rather as a getter object that looks
> > > up
> > > > > > > spring's
> > > > > > > application context every time. Take a look at this class's
> inject
> > > > > object
> > > > > > > method.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Amir
> > > > > > >
> > > > > > > --- Kevin Fightmaster < kfightmaster@gmail.com> wrote:
> > > > > > >
> > > > > > > > Problem:
> > > > > > > > When I submit a form which persists a new object to the
> > > database
> > > > > and
> > > > > > > I
> > > > > > > > return back to the form to create a new object but the old
> > > object
> > > > > values
> > > > > > > are
> > > > > > > > still there. I'm using @InjectObject in my code and I'm not
> sure
> > > how
> > > > > to
> > > > > > > tell
> > > > > > > > the class to reset the value.
> > > > > > > >
> > > > > > > > Artifacts:
> > > > > > > > [PAGE CLASS]
> > > > > > > > public abstract class AddPerson extends
> > > PersonPersistenceAbstract {
> > > > > > > > ...
> > > > > > > > @InjectObject("spring:Person")
> > > > > > > > public abstract Person getPerson();
> > > > > > > > ...
> > > > > > > > public void detach() {
> > > > > > > > if (log.isDebugEnabled ())
> > > > > > > > log.debug("Page Detaching");
> > > > > > > > super.detach();
> > > > > > > > }
> > > > > > > > }
> > > > > > > >
> > > > > > > > [PAGE SPECIFICATION]
> > > > > > > > <!DOCTYPE page-specification PUBLIC
> > > > > > > > "-//Apache Software Foundation//Tapestry Specification 4.0
> > > //EN"
> > > > > > > > " http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> > > > > > > > <page-specification class="
> > > > > > > > org.fightmaster.person.presentation.page.AddPerson">
> > > > > > > > <inject property="listPerson" type="page"
> > > object="ListPerson"/>
> > > > > > > > <component id="personForm" type="Form">
> > > > > > > > <binding name="listener" value="listener:onSubmit"/>
> > > > > > > > </component>
> > > > > > > > <component id="firstname" type="TextField">
> > > > > > > > <binding name="value" value="ognl:person.firstname"/>
> > > > > > > > </component>
> > > > > > > > <component id="middlename" type="TextField">
> > > > > > > > <binding name="value" value="ognl:person.middlename"/>
> > > > > > > > </component>
> > > > > > > > <component id="lastname" type="TextField">
> > > > > > > > <binding name="value" value="ognl:person.lastname"/>
> > > > > > > > </component>
> > > > > > > > </page-specification>
> > > > > > > >
> > > > > > > > [SPRING BEAN XML]
> > > > > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > > > > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > > > > > > > " http://www.springframework.org/dtd/spring-beans.dtd">
> > > > > > > > <beans>
> > > > > > > > <bean id="Person.Hibernate.Annotation.SessionFactory" class="
> > > > > > > >
> > > > > > >
> > > > >
> > >
> org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
> > > > > > > ">
> > > > > > > > <property name="configurationClass" value="
> > > > > > > > org.hibernate.cfg.AnnotationConfiguration "/>
> > > > > > > > <property name="configLocation" value="classpath:
> > > > > hibernate.cfg.xml
> > > > > > > "/>
> > > > > > > > </bean>
> > > > > > > > ...
> > > > > > > > <bean id="Person" class="
> > > > > > > > org.fightmaster.person.business.hibernate.PersonImpl "
> > > > > singleton="false">
> > > > > > > > ...
> > > > > > > > </bean>
> > > > > > > > ...
> > > > > > > > </beans>
> > > > > > > >
> > > > > > > > Specs:
> > > > > > > > Tapestry 4
> > > > > > > > Hibernate 3
> > > > > > > > Spring 1.1
> > > > > > > > Java 1.5
> > > > > > > > Tomcat 5.5
> > > > > > > >
> > > > > > > > Summary:
> > > > > > > > The setup works as far as persistence goes. My objects are
> > > persisted
> > > > > to
> > > > > > > the
> > > > > > > > database. My issue has to do with session and why I can't get
> my
> > > > > Person
> > > > > > > > object to reset for the next request. Thanks for any guidance.
> > > > > > > >
> > > > > > > >
> > > > > > > > Kevin
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail:
> > > tapestry-user-unsubscribe@jakarta.apache.org
> > > > > > > For additional commands, e-mail:
> > > tapestry-user-help@jakarta.apache.org
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Jesse Kuhnert
> > > > > > Tacos/Tapestry, team member/developer
> > > > > >
> > > > > > Open source based consulting work centered around
> > > > > > dojo/tapestry/tacos/hivemind. http://opennotion.com
> > > > > >
> > > > >
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Resetting state of Injected Objects
Posted by am...@yahoo.com.
I am not too sure on how to integerating hibernate and hivemind (or if there
is a need to), maybe someone else can comment on this.
What I did is create my own InjectObjectWorker class with the fix, and packaged
it with my source code (it's a hack, I'm hoping future releases would solve
it). The classloader will pick up the one with the source code, not the one in
the jar file (in effect it shadows the original).
--- Kevin Fightmaster <kf...@gmail.com> wrote:
> Probably lack of knowledge on how I would go about doing that ;-).
>
> On a more 'meta' note: I like using hibernate and haven't done enough
> research on hivemind to know how easy it is to integrate the two. So I need
> Spring to act as my IoC and integration point with hibernate. I've tried
> hard to maintain tier code that wasnt tightly integrated with other tiers.
> The code in this page class doesn't require any context but hivemind. I'm
> always open to more elegant solutions I just dont have enough
> tapestry/hivemind knowledge yet to come up with it. If I could write a
> wrapper to the InjectObjectWorker object and have that setup in a config
> that may be a more elegant solution.
>
> Thanks for the dialog,
> Kevin
>
>
> On 3/28/06, amirsguard-tapestry@yahoo.com <am...@yahoo.com>
> wrote:
> >
> > Well if you are going that route why not just inject the spring context
> > and query it for your object directly?
> >
> > --- Kevin Fightmaster <kf...@gmail.com> wrote:
> >
> > > I'm glad other folks are having the same issues. And thanks for the
> > > feedback.
> > > I'm hesitant to modify Tapestry classes. Then I might have to worry
> > about
> > > unexpected impacts of changing the code and maintainability with
> > updates.
> > > The work around im using.. but don't like all that much is to use the
> > > @InjectObject method as just a template to get a handle to the right
> > class.
> > > Then creating a newInstance to work with on the page.
> > >
> > > @InjectObject("spring:Person")
> > > public abstract Person getPersonTemplate();
> > > public abstract Person getPerson();
> > > public abstract void setPerson(Person person);
> > >
> > > public void pageBeginRender(PageEvent arg0) {
> > > if (getPerson() == null) {
> > > try {
> > > setPerson(getPersonTemplate().getClass().newInstance());
> > > } catch (InstantiationException e) {
> > > ...
> > > } catch (IllegalAccessException e) {
> > > ... }
> > > }
> > > }
> > > ....
> > > public void detach() {
> > > if (log.isDebugEnabled())
> > > log.debug("Page Detaching");
> > > setPerson(null);
> > > super.detach();
> > > }
> > > I wouldnt call it the most elegant code and I hate having to try/catch
> > now.
> > > Maybe a better alternative will come down the road.
> > >
> > >
> > >
> > > On 3/28/06, amirsguard-tapestry@yahoo.com <am...@yahoo.com>
> > > wrote:
> > > >
> > > > This is a broder issue than spring, this has to do with the way
> > > > InjectObjectWorker works. If there is any doubt just log the enhanced
> > > > class's source code and examine how the injected object is passed to
> > the
> > > > object (or just examine the injectObject method).
> > > >
> > > > The same problem occurs with any injected object.
> > > >
> > > > --- Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > > >
> > > > > I would reccomend using Howard's spring stuff
> > > > > http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
> > > > >
> > > > > On 3/28/06, amirsguard-tapestry@yahoo.com <
> > amirsguard-tapestry@yahoo.com
> > > > >
> > > > > wrote:
> > > > > >
> > > > > > Kevin,
> > > > > >
> > > > > > I think this is a bug, I had the same problem.
> > > > > >
> > > > > > What is happening is that when the page is being enhanced
> > (subclass
> > > > > > created)
> > > > > > the reference to the injected object (a spring object in your
> > case) is
> > > >
> > > > > > passed
> > > > > > through the constructor. Now since the page is pooled, the next
> > time a
> > > > > > request
> > > > > > is made the requested is serviced with this cached page along with
> > the
> > > >
> > > > > > original
> > > > > > (stale) injected object.
> > > > > >
> > > > > > I had to modify InjectObjectWorker class so that the reference is
> > not
> > > > > > passed
> > > > > > through the constructor but rather as a getter object that looks
> > up
> > > > > > spring's
> > > > > > application context every time. Take a look at this class's inject
> > > > object
> > > > > > method.
> > > > > >
> > > > > > Regards,
> > > > > > Amir
> > > > > >
> > > > > > --- Kevin Fightmaster < kfightmaster@gmail.com> wrote:
> > > > > >
> > > > > > > Problem:
> > > > > > > When I submit a form which persists a new object to the
> > database
> > > > and
> > > > > > I
> > > > > > > return back to the form to create a new object but the old
> > object
> > > > values
> > > > > > are
> > > > > > > still there. I'm using @InjectObject in my code and I'm not sure
> > how
> > > > to
> > > > > > tell
> > > > > > > the class to reset the value.
> > > > > > >
> > > > > > > Artifacts:
> > > > > > > [PAGE CLASS]
> > > > > > > public abstract class AddPerson extends
> > PersonPersistenceAbstract {
> > > > > > > ...
> > > > > > > @InjectObject("spring:Person")
> > > > > > > public abstract Person getPerson();
> > > > > > > ...
> > > > > > > public void detach() {
> > > > > > > if (log.isDebugEnabled ())
> > > > > > > log.debug("Page Detaching");
> > > > > > > super.detach();
> > > > > > > }
> > > > > > > }
> > > > > > >
> > > > > > > [PAGE SPECIFICATION]
> > > > > > > <!DOCTYPE page-specification PUBLIC
> > > > > > > "-//Apache Software Foundation//Tapestry Specification 4.0
> > //EN"
> > > > > > > " http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> > > > > > > <page-specification class="
> > > > > > > org.fightmaster.person.presentation.page.AddPerson">
> > > > > > > <inject property="listPerson" type="page"
> > object="ListPerson"/>
> > > > > > > <component id="personForm" type="Form">
> > > > > > > <binding name="listener" value="listener:onSubmit"/>
> > > > > > > </component>
> > > > > > > <component id="firstname" type="TextField">
> > > > > > > <binding name="value" value="ognl:person.firstname"/>
> > > > > > > </component>
> > > > > > > <component id="middlename" type="TextField">
> > > > > > > <binding name="value" value="ognl:person.middlename"/>
> > > > > > > </component>
> > > > > > > <component id="lastname" type="TextField">
> > > > > > > <binding name="value" value="ognl:person.lastname"/>
> > > > > > > </component>
> > > > > > > </page-specification>
> > > > > > >
> > > > > > > [SPRING BEAN XML]
> > > > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > > > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > > > > > > " http://www.springframework.org/dtd/spring-beans.dtd">
> > > > > > > <beans>
> > > > > > > <bean id="Person.Hibernate.Annotation.SessionFactory" class="
> > > > > > >
> > > > > >
> > > >
> > org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
> > > > > > ">
> > > > > > > <property name="configurationClass" value="
> > > > > > > org.hibernate.cfg.AnnotationConfiguration "/>
> > > > > > > <property name="configLocation" value="classpath:
> > > > hibernate.cfg.xml
> > > > > > "/>
> > > > > > > </bean>
> > > > > > > ...
> > > > > > > <bean id="Person" class="
> > > > > > > org.fightmaster.person.business.hibernate.PersonImpl "
> > > > singleton="false">
> > > > > > > ...
> > > > > > > </bean>
> > > > > > > ...
> > > > > > > </beans>
> > > > > > >
> > > > > > > Specs:
> > > > > > > Tapestry 4
> > > > > > > Hibernate 3
> > > > > > > Spring 1.1
> > > > > > > Java 1.5
> > > > > > > Tomcat 5.5
> > > > > > >
> > > > > > > Summary:
> > > > > > > The setup works as far as persistence goes. My objects are
> > persisted
> > > > to
> > > > > > the
> > > > > > > database. My issue has to do with session and why I can't get my
> > > > Person
> > > > > > > object to reset for the next request. Thanks for any guidance.
> > > > > > >
> > > > > > >
> > > > > > > Kevin
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail:
> > tapestry-user-unsubscribe@jakarta.apache.org
> > > > > > For additional commands, e-mail:
> > tapestry-user-help@jakarta.apache.org
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Jesse Kuhnert
> > > > > Tacos/Tapestry, team member/developer
> > > > >
> > > > > Open source based consulting work centered around
> > > > > dojo/tapestry/tacos/hivemind. http://opennotion.com
> > > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > 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: Resetting state of Injected Objects
Posted by Kevin Fightmaster <kf...@gmail.com>.
Probably lack of knowledge on how I would go about doing that ;-).
On a more 'meta' note: I like using hibernate and haven't done enough
research on hivemind to know how easy it is to integrate the two. So I need
Spring to act as my IoC and integration point with hibernate. I've tried
hard to maintain tier code that wasnt tightly integrated with other tiers.
The code in this page class doesn't require any context but hivemind. I'm
always open to more elegant solutions I just dont have enough
tapestry/hivemind knowledge yet to come up with it. If I could write a
wrapper to the InjectObjectWorker object and have that setup in a config
that may be a more elegant solution.
Thanks for the dialog,
Kevin
On 3/28/06, amirsguard-tapestry@yahoo.com <am...@yahoo.com>
wrote:
>
> Well if you are going that route why not just inject the spring context
> and query it for your object directly?
>
> --- Kevin Fightmaster <kf...@gmail.com> wrote:
>
> > I'm glad other folks are having the same issues. And thanks for the
> > feedback.
> > I'm hesitant to modify Tapestry classes. Then I might have to worry
> about
> > unexpected impacts of changing the code and maintainability with
> updates.
> > The work around im using.. but don't like all that much is to use the
> > @InjectObject method as just a template to get a handle to the right
> class.
> > Then creating a newInstance to work with on the page.
> >
> > @InjectObject("spring:Person")
> > public abstract Person getPersonTemplate();
> > public abstract Person getPerson();
> > public abstract void setPerson(Person person);
> >
> > public void pageBeginRender(PageEvent arg0) {
> > if (getPerson() == null) {
> > try {
> > setPerson(getPersonTemplate().getClass().newInstance());
> > } catch (InstantiationException e) {
> > ...
> > } catch (IllegalAccessException e) {
> > ... }
> > }
> > }
> > ....
> > public void detach() {
> > if (log.isDebugEnabled())
> > log.debug("Page Detaching");
> > setPerson(null);
> > super.detach();
> > }
> > I wouldnt call it the most elegant code and I hate having to try/catch
> now.
> > Maybe a better alternative will come down the road.
> >
> >
> >
> > On 3/28/06, amirsguard-tapestry@yahoo.com <am...@yahoo.com>
> > wrote:
> > >
> > > This is a broder issue than spring, this has to do with the way
> > > InjectObjectWorker works. If there is any doubt just log the enhanced
> > > class's source code and examine how the injected object is passed to
> the
> > > object (or just examine the injectObject method).
> > >
> > > The same problem occurs with any injected object.
> > >
> > > --- Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> > >
> > > > I would reccomend using Howard's spring stuff
> > > > http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
> > > >
> > > > On 3/28/06, amirsguard-tapestry@yahoo.com <
> amirsguard-tapestry@yahoo.com
> > > >
> > > > wrote:
> > > > >
> > > > > Kevin,
> > > > >
> > > > > I think this is a bug, I had the same problem.
> > > > >
> > > > > What is happening is that when the page is being enhanced
> (subclass
> > > > > created)
> > > > > the reference to the injected object (a spring object in your
> case) is
> > >
> > > > > passed
> > > > > through the constructor. Now since the page is pooled, the next
> time a
> > > > > request
> > > > > is made the requested is serviced with this cached page along with
> the
> > >
> > > > > original
> > > > > (stale) injected object.
> > > > >
> > > > > I had to modify InjectObjectWorker class so that the reference is
> not
> > > > > passed
> > > > > through the constructor but rather as a getter object that looks
> up
> > > > > spring's
> > > > > application context every time. Take a look at this class's inject
> > > object
> > > > > method.
> > > > >
> > > > > Regards,
> > > > > Amir
> > > > >
> > > > > --- Kevin Fightmaster < kfightmaster@gmail.com> wrote:
> > > > >
> > > > > > Problem:
> > > > > > When I submit a form which persists a new object to the
> database
> > > and
> > > > > I
> > > > > > return back to the form to create a new object but the old
> object
> > > values
> > > > > are
> > > > > > still there. I'm using @InjectObject in my code and I'm not sure
> how
> > > to
> > > > > tell
> > > > > > the class to reset the value.
> > > > > >
> > > > > > Artifacts:
> > > > > > [PAGE CLASS]
> > > > > > public abstract class AddPerson extends
> PersonPersistenceAbstract {
> > > > > > ...
> > > > > > @InjectObject("spring:Person")
> > > > > > public abstract Person getPerson();
> > > > > > ...
> > > > > > public void detach() {
> > > > > > if (log.isDebugEnabled ())
> > > > > > log.debug("Page Detaching");
> > > > > > super.detach();
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > [PAGE SPECIFICATION]
> > > > > > <!DOCTYPE page-specification PUBLIC
> > > > > > "-//Apache Software Foundation//Tapestry Specification 4.0
> //EN"
> > > > > > " http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> > > > > > <page-specification class="
> > > > > > org.fightmaster.person.presentation.page.AddPerson">
> > > > > > <inject property="listPerson" type="page"
> object="ListPerson"/>
> > > > > > <component id="personForm" type="Form">
> > > > > > <binding name="listener" value="listener:onSubmit"/>
> > > > > > </component>
> > > > > > <component id="firstname" type="TextField">
> > > > > > <binding name="value" value="ognl:person.firstname"/>
> > > > > > </component>
> > > > > > <component id="middlename" type="TextField">
> > > > > > <binding name="value" value="ognl:person.middlename"/>
> > > > > > </component>
> > > > > > <component id="lastname" type="TextField">
> > > > > > <binding name="value" value="ognl:person.lastname"/>
> > > > > > </component>
> > > > > > </page-specification>
> > > > > >
> > > > > > [SPRING BEAN XML]
> > > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > > > > > " http://www.springframework.org/dtd/spring-beans.dtd">
> > > > > > <beans>
> > > > > > <bean id="Person.Hibernate.Annotation.SessionFactory" class="
> > > > > >
> > > > >
> > >
> org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
> > > > > ">
> > > > > > <property name="configurationClass" value="
> > > > > > org.hibernate.cfg.AnnotationConfiguration "/>
> > > > > > <property name="configLocation" value="classpath:
> > > hibernate.cfg.xml
> > > > > "/>
> > > > > > </bean>
> > > > > > ...
> > > > > > <bean id="Person" class="
> > > > > > org.fightmaster.person.business.hibernate.PersonImpl "
> > > singleton="false">
> > > > > > ...
> > > > > > </bean>
> > > > > > ...
> > > > > > </beans>
> > > > > >
> > > > > > Specs:
> > > > > > Tapestry 4
> > > > > > Hibernate 3
> > > > > > Spring 1.1
> > > > > > Java 1.5
> > > > > > Tomcat 5.5
> > > > > >
> > > > > > Summary:
> > > > > > The setup works as far as persistence goes. My objects are
> persisted
> > > to
> > > > > the
> > > > > > database. My issue has to do with session and why I can't get my
> > > Person
> > > > > > object to reset for the next request. Thanks for any guidance.
> > > > > >
> > > > > >
> > > > > > Kevin
> > > > > >
> > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Jesse Kuhnert
> > > > Tacos/Tapestry, team member/developer
> > > >
> > > > Open source based consulting work centered around
> > > > dojo/tapestry/tacos/hivemind. http://opennotion.com
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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: Resetting state of Injected Objects
Posted by am...@yahoo.com.
Well if you are going that route why not just inject the spring context
and query it for your object directly?
--- Kevin Fightmaster <kf...@gmail.com> wrote:
> I'm glad other folks are having the same issues. And thanks for the
> feedback.
> I'm hesitant to modify Tapestry classes. Then I might have to worry about
> unexpected impacts of changing the code and maintainability with updates.
> The work around im using.. but don't like all that much is to use the
> @InjectObject method as just a template to get a handle to the right class.
> Then creating a newInstance to work with on the page.
>
> @InjectObject("spring:Person")
> public abstract Person getPersonTemplate();
> public abstract Person getPerson();
> public abstract void setPerson(Person person);
>
> public void pageBeginRender(PageEvent arg0) {
> if (getPerson() == null) {
> try {
> setPerson(getPersonTemplate().getClass().newInstance());
> } catch (InstantiationException e) {
> ...
> } catch (IllegalAccessException e) {
> ... }
> }
> }
> ....
> public void detach() {
> if (log.isDebugEnabled())
> log.debug("Page Detaching");
> setPerson(null);
> super.detach();
> }
> I wouldnt call it the most elegant code and I hate having to try/catch now.
> Maybe a better alternative will come down the road.
>
>
>
> On 3/28/06, amirsguard-tapestry@yahoo.com <amirsguard-tapestry@yahoo.com >
> wrote:
> >
> > This is a broder issue than spring, this has to do with the way
> > InjectObjectWorker works. If there is any doubt just log the enhanced
> > class's source code and examine how the injected object is passed to the
> > object (or just examine the injectObject method).
> >
> > The same problem occurs with any injected object.
> >
> > --- Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> >
> > > I would reccomend using Howard's spring stuff
> > > http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
> > >
> > > On 3/28/06, amirsguard-tapestry@yahoo.com <amirsguard-tapestry@yahoo.com
> > >
> > > wrote:
> > > >
> > > > Kevin,
> > > >
> > > > I think this is a bug, I had the same problem.
> > > >
> > > > What is happening is that when the page is being enhanced (subclass
> > > > created)
> > > > the reference to the injected object (a spring object in your case) is
> >
> > > > passed
> > > > through the constructor. Now since the page is pooled, the next time a
> > > > request
> > > > is made the requested is serviced with this cached page along with the
> >
> > > > original
> > > > (stale) injected object.
> > > >
> > > > I had to modify InjectObjectWorker class so that the reference is not
> > > > passed
> > > > through the constructor but rather as a getter object that looks up
> > > > spring's
> > > > application context every time. Take a look at this class's inject
> > object
> > > > method.
> > > >
> > > > Regards,
> > > > Amir
> > > >
> > > > --- Kevin Fightmaster < kfightmaster@gmail.com> wrote:
> > > >
> > > > > Problem:
> > > > > When I submit a form which persists a new object to the database
> > and
> > > > I
> > > > > return back to the form to create a new object but the old object
> > values
> > > > are
> > > > > still there. I'm using @InjectObject in my code and I'm not sure how
> > to
> > > > tell
> > > > > the class to reset the value.
> > > > >
> > > > > Artifacts:
> > > > > [PAGE CLASS]
> > > > > public abstract class AddPerson extends PersonPersistenceAbstract {
> > > > > ...
> > > > > @InjectObject("spring:Person")
> > > > > public abstract Person getPerson();
> > > > > ...
> > > > > public void detach() {
> > > > > if (log.isDebugEnabled ())
> > > > > log.debug("Page Detaching");
> > > > > super.detach();
> > > > > }
> > > > > }
> > > > >
> > > > > [PAGE SPECIFICATION]
> > > > > <!DOCTYPE page-specification PUBLIC
> > > > > "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
> > > > > " http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> > > > > <page-specification class="
> > > > > org.fightmaster.person.presentation.page.AddPerson">
> > > > > <inject property="listPerson" type="page" object="ListPerson"/>
> > > > > <component id="personForm" type="Form">
> > > > > <binding name="listener" value="listener:onSubmit"/>
> > > > > </component>
> > > > > <component id="firstname" type="TextField">
> > > > > <binding name="value" value="ognl:person.firstname"/>
> > > > > </component>
> > > > > <component id="middlename" type="TextField">
> > > > > <binding name="value" value="ognl:person.middlename"/>
> > > > > </component>
> > > > > <component id="lastname" type="TextField">
> > > > > <binding name="value" value="ognl:person.lastname"/>
> > > > > </component>
> > > > > </page-specification>
> > > > >
> > > > > [SPRING BEAN XML]
> > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > > > > " http://www.springframework.org/dtd/spring-beans.dtd">
> > > > > <beans>
> > > > > <bean id="Person.Hibernate.Annotation.SessionFactory" class="
> > > > >
> > > >
> > org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
> > > > ">
> > > > > <property name="configurationClass" value="
> > > > > org.hibernate.cfg.AnnotationConfiguration "/>
> > > > > <property name="configLocation" value="classpath:
> > hibernate.cfg.xml
> > > > "/>
> > > > > </bean>
> > > > > ...
> > > > > <bean id="Person" class="
> > > > > org.fightmaster.person.business.hibernate.PersonImpl "
> > singleton="false">
> > > > > ...
> > > > > </bean>
> > > > > ...
> > > > > </beans>
> > > > >
> > > > > Specs:
> > > > > Tapestry 4
> > > > > Hibernate 3
> > > > > Spring 1.1
> > > > > Java 1.5
> > > > > Tomcat 5.5
> > > > >
> > > > > Summary:
> > > > > The setup works as far as persistence goes. My objects are persisted
> > to
> > > > the
> > > > > database. My issue has to do with session and why I can't get my
> > Person
> > > > > object to reset for the next request. Thanks for any guidance.
> > > > >
> > > > >
> > > > > Kevin
> > > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > Jesse Kuhnert
> > > Tacos/Tapestry, team member/developer
> > >
> > > Open source based consulting work centered around
> > > dojo/tapestry/tacos/hivemind. http://opennotion.com
> > >
> >
> >
> > ---------------------------------------------------------------------
> > 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: Resetting state of Injected Objects
Posted by Kevin Fightmaster <kf...@gmail.com>.
I'm glad other folks are having the same issues. And thanks for the
feedback.
I'm hesitant to modify Tapestry classes. Then I might have to worry about
unexpected impacts of changing the code and maintainability with updates.
The work around im using.. but don't like all that much is to use the
@InjectObject method as just a template to get a handle to the right class.
Then creating a newInstance to work with on the page.
@InjectObject("spring:Person")
public abstract Person getPersonTemplate();
public abstract Person getPerson();
public abstract void setPerson(Person person);
public void pageBeginRender(PageEvent arg0) {
if (getPerson() == null) {
try {
setPerson(getPersonTemplate().getClass().newInstance());
} catch (InstantiationException e) {
...
} catch (IllegalAccessException e) {
... }
}
}
....
public void detach() {
if (log.isDebugEnabled())
log.debug("Page Detaching");
setPerson(null);
super.detach();
}
I wouldnt call it the most elegant code and I hate having to try/catch now.
Maybe a better alternative will come down the road.
On 3/28/06, amirsguard-tapestry@yahoo.com <amirsguard-tapestry@yahoo.com >
wrote:
>
> This is a broder issue than spring, this has to do with the way
> InjectObjectWorker works. If there is any doubt just log the enhanced
> class's source code and examine how the injected object is passed to the
> object (or just examine the injectObject method).
>
> The same problem occurs with any injected object.
>
> --- Jesse Kuhnert < jkuhnert@gmail.com> wrote:
>
> > I would reccomend using Howard's spring stuff
> > http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
> >
> > On 3/28/06, amirsguard-tapestry@yahoo.com <amirsguard-tapestry@yahoo.com
> >
> > wrote:
> > >
> > > Kevin,
> > >
> > > I think this is a bug, I had the same problem.
> > >
> > > What is happening is that when the page is being enhanced (subclass
> > > created)
> > > the reference to the injected object (a spring object in your case) is
>
> > > passed
> > > through the constructor. Now since the page is pooled, the next time a
> > > request
> > > is made the requested is serviced with this cached page along with the
>
> > > original
> > > (stale) injected object.
> > >
> > > I had to modify InjectObjectWorker class so that the reference is not
> > > passed
> > > through the constructor but rather as a getter object that looks up
> > > spring's
> > > application context every time. Take a look at this class's inject
> object
> > > method.
> > >
> > > Regards,
> > > Amir
> > >
> > > --- Kevin Fightmaster < kfightmaster@gmail.com> wrote:
> > >
> > > > Problem:
> > > > When I submit a form which persists a new object to the database
> and
> > > I
> > > > return back to the form to create a new object but the old object
> values
> > > are
> > > > still there. I'm using @InjectObject in my code and I'm not sure how
> to
> > > tell
> > > > the class to reset the value.
> > > >
> > > > Artifacts:
> > > > [PAGE CLASS]
> > > > public abstract class AddPerson extends PersonPersistenceAbstract {
> > > > ...
> > > > @InjectObject("spring:Person")
> > > > public abstract Person getPerson();
> > > > ...
> > > > public void detach() {
> > > > if (log.isDebugEnabled ())
> > > > log.debug("Page Detaching");
> > > > super.detach();
> > > > }
> > > > }
> > > >
> > > > [PAGE SPECIFICATION]
> > > > <!DOCTYPE page-specification PUBLIC
> > > > "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
> > > > " http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> > > > <page-specification class="
> > > > org.fightmaster.person.presentation.page.AddPerson">
> > > > <inject property="listPerson" type="page" object="ListPerson"/>
> > > > <component id="personForm" type="Form">
> > > > <binding name="listener" value="listener:onSubmit"/>
> > > > </component>
> > > > <component id="firstname" type="TextField">
> > > > <binding name="value" value="ognl:person.firstname"/>
> > > > </component>
> > > > <component id="middlename" type="TextField">
> > > > <binding name="value" value="ognl:person.middlename"/>
> > > > </component>
> > > > <component id="lastname" type="TextField">
> > > > <binding name="value" value="ognl:person.lastname"/>
> > > > </component>
> > > > </page-specification>
> > > >
> > > > [SPRING BEAN XML]
> > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > > > " http://www.springframework.org/dtd/spring-beans.dtd">
> > > > <beans>
> > > > <bean id="Person.Hibernate.Annotation.SessionFactory" class="
> > > >
> > >
> org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
> > > ">
> > > > <property name="configurationClass" value="
> > > > org.hibernate.cfg.AnnotationConfiguration "/>
> > > > <property name="configLocation" value="classpath:
> hibernate.cfg.xml
> > > "/>
> > > > </bean>
> > > > ...
> > > > <bean id="Person" class="
> > > > org.fightmaster.person.business.hibernate.PersonImpl "
> singleton="false">
> > > > ...
> > > > </bean>
> > > > ...
> > > > </beans>
> > > >
> > > > Specs:
> > > > Tapestry 4
> > > > Hibernate 3
> > > > Spring 1.1
> > > > Java 1.5
> > > > Tomcat 5.5
> > > >
> > > > Summary:
> > > > The setup works as far as persistence goes. My objects are persisted
> to
> > > the
> > > > database. My issue has to do with session and why I can't get my
> Person
> > > > object to reset for the next request. Thanks for any guidance.
> > > >
> > > >
> > > > Kevin
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tacos/Tapestry, team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://opennotion.com
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
Re: Resetting state of Injected Objects
Posted by Kevin Fightmaster <kf...@gmail.com>.
The tapestry-spring package I was already using and It was nice to find an
updated version which accounted for "singleton="false" type of spring beans
but the updated package still seems to have some quarky behavior which I
still needed to generate a work around for and I wrote that all down in a
new thead, for easier search for others with similar problems, titled
"tapestry-spring
0.1.2 InjectSpring "
Thanks for all the feedback,
Kevin
On 3/28/06, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> I would reccomend using Howard's spring stuff
> http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
>
> On 3/28/06, amirsguard-tapestry@yahoo.com <am...@yahoo.com>
> wrote:
> >
> > Kevin,
> >
> > I think this is a bug, I had the same problem.
> >
> > What is happening is that when the page is being enhanced (subclass
> > created)
> > the reference to the injected object (a spring object in your case) is
> > passed
> > through the constructor. Now since the page is pooled, the next time a
> > request
> > is made the requested is serviced with this cached page along with the
> > original
> > (stale) injected object.
> >
> > I had to modify InjectObjectWorker class so that the reference is not
> > passed
> > through the constructor but rather as a getter object that looks up
> > spring's
> > application context every time. Take a look at this class's inject
> object
> > method.
> >
> > Regards,
> > Amir
> >
> > --- Kevin Fightmaster <kf...@gmail.com> wrote:
> >
> > > Problem:
> > > When I submit a form which persists a new object to the database
> and
> > I
> > > return back to the form to create a new object but the old object
> values
> > are
> > > still there. I'm using @InjectObject in my code and I'm not sure how
> to
> > tell
> > > the class to reset the value.
> > >
> > > Artifacts:
> > > [PAGE CLASS]
> > > public abstract class AddPerson extends PersonPersistenceAbstract {
> > > ...
> > > @InjectObject("spring:Person")
> > > public abstract Person getPerson();
> > > ...
> > > public void detach() {
> > > if (log.isDebugEnabled())
> > > log.debug("Page Detaching");
> > > super.detach();
> > > }
> > > }
> > >
> > > [PAGE SPECIFICATION]
> > > <!DOCTYPE page-specification PUBLIC
> > > "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
> > > "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> > > <page-specification class="
> > > org.fightmaster.person.presentation.page.AddPerson">
> > > <inject property="listPerson" type="page" object="ListPerson"/>
> > > <component id="personForm" type="Form">
> > > <binding name="listener" value="listener:onSubmit"/>
> > > </component>
> > > <component id="firstname" type="TextField">
> > > <binding name="value" value="ognl:person.firstname"/>
> > > </component>
> > > <component id="middlename" type="TextField">
> > > <binding name="value" value="ognl:person.middlename"/>
> > > </component>
> > > <component id="lastname" type="TextField">
> > > <binding name="value" value="ognl:person.lastname"/>
> > > </component>
> > > </page-specification>
> > >
> > > [SPRING BEAN XML]
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > > "http://www.springframework.org/dtd/spring-beans.dtd">
> > > <beans>
> > > <bean id="Person.Hibernate.Annotation.SessionFactory" class="
> > >
> >
> org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
> > ">
> > > <property name="configurationClass" value="
> > > org.hibernate.cfg.AnnotationConfiguration"/>
> > > <property name="configLocation" value="classpath:hibernate.cfg.xml
> > "/>
> > > </bean>
> > > ...
> > > <bean id="Person" class="
> > > org.fightmaster.person.business.hibernate.PersonImpl"
> singleton="false">
> > > ...
> > > </bean>
> > > ...
> > > </beans>
> > >
> > > Specs:
> > > Tapestry 4
> > > Hibernate 3
> > > Spring 1.1
> > > Java 1.5
> > > Tomcat 5.5
> > >
> > > Summary:
> > > The setup works as far as persistence goes. My objects are persisted
> to
> > the
> > > database. My issue has to do with session and why I can't get my
> Person
> > > object to reset for the next request. Thanks for any guidance.
> > >
> > >
> > > Kevin
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> --
> Jesse Kuhnert
> Tacos/Tapestry, team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://opennotion.com
>
>
Re: Resetting state of Injected Objects
Posted by am...@yahoo.com.
This is a broder issue than spring, this has to do with the way
InjectObjectWorker works. If there is any doubt just log the enhanced
class's source code and examine how the injected object is passed to the
object (or just examine the injectObject method).
The same problem occurs with any injected object.
--- Jesse Kuhnert <jk...@gmail.com> wrote:
> I would reccomend using Howard's spring stuff
> http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
>
> On 3/28/06, amirsguard-tapestry@yahoo.com <am...@yahoo.com>
> wrote:
> >
> > Kevin,
> >
> > I think this is a bug, I had the same problem.
> >
> > What is happening is that when the page is being enhanced (subclass
> > created)
> > the reference to the injected object (a spring object in your case) is
> > passed
> > through the constructor. Now since the page is pooled, the next time a
> > request
> > is made the requested is serviced with this cached page along with the
> > original
> > (stale) injected object.
> >
> > I had to modify InjectObjectWorker class so that the reference is not
> > passed
> > through the constructor but rather as a getter object that looks up
> > spring's
> > application context every time. Take a look at this class's inject object
> > method.
> >
> > Regards,
> > Amir
> >
> > --- Kevin Fightmaster <kf...@gmail.com> wrote:
> >
> > > Problem:
> > > When I submit a form which persists a new object to the database and
> > I
> > > return back to the form to create a new object but the old object values
> > are
> > > still there. I'm using @InjectObject in my code and I'm not sure how to
> > tell
> > > the class to reset the value.
> > >
> > > Artifacts:
> > > [PAGE CLASS]
> > > public abstract class AddPerson extends PersonPersistenceAbstract {
> > > ...
> > > @InjectObject("spring:Person")
> > > public abstract Person getPerson();
> > > ...
> > > public void detach() {
> > > if (log.isDebugEnabled())
> > > log.debug("Page Detaching");
> > > super.detach();
> > > }
> > > }
> > >
> > > [PAGE SPECIFICATION]
> > > <!DOCTYPE page-specification PUBLIC
> > > "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
> > > "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> > > <page-specification class="
> > > org.fightmaster.person.presentation.page.AddPerson">
> > > <inject property="listPerson" type="page" object="ListPerson"/>
> > > <component id="personForm" type="Form">
> > > <binding name="listener" value="listener:onSubmit"/>
> > > </component>
> > > <component id="firstname" type="TextField">
> > > <binding name="value" value="ognl:person.firstname"/>
> > > </component>
> > > <component id="middlename" type="TextField">
> > > <binding name="value" value="ognl:person.middlename"/>
> > > </component>
> > > <component id="lastname" type="TextField">
> > > <binding name="value" value="ognl:person.lastname"/>
> > > </component>
> > > </page-specification>
> > >
> > > [SPRING BEAN XML]
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > > "http://www.springframework.org/dtd/spring-beans.dtd">
> > > <beans>
> > > <bean id="Person.Hibernate.Annotation.SessionFactory" class="
> > >
> > org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
> > ">
> > > <property name="configurationClass" value="
> > > org.hibernate.cfg.AnnotationConfiguration"/>
> > > <property name="configLocation" value="classpath:hibernate.cfg.xml
> > "/>
> > > </bean>
> > > ...
> > > <bean id="Person" class="
> > > org.fightmaster.person.business.hibernate.PersonImpl" singleton="false">
> > > ...
> > > </bean>
> > > ...
> > > </beans>
> > >
> > > Specs:
> > > Tapestry 4
> > > Hibernate 3
> > > Spring 1.1
> > > Java 1.5
> > > Tomcat 5.5
> > >
> > > Summary:
> > > The setup works as far as persistence goes. My objects are persisted to
> > the
> > > database. My issue has to do with session and why I can't get my Person
> > > object to reset for the next request. Thanks for any guidance.
> > >
> > >
> > > Kevin
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> --
> Jesse Kuhnert
> Tacos/Tapestry, team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://opennotion.com
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Resetting state of Injected Objects
Posted by Jesse Kuhnert <jk...@gmail.com>.
I would reccomend using Howard's spring stuff
http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
On 3/28/06, amirsguard-tapestry@yahoo.com <am...@yahoo.com>
wrote:
>
> Kevin,
>
> I think this is a bug, I had the same problem.
>
> What is happening is that when the page is being enhanced (subclass
> created)
> the reference to the injected object (a spring object in your case) is
> passed
> through the constructor. Now since the page is pooled, the next time a
> request
> is made the requested is serviced with this cached page along with the
> original
> (stale) injected object.
>
> I had to modify InjectObjectWorker class so that the reference is not
> passed
> through the constructor but rather as a getter object that looks up
> spring's
> application context every time. Take a look at this class's inject object
> method.
>
> Regards,
> Amir
>
> --- Kevin Fightmaster <kf...@gmail.com> wrote:
>
> > Problem:
> > When I submit a form which persists a new object to the database and
> I
> > return back to the form to create a new object but the old object values
> are
> > still there. I'm using @InjectObject in my code and I'm not sure how to
> tell
> > the class to reset the value.
> >
> > Artifacts:
> > [PAGE CLASS]
> > public abstract class AddPerson extends PersonPersistenceAbstract {
> > ...
> > @InjectObject("spring:Person")
> > public abstract Person getPerson();
> > ...
> > public void detach() {
> > if (log.isDebugEnabled())
> > log.debug("Page Detaching");
> > super.detach();
> > }
> > }
> >
> > [PAGE SPECIFICATION]
> > <!DOCTYPE page-specification PUBLIC
> > "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
> > "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> > <page-specification class="
> > org.fightmaster.person.presentation.page.AddPerson">
> > <inject property="listPerson" type="page" object="ListPerson"/>
> > <component id="personForm" type="Form">
> > <binding name="listener" value="listener:onSubmit"/>
> > </component>
> > <component id="firstname" type="TextField">
> > <binding name="value" value="ognl:person.firstname"/>
> > </component>
> > <component id="middlename" type="TextField">
> > <binding name="value" value="ognl:person.middlename"/>
> > </component>
> > <component id="lastname" type="TextField">
> > <binding name="value" value="ognl:person.lastname"/>
> > </component>
> > </page-specification>
> >
> > [SPRING BEAN XML]
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> > "http://www.springframework.org/dtd/spring-beans.dtd">
> > <beans>
> > <bean id="Person.Hibernate.Annotation.SessionFactory" class="
> >
> org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
> ">
> > <property name="configurationClass" value="
> > org.hibernate.cfg.AnnotationConfiguration"/>
> > <property name="configLocation" value="classpath:hibernate.cfg.xml
> "/>
> > </bean>
> > ...
> > <bean id="Person" class="
> > org.fightmaster.person.business.hibernate.PersonImpl" singleton="false">
> > ...
> > </bean>
> > ...
> > </beans>
> >
> > Specs:
> > Tapestry 4
> > Hibernate 3
> > Spring 1.1
> > Java 1.5
> > Tomcat 5.5
> >
> > Summary:
> > The setup works as far as persistence goes. My objects are persisted to
> the
> > database. My issue has to do with session and why I can't get my Person
> > object to reset for the next request. Thanks for any guidance.
> >
> >
> > Kevin
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
--
Jesse Kuhnert
Tacos/Tapestry, team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://opennotion.com
Re: Resetting state of Injected Objects
Posted by am...@yahoo.com.
Kevin,
I think this is a bug, I had the same problem.
What is happening is that when the page is being enhanced (subclass created)
the reference to the injected object (a spring object in your case) is passed
through the constructor. Now since the page is pooled, the next time a request
is made the requested is serviced with this cached page along with the original
(stale) injected object.
I had to modify InjectObjectWorker class so that the reference is not passed
through the constructor but rather as a getter object that looks up spring's
application context every time. Take a look at this class's inject object
method.
Regards,
Amir
--- Kevin Fightmaster <kf...@gmail.com> wrote:
> Problem:
> When I submit a form which persists a new object to the database and I
> return back to the form to create a new object but the old object values are
> still there. I'm using @InjectObject in my code and I'm not sure how to tell
> the class to reset the value.
>
> Artifacts:
> [PAGE CLASS]
> public abstract class AddPerson extends PersonPersistenceAbstract {
> ...
> @InjectObject("spring:Person")
> public abstract Person getPerson();
> ...
> public void detach() {
> if (log.isDebugEnabled())
> log.debug("Page Detaching");
> super.detach();
> }
> }
>
> [PAGE SPECIFICATION]
> <!DOCTYPE page-specification PUBLIC
> "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
> "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> <page-specification class="
> org.fightmaster.person.presentation.page.AddPerson">
> <inject property="listPerson" type="page" object="ListPerson"/>
> <component id="personForm" type="Form">
> <binding name="listener" value="listener:onSubmit"/>
> </component>
> <component id="firstname" type="TextField">
> <binding name="value" value="ognl:person.firstname"/>
> </component>
> <component id="middlename" type="TextField">
> <binding name="value" value="ognl:person.middlename"/>
> </component>
> <component id="lastname" type="TextField">
> <binding name="value" value="ognl:person.lastname"/>
> </component>
> </page-specification>
>
> [SPRING BEAN XML]
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
> "http://www.springframework.org/dtd/spring-beans.dtd">
> <beans>
> <bean id="Person.Hibernate.Annotation.SessionFactory" class="
> org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
> <property name="configurationClass" value="
> org.hibernate.cfg.AnnotationConfiguration"/>
> <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
> </bean>
> ...
> <bean id="Person" class="
> org.fightmaster.person.business.hibernate.PersonImpl" singleton="false">
> ...
> </bean>
> ...
> </beans>
>
> Specs:
> Tapestry 4
> Hibernate 3
> Spring 1.1
> Java 1.5
> Tomcat 5.5
>
> Summary:
> The setup works as far as persistence goes. My objects are persisted to the
> database. My issue has to do with session and why I can't get my Person
> object to reset for the next request. Thanks for any guidance.
>
>
> Kevin
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org