![]() |
|
|
|
|
Change By:
|
Federico Grilli
(11/Dec/13 6:20 PM)
|
|
Description:
|
Suppose you're creating a new node and doing some additional validation in an action, besides that done by the validator proper. If such additional validation fails for some reason, you are presented again with the form to fix the data you entered before. Now data are correct, you hit the submit button and no validation error will occur. However, the action will fail again, this time with NPE.
Reason
What happened
is
at
that each time you call
{{
JcrNewNodeAdapter.applyChanges()}} to get the actual underlying jcr Node updated to its latest status. The first time that jcr Node is created on the fly and is a transient one as the session it is contained in hasn't been saved yet (it will be saved once all validation passes). The second time the jcr node will be no longer created on the fly, rather fetched from the current JCR session as if it were no longer a new node rather an existing one, hence applyChanges() will return null. We should take into account that a new node adapter isn't always saved on first attempt and validation errors may occur, therefore we must be able to reuse the adapter until it is valid or discarded. What we could do in
info.magnolia.ui.
form
vaadin
.
action
integration
.
SaveFormAction
jcr
.
execute()}} line #90 which reads {{item
JcrNewNodeAdapter
.applyChanges()
;}}. What happened is that
keep on creating
the
underlying JCR session has expired in
node on
the
meantime so that calling again
fly as long as needed.
{
code} // If changes were already applied, behave like a JcrNodeAdapter if (appliedChanges)
{
item
Node node = super
.applyChanges();
}} will return
if (node !=
null
) { isNew = false; return node; } // else validation errors probably occurred
,
that item being temporarily created in
so we need to recreate
the
previous session and now no longer available.
new node on the fly } {code}
|
|
|
|
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <
[email protected]>
----------------------------------------------------------------