trigger validation without submission

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

trigger validation without submission

Alexandru Ionita



Hello guys,

is it possible to trigger the validation without a submission? Our form is passing the XML instance to a webservice that is making all the stuff WITHOUT submission, but calling a XPL instead. 
The idea is to trigger the validation process in the action sequence.

<xf:action ev:event="DOMActivate">
    _do_smth_
    _do_smth_
    *VALIDATE forms*
    if (validation is successful) {
         _do_smtg_else_
         _do_smtg_else_
    } else {
         DO NOTHING // display error msgs
    }
</xf:action>


thanks,
Alexandru


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: trigger validation without submission

Tom Grahame
Hi Alexandru,

Could you use the dispatch element? Something like this (untested):

<xf:action ev:event="DOMActivate">
        <xf:dispatch name="xforms-revalidate" target="my-model-id"/>
</xf:action>

You would then listen for xforms-valid or xforms-invalid in your model and go from there.

Hope that helps,

Tom
Reply | Threaded
Open this post in threaded view
|

Re: Re: trigger validation without submission

Alexandru Ionita


Hello Tom,

thanks for your help, unfortunately is not working. There is nothing changed in the actual user interface behavior. Should this "xforms-revalidate" action registered or something?

Alexandru


On Thu, Mar 18, 2010 at 10:30, Tom Grahame <[hidden email]> wrote:

Hi Alexandru,

Could you use the dispatch element? Something like this (untested):

<xf:action ev:event="DOMActivate">
       <xf:dispatch name="xforms-revalidate" target="my-model-id"/>
</xf:action>

You would then listen for xforms-valid or xforms-invalid in your model and
go from there.

Hope that helps,

Tom
--
View this message in context: http://n4.nabble.com/trigger-validation-without-submission-tp1597358p1597711.html
Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: trigger validation without submission

Tom Grahame
Hi Alexandru,

If you mean a change in the form as you see it in the browser, nothing will change unless you configure it to do so. Events occur as the processing model is executed, but you need to listen for them and declare your additional behaviour.

I've attached a simple example to demonstrate what I mean:
revalidate.zip

Unzip revalidate.zip and drop the folder under /apps
hit
http://localhost:8080/orbeon/revalidate/
in your browser
Click the buttons.

It is useful to watch the logs and see the events as the occur.

Also, I'm not sure why Orbeon uses xxforms-valid and not xforms-valid.

Best wishes,

Tom
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: trigger validation without submission

Alexandru Ionita


Hello Tom,


your help is much appreciated but this is not helping me. Here is what I'm trying to do

                        <xforms:trigger>
<xforms:label>Make invalid</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('integer')/integer" value="'string'"/>
<xforms:dispatch name="xforms-revalidate" target="main"/>
<!-- If the form is invalid I don't want the following code to be executed -->
<xforms:message>Further action taken!</xforms:message>
</xforms:action> 
</xforms:trigger>

I want, if the form is not valid, the message "Further action taken!" shouldn't be displayed. This is what we want to achieve. The actual code is showing the message even if the form is invalid (we don't want that).

Our solution for the moment is to hide the button if the form is not valid. We do that like this:

<xxforms:variable name="displayButtons" select="if(xxforms:valid(instance('userRequest')/., true()))then 'visible' else 'hidden'"/>
<xhtml:div id="buttons" style="visibility:{$displayButtons}">
                        <xforms:trigger>
<xforms:label>Make invalid</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="instance('integer')/integer" value="'string'"/>
<xforms:dispatch name="xforms-revalidate" target="main"/>
<!-- If the form is invalid I don't want the following code to be executed -->
<xforms:message>Further action taken!</xforms:message>
</xforms:action> 
</xforms:trigger>
</xhtml:div>

This works good for the moment, but we would like to display the buttons too, and if the user press the button, the button's action is not executed until the form is valid - whatever this action might be NOT ONLY submission.

Thanks,
Alexandru

On Fri, Mar 19, 2010 at 11:30, Tom Grahame <[hidden email]> wrote:

Hi Alexandru,

If you mean a change in the form as you see it in the browser, nothing will
change unless you configure it to do so. Events occur as the processing
model is executed, but you need to listen for them and declare your
additional behaviour.

