Set some fields as readonly while a get submission is processed

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Set some fields as readonly while a get submission is processed

inanda.menezes
This post was updated on .
I have a submission that takes few seconds to get processed, once it's processed, it fills some fields into the form. I want these fields to be readonly just while the submission is getting processed, but it does not work. It uses version 3.9.1 PE, but I've also tested it in version (4.8 CE) and it did not work.

I've tried it the following ways:

1)Using 'xforms-submit': I expected that this event would run before the submission and set the value, but it looks like it sets it after the submission. So it does not work.

            <xf:submission id="test"
                           resource="http://serviceUrl/anyService/123"
                           method="get"
                           replace="instance"
                           serialization="none"
                           targetref="instance('testresponse')"
                           xxf:cache="false"
                           validate="false"> 
                               <xf:setvalue ev:event="xforms-submit" ref="instance('temp')/waitingTestProcess"
                             value="'true'"/>
            </xf:submission>

2)Setting the value before calling send: It does not work, since it sets the value only after the submission.
 <xf:trigger id="control-3-control" bind="control-3-bind">
                                    <xf:label ref="$form-resources/control-3/label"/>
                   
                                    <xf:hint ref="$form-resources/control-3/hint"/>
                                    <xf:alert ref="$fr-resources/detail/labels/alert"/>
                                    <xf:action ev:event="DOMActivate">
                                        <xf:setvalue  ref="instance('temp')/waitingTestProcess" value="'true'"/>
                                        <xf:send submission="test"/>
                                    </xf:action>
                                </xf:trigger>


 Why it does not work? How to get it working?

Reply | Threaded
Open this post in threaded view
|

Re: Set some fields as readonly while a get submission is processed

inanda.menezes
This post was updated on .
I got it to work by using javascript to disable the fields instead of using readonly attribute from bind. Also, it was necessary to dispatch an event using javascript and call  <xforms:send submission="callService"/> into it, because if it's not dispatched from javascript, the script to disable the fields will not run on correct time.

<xxforms:script  ev:event="DOMActivate">
        //Javascript to set the components as disabled or any other javascript you want to run before submission here

        //Call an event which calls the submission. It's important to call this way, otherwise the script to disable the fields will not be called in correct time
         ORBEON.xforms.Document.dispatchEvent("fr-form-model", "fetchFromService");
 </xxforms:script>

<xforms:action ev:event="fetchFromService">

                <xforms:send submission="callService"/>
                //Call script to enable the components again. It could be also called in a xforms-submit-done and xforms-submit-error event
</xforms:action>
Reply | Threaded
Open this post in threaded view
|

Re: Set some fields as readonly while a get submission is processed

Alessandro  Vernet
Administrator
In reply to this post by inanda.menezes
Hi Inanda,

Using JavaScript is one way of doing it.

If you want to keep it in pure XForms, you need to use a delayed event. I.e., your trigger, on DOMActivate would set the flag, <xf:dispatch name="fetchFromService" targetid="fr-form-model" delay="1"/>. The handling of `fetchFromService` would be unchanged compared to what you have now. The delayed event makes sure that the control goes back to the client, so the fields get a chance to become readonly, while the submission is done, triggered in a second Ajax request.

Alternatively, I think that adding mode="asynchronous" on your submission should just do it, with your original code, which might be even simpler and more declarative, compared to using a delayed event. If you get a chance to try, you'll let us know if it works for you.

Alex

On Wed, Mar 11, 2015 at 12:19 PM 'inanda.menezes' via Orbeon Forms <[hidden email]> wrote:
I have a submission that takes few seconds to get processed, once it's
processed, it fills some fields into the form. I want these fields to be
readonly just while the submission is getting processed. It uses version
3.9.1 PE, but I've also tested it in version (4.8 CE) and it did not work.

I've tried it the following ways:

1)Using 'xforms-submit': I expected this event would run before the
submission and set the value, but it looks like it sets it after the
submission. So it did not work.

            <xf:submission id="test"
                           resource="http://serviceUrl/anyService/123"
                           method="get"
                           replace="instance"
                           serialization="none"
                           targetref="instance('testresponse')"
                           xxf:cache="false"
                           validate="false">
                               <xf:setvalue ev:event="xforms-submit"
ref="instance('temp')/waitingTestProcess"
                             value="'true'"/>
            </xf:submission>

2)Setting the value before calling send: It does not work, since it sets the
value only after the submission.
 <xf:trigger id="control-3-control" bind="control-3-bind">
                                    <xf:label
ref="$form-resources/control-3/label"/>

                                    <xf:hint
ref="$form-resources/control-3/hint"/>
                                    <xf:alert
ref="$fr-resources/detail/labels/alert"/>
                                    <xf:action ev:event="DOMActivate">
                                        <xf:setvalue
ref="instance('temp')/waitingTestProcess" value="'true'"/>
                                        <xf:send submission="test"/>
                                    </xf:action>
                                </xf:trigger>





--
View this message in context: http://discuss.orbeon.com/Set-some-fields-as-readonly-while-a-get-submission-is-processed-tp4659663.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet