I’m currently developing an enterprise form with a custom, pluggable behavior. It is an implementation of OnValidationSuccessBehavior. The form behaves as expected when mapped to a standalone page via a sitemap item, but if I inject said form into another document using the channel editor, the custom behavior is not called anymore.
I have had a look into the AutoDetectFormComponent, which is used in this scenario, and I have noticed that it has a hard-coded list of behaviors that are then assigned to the form if enabled.
Do you have any recommendations or suggestions for what I might try in order to be able to add a form using the channel editor and keeping all of its behaviors?
You can override protected method AutoDetectFormComponent#getAutoDetectBehaviors and configure your extension class in the place where AutoDetectFormComponent is.
Thank you very much for your suggestion. That seems to have done the trick.
However, I’m encountering a different issue now. In my above-mentioned scenario, does the page into which I’m injecting the form need to be mapped to an extension of EformComponent Java class?
EDIT: I have tried extending EformComponent from my main Java component, but to no avail. I am still getting a 404 on the form submission POST request. Any ideas as to why this is happening?
Hi Alex,
First, I see now that besides extending the AutoDetectFormComponent class you can also add your custom behavior to the component using the ‘behaviors’ HST parameter.
Second, 404 is not expected if you drop AutoDetectFormComponent (or an extension) on the page and use a POST and action URL like so:
I double checked my configuration. The main component (i.e. the base page into which I’m dropping the form) is NOT extending EformComponent, it is a basic extension of BaseHstComponent. The referenced container item (the form) uses my custom extension of AutoDetectFormComponent. In terms of Freemarker, the form uses the above code you have mentioned for submission.
This is quite similar to the eforms demo project. I have checked with the debugger and the doAction method on my custom extension of AutoDetectFormComponent is not called. I would imagine this is a direct result of the 404. However, the addConfiguredBehaviors method (as are the other “set-up” methods) is called.
I think it’s worth mentioning that my AutoDetectFormComponent extension is only overriding the getAutoDetectBehaviors method. Should I have overridden another one as well?
Your main (page) component doesn’t need to change it seems.
I was thinking maybe you need to override #getFormBean method but if the doAction doesn’t get called at all that won’t help… That needs to happen so maybe there’s some other component doing a 404? Something in the logs?
Looks like the actionURL POST isn’t done because the validation resourceURL isn’t good, blocking further Javascript executing? Don’t know why. I don’t know your front-end, maybe you can proceed without resourceURLs for validation? Doing that fully client side is also possible.
As far as I can see the validation resource URL configuration isn’t described in eforms setup or bloomreach documentation. Do you have any reference I can review to find a solution?