Howard updated this bridge(tapestry-spring) to help with the use of spring
"prototype" objects. However in using this package on a form submission I've
run into problems. It seems that if I setup my object in the java page file
like the following

@InjectSpring("Person")
public abstract Person getPerson();

-------------------------------------------------------------
and have my html read something like this

  <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>

----------------------------------------------------------------------
 and then define my listener like this

public void onSubmit(IRequestCycle cycle) {
        getPersister().addPerson(getPerson());
        ....
}

What appears to be happening is that the values submitted in the request are
not getting placed on the instance returned by getPerson() in my listener.
Im not sure if the values are captured on a different instance and the
getPerson() called in my listerner is returning a new instance of the bean.
So in a previous thread titled "Resetting state of Injected Objects" I gave
some background on what I was trying to do. I have however found a much more
elegant solution to my problem until such time as the tapestry-spring bridge
is functioning more along the lines of how it should ought to work (if that
ever becomes the case) so below is a solution which should work for people
integrating spring and wishing to get a new instance each time they are on a
create page.

@InjectSpring("Person")
    public abstract Person getPersonTemplate();
@InitialValue("ognl:personTemplate")
    public abstract Person getPerson();

This is a drastic reduction in the amount of code I used in my previous work
around. And gives me everything I need. If tapestry-spring encapsulates the
ability to use it in form submission listeners then all I have to do is
remove the Template() method and the @InitialValue annotation. I hope this
can help others looking for a work around.

Kevin

Reply via email to