Wicket's form tester attaches model but doesn't detach it afterwards
--------------------------------------------------------------------
Key: WICKET-2377
URL: https://issues.apache.org/jira/browse/WICKET-2377
Project: Wicket
Issue Type: Bug
Components: wicket
Reporter: Peter Ertl
Hi wicketeers!
When calling newFormTester("form") I found out that the page's model is left in
an attached state after the call. The constructor
protected FormTester(final String path, final Form<?> workingForm,
final BaseWicketTester wicketTester, final boolean
fillBlankString)
is accessing the form component hierarchy and it's models (therefore attaches
it) but never call's detach so this is the situation:
** all models is detached
final FormTester form = tester.newFormTester("form");
** one or more component models are now attached !!!
having the model(s) already attached / loaded before calling form.submit() is a
problem!
- I override Form.process() to start a new transaction (similar to Igor's
EntityModel: http://wicketinaction.com/2008/09/building-a-smart-entitymodel)
- During form processing the entity model will get modified
- After form processing the transaction is committed and the changes are
flushed to the database
However, when the entity get's loaded before form processing starts this
doesn't work anymore. Hibernate thinks the entity is transient (it was loaded
in a different session and *btw* I don't use session in view).
When running the same testcase with jetty and a browser it works just fine.
I think FormTester's constructor should call detach to clean up the model state
before returning a new FormTester.
I attached a patch (one line) and applied it to current trunk. It compiles
clean and without errors.
It just detaches the form's model before returning a new form tester.
I think it should go in before final because WicketTester doesn't match the
behavior of wicket running in a web server.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.