Well if you are going that route why not just inject the spring context
and query it for your object directly?
--- Kevin Fightmaster <[EMAIL PROTECTED]> 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, [EMAIL PROTECTED] <[EMAIL PROTECTED] >
> 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 < [EMAIL PROTECTED]> wrote:
> >
> > > I would reccomend using Howard's spring stuff
> > > http://howardlewisship.com/tapestry-javaforge/tapestry-spring/ .
> > >
> > > On 3/28/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]
> > >
> > > 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 < [EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> > > --
> > > 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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]