onActionFormDialog closes even if invalid

cancel
Showing results for 
Search instead for 
Did you mean: 
milesiforge
Member II

onActionFormDialog closes even if invalid

Hi everybody,

I defined the following action form that shos up in a dialog

    <config evaluator="string-compare" condition="DocLibActions">
        <actions>
            <action id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction"
                    icon="check-protocolled-documents"
                    type="javascript"
                    label="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.label">

                <param name="function">onActionFormDialog</param>
                <param name="itemKind">action</param>
                <param name="itemId">inforge.check-protocolled-documents</param> <!-- Repository action id = Spring Bean id -->
                <param name="mode">create</param>
                <param name="destination">{node.nodeRef}</param>
                <param name="successMessage">it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.msg.success</param>
                <param name="failureMessage">it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.msg.failure</param>
                <evaluator>it.inforge.alfresco.protocol.evaluator.isProtocolAdmin</evaluator>
            </action>
        </actions>
    </config>

with the following form

  <config evaluator="string-compare" condition="inforge.check-protocolled-documents"> <!-- ID for the Repository Action that this form is associated with -->
        <forms>
            <form>
                <field-visibility>
                    <show id="type"/>
                    <show id="documentName"/>
                    <show id="fromProtocolNumber"/>
                    <show id="toProtocolNumber"/>
                    <show id="fromProtocolDate"/>
                    <show id="toProtocolDate"/>
                    <show id="fromDocumentNumber"/>
                    <show id="toDocumentNumber"/>
                    <show id="fromDocumentDate"/>
                    <show id="toDocumentDate"/>

                    <show id="onlyMissing"/>
                    <show id="onlyProtocolled"/>
                    <show id="generateFile"/>
                    <show id="sendEmail"/>
                    <show id="emailAddresses"/>
                </field-visibility>
                <appearance>
                    <set id="info" appearance="fieldset" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.set.info" />
                    <set id="protocol" appearance="fieldset" template="/org/alfresco/components/form/2-column-set.ftl" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.set.protocol" />
                    <set id="document" appearance="fieldset" template="/org/alfresco/components/form/2-column-set.ftl" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.set.document" />
                    <set id="output" appearance="fieldset" template="/org/alfresco/components/form/2-column-set.ftl" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.set.output" />

                    <field id="type" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.type" set="info">
                        <control>
                            <control-param name="style">width: 100%</control-param>
                        </control>
                        <constraint-handlers>
                            <constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.mandatory" event="blur" />
                        </constraint-handlers>
                    </field>
                    <field id="documentName" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.documentName" set="info"/>

                    <field id="fromProtocolNumber" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.fromNumber" set="protocol">
                        <control template="/org/alfresco/components/form/controls/number.ftl" />
                        <constraint-handlers>
                            <constraint type="NUMBER" validation-handler="Alfresco.forms.validation.number" event="keyup" />
                        </constraint-handlers>
                    </field>
                    <field id="toProtocolNumber" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.toNumber" set="protocol">
                        <control template="/org/alfresco/components/form/controls/number.ftl" />
                        <constraint-handlers>
                            <constraint type="NUMBER" validation-handler="Alfresco.forms.validation.number" event="keyup" />
                        </constraint-handlers>
                    </field>
                    <field id="fromProtocolDate" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.fromDate" set="protocol">
                        <control template="/org/alfresco/components/form/controls/date.ftl" />
                    </field>
                    <field id="toProtocolDate" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.toDate" set="protocol">
                        <control template="/org/alfresco/components/form/controls/date.ftl" />
                    </field>

                    <field id="fromDocumentNumber" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.fromNumber" set="document">
                        <control template="/org/alfresco/components/form/controls/number.ftl" />
                        <constraint-handlers>
                            <constraint type="NUMBER" validation-handler="Alfresco.forms.validation.number" event="keyup" />
                        </constraint-handlers>
                    </field>
                    <field id="toDocumentNumber" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.toNumber" set="document">
                        <control template="/org/alfresco/components/form/controls/number.ftl" />
                        <constraint-handlers>
                            <constraint type="NUMBER" validation-handler="Alfresco.forms.validation.number" event="keyup" />
                        </constraint-handlers>
                    </field>
                    <field id="fromDocumentDate" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.fromDate" set="document">
                        <control template="/org/alfresco/components/form/controls/date.ftl" />
                    </field>
                    <field id="toDocumentDate" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.toDate" set="document">
                        <control template="/org/alfresco/components/form/controls/date.ftl" />
                    </field>

                    <field id="onlyMissing" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.onlyMissing" set="output"/>
                    <field id="onlyProtocolled" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.onlyProtocolled" set="output"/>
                    <field id="generateFile" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.generateFile" set="output"/>
                    <field id="sendEmail" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.sendEmail" set="output"/>
                    <field id="emailAddresses" label-id="it.inforge.alfresco.protocol.action.checkProtocolledDocumentsAction.emailAddresses" set="output"/>
                </appearance>
            </form>
        </forms>
    </config>

everything works fine and the validations errors show up when I set an invalid value in a validated field.

The only problem is that, when I click the ok button of the dialog containing my form, if one of the fields is invalid, my form is not submitted (which is ok), but the dialog closes.

Is there a way to keep the dialog open when the form is submitted and some fields are invalid?

thanks in advance for your help.

1 Reply
douglascrp
Advanced II

Re: onActionFormDialog closes even if invalid

Hello.

I know this is an old thread, but as there is no answer for it, I decided to share what I found, as it can be useful for someone else in the future.

In order to have the submit button disabled when mandatory fields are not filled, one can replace the onActionFormDialog parameter with onActionFormDialogWithSubmitDisable