uopdate field value by calling java class

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

uopdate field value by calling java class

fachhoch
java class to update a field value based on other field,
 I have two two xform fields say A and B if users enters value in A I want to do some complex calculations and update the value of B  , is this possible?
 are there any examples ?  complex calculations I mean calling database stored procedure  or calling web service.
 
Reply | Threaded
Open this post in threaded view
|

Re: uopdate field value by calling java class

Harshal
- You can call java static method from xforms.
example:
<xforms:setvalue ref="instance('example')/field-b"
  value="myutil:complex_calculation(instance('example')/field-a)"  
  xmlns:myutil="java:com.myexample.Myutil"/>
Reply | Threaded
Open this post in threaded view
|

Re: uopdate field value by calling java class

fachhoch
I want to set value of B only if a value is entered in A ,
on field A I want  a java script event onmouseout   to fire an ajax request  which will  call my servlet and this will return the value of field B, can I do this ?
Reply | Threaded
Open this post in threaded view
|

Re: uopdate field value by calling java class

Harshal
Call setvalue on xforms-value-changed or DOMFocusOut event.

<xforms:input ref="instance('my-instance')/field-a">
    <xforms:action ev:event="xforms-value-changed">
     do a setvalue here
    </xforms:action>
</xforms:input>

You can read more on events here:
http://www.w3.org/MarkUp/Forms/2010/xforms11-qr.html#events