Reputation: 11
I have an onSubmit method defined for a form that triggers an ajax render for another area of the screen that contains a form. While rendering this block it hits an exception, "Form components may not be placed inside other Form components.".
I have dug into the tapestry code and the issue seems to be in the below method of Form.java ...
void setupRender()
{
FormSupport existing = environment.peek(FormSupport.class);
if (existing != null)
{
throw new TapestryException(messages.get("core-form-nesting-not-allowed"), existing, null);
}
...
}
The existing form is not, however, the enclosing form but instead corresponds to the form that triggers the action. It is placed in the environment as part of the onAction method.
Is this a known issue or are am I doing something wrong?
Upvotes: 1
Views: 24
Reputation: 342
I faced the same error message, but I am not sure that we are having the same root cause. The error occurred when changing value inside the form (not onSubmit). Anyway, here is the fix that worked for me :
@OnEvent(value = UpdateZone.DEFAULT_EVENT, component = "myComponent")
public void onChangeFromCriterion(@RequestParameter(value = "criterion", allowBlank = true) String value) {
criterion = value;
ajaxResponseRenderer.addRender(editBlockZone);
resources.triggerEvent("some_event", new Object[]{someData}, callback); // I deleted this line to fix the issue
}
Upvotes: 0