I've attached a simple example to demonstrate what I mean:
http://n4.nabble.com/file/n1599191/revalidate.zip revalidate.zip

Unzip revalidate.zip and drop the folder under /apps
hit
http://localhost:8080/orbeon/revalidate/
in your browser
Click the buttons.

It is useful to watch the logs and see the events as the occur.

Also, I'm not sure why Orbeon uses xxforms-valid and not xforms-valid.

Best wishes,

Tom
--
View this message in context: http://n4.nabble.com/trigger-validation-without-submission-tp1597358p1599191.html
Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: trigger validation without submission

Alessandro  Vernet
Administrator
Alexandru, Tom,

The xforms-valid and xforms-invalid events are not dispatch on
revalidation if the validity doesn't change. So you can't just listen
to those events when doing a revalidation. If you want to use those
events, you have to listen to them since the start and keep track in a
separate instance of what is valid and invalid. It is possible, but in
this case much simpler to use the xxforms:valid() function:

http://wiki.orbeon.com/forms/doc/developer-guide/xforms-xpath-functions#TOC-xxforms:valid-

You'll let us know if it works for you.

Alex

On Fri, Mar 19, 2010 at 4:44 PM, Alexandru Ionita
<[hidden email]> wrote:

>
>
> Hello Tom,
>
> your help is much appreciated but this is not helping me. Here is what I'm
> trying to do
>                         <xforms:trigger>
> <xforms:label>Make invalid</xforms:label>
> <xforms:action ev:event="DOMActivate">
> <xforms:setvalue ref="instance('integer')/integer" value="'string'"/>
> <xforms:dispatch name="xforms-revalidate" target="main"/>
> <!-- If the form is invalid I don't want the following code to be executed
> -->
> <xforms:message>Further action taken!</xforms:message>
> </xforms:action>
> </xforms:trigger>
> I want, if the form is not valid, the message "Further action taken!"
> shouldn't be displayed. This is what we want to achieve. The actual code is
> showing the message even if the form is invalid (we don't want that).
> Our solution for the moment is to hide the button if the form is not valid.
> We do that like this:
> <xxforms:variable name="displayButtons"
> select="if(xxforms:valid(instance('userRequest')/., true()))then 'visible'
> else 'hidden'"/>
> <xhtml:div id="buttons" style="visibility:{$displayButtons}">
>                         <xforms:trigger>
> <xforms:label>Make invalid</xforms:label>
> <xforms:action ev:event="DOMActivate">
> <xforms:setvalue ref="instance('integer')/integer" value="'string'"/>
> <xforms:dispatch name="xforms-revalidate" target="main"/>
> <!-- If the form is invalid I don't want the following code to be executed
> -->
> <xforms:message>Further action taken!</xforms:message>
> </xforms:action>
> </xforms:trigger>
> </xhtml:div>
> This works good for the moment, but we would like to display the buttons
> too, and if the user press the button, the button's action is not executed
> until the form is valid - whatever this action might be NOT ONLY submission.
> Thanks,
> Alexandru
> On Fri, Mar 19, 2010 at 11:30, Tom Grahame <[hidden email]>
> wrote:
>>
>> Hi Alexandru,
>>
>> If you mean a change in the form as you see it in the browser, nothing
>> will
>> change unless you configure it to do so. Events occur as the processing
>> model is executed, but you need to listen for them and declare your
>> additional behaviour.
>>
>> I've attached a simple example to demonstrate what I mean:
>> http://n4.nabble.com/file/n1599191/revalidate.zip revalidate.zip
>>
>> Unzip revalidate.zip and drop the folder under /apps
>> hit
>> http://localhost:8080/orbeon/revalidate/
>> in your browser
>> Click the buttons.
>>
>> It is useful to watch the logs and see the events as the occur.
>>
>> Also, I'm not sure why Orbeon uses xxforms-valid and not xforms-valid.
>>
>> Best wishes,
>>
>> Tom
>> --
>> View this message in context:
>> http://n4.nabble.com/trigger-validation-without-submission-tp1597358p1599191.html
>> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email] mailing
>> list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
Orbeon Forms - Web forms, open-source, for the Enterprise -
http://www.orbeon.com/
My Twitter: http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: trigger validation without submission

Tom Grahame
Alex, Alexandru,

It seems I have not understood the problem, so I am going to bow out of this thread...

My only remaining comment is that perhaps the 'if' action might be useful somewhere.

http://www.w3.org/TR/xforms11/#attrs-action-common

Best wishes,

Tom
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: trigger validation without submission

Alexandru Ionita


Hello Tom,

thanks for pointing me in the right direction. This was exactly what I was looking for. I hope this is working in Orbeon because I didn't test it yet.

Thanks,
Alexandru



<trigger>
   <label>Get Sum</label>
   <action ev:event="DOMActivate">
      <setvalue ref="instance('temps')/counter" value="1"/>
      <setvalue ref="instance('temps')/accumulator" value="0"/>
      <action while="instance('temps')/counter <= count(/some/nodes)">
         <setvalue ref="instance('temps')/accumulator" 
                   value=". + instance('default')/some/nodes[number(instance('temps')/counter)]"
                   if="boolean-from-string(/some/nodes[number(instance('temps')/counter)]/@selected)"/>
         <setvalue ref="instance('temps')/counter" value=". + 1"/>
      </action>
   </action>
</trigger>




On Thu, Mar 25, 2010 at 11:07, Tom Grahame <[hidden email]> wrote:

Alex, Alexandru,

It seems I have not understood the problem, so I am going to bow out of this
thread...

My only remaining comment is that perhaps the 'if' action might be useful
somewhere.

http://www.w3.org/TR/xforms11/#attrs-action-common
http://www.w3.org/TR/xforms11/#attrs-action-common

Best wishes,

Tom
--
View this message in context: http://n4.nabble.com/trigger-validation-without-submission-tp1597358p1690373.html
Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: Re: Re: Re: trigger validation without submission

Alessandro  Vernet
Administrator
Alexandru,

Yes, the "if" attribute is supported on actions, as you would expect.

Alex

On Fri, Mar 26, 2010 at 7:43 AM, Alexandru Ionita
<[hidden email]> wrote:

>
>
> Hello Tom,
> thanks for pointing me in the right direction. This was exactly what I was
> looking for. I hope this is working in Orbeon because I didn't test it yet.
> Thanks,
> Alexandru
> http://www.w3.org/TR/xforms11/#action-iterated
>
> <trigger>
>    <label>Get Sum</label>
>    <action ev:event="DOMActivate">
>       <setvalue ref="instance('temps')/counter" value="1"/>
>       <setvalue ref="instance('temps')/accumulator" value="0"/>
>       <action while="instance('temps')/counter <= count(/some/nodes)">
>          <setvalue ref="instance('temps')/accumulator"
>                    value=". +
> instance('default')/some/nodes[number(instance('temps')/counter)]"
>
> if="boolean-from-string(/some/nodes[number(instance('temps')/counter)]/@selected)"/>
>          <setvalue ref="instance('temps')/counter" value=". + 1"/>
>       </action>
>    </action>
> </trigger>
>
>
>
>
>
> On Thu, Mar 25, 2010 at 11:07, Tom Grahame <[hidden email]>
> wrote:
>>
>> Alex, Alexandru,
>>
>> It seems I have not understood the problem, so I am going to bow out of
>> this
>> thread...
>>
>> My only remaining comment is that perhaps the 'if' action might be useful
>> somewhere.
>>
>> http://www.w3.org/TR/xforms11/#attrs-action-common
>> http://www.w3.org/TR/xforms11/#attrs-action-common
>>
>> Best wishes,
>>
>> Tom
>> --
>> View this message in context:
>> http://n4.nabble.com/trigger-validation-without-submission-tp1597358p1690373.html
>> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>>
>>
>> --
>> You receive this message as a subscriber of the [hidden email] mailing
>> list.
>> To unsubscribe: mailto:[hidden email]
>> For general help: mailto:[hidden email]?subject=help
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing
> list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
Orbeon Forms - Web forms, open-source, for the Enterprise -
http://www.orbeon.com/
My Twitter: http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet