javascript-XForms

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

javascript-XForms

Prameela R

Hi Florian,

 

1. I used the following function in javascrit tag.to bind the value directly to the dummy instance.But it did’t work.

 

<script language="javascript">

function changeMe(){

var model = document.getElementById("myModel");

var instance = model.getInstanceDocument ("myInstance");

var textElements = instance.getElementsByTagName("text");

textElements[0].firstChild.nodeValue = 'Changed!';

model.rebuild();

model.refresh();

}

</script>

 

In modeltag

 

<xf:model id="myModel">

<xf:instance id="city-instance">

                             <gcity xmlns="">

                             <getcity></getcity>

                             </gcity>

                         </xf:instance>

                    

<xf:bind id="getcity" nodeset="getcity"  type="xs:string"/>

</xf:instance>

 

 

 

2.tried to get te value in to some variable

 

Javascript

 

 

<script type="text/javascript"

src="http://www.google.com/jsapi?key=ABCDEFG"></script>

<script language="javascript">

function SetValue(){

 

   var city = google.loader.ClientLocation.address.city;

   return city;

}

</script>

 

 

 

 

In body tag

<xf:variable name="cityid" select="SetValue()"/>

Or

<xf:variable name="cityid" value="SetValue()"/>

 

If I can get the city value directly immediately on load I can display the respective near by events immediately who ever the client.

 

 

 

3.IS google api integrated with XForms.IF so how to use it to get the client location.



--
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: javascript-XForms

fl.schmitt(ops-users)
Prameela,

> 1. I used the following function in javascrit tag.to bind the value
> directly to the dummy instance.But it did’t work.

yes, you can't modify instance data directly using JavaScript. Instead,
you could modify a xforms control, thuns modifying indirectly the
instance, too. Have you checked the documentation about this?:

http://www.orbeon.com/ops/doc/reference-xforms-2#xforms-javascript

There's a FAQ regarding this, too:

http://www.orbeon.com/ops/doc/home-faq#javascript-dom

If you don't want to show the controls that are modified by javascript,
just hide them, for example using css.


HTH
florian



--
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: javascript-XForms

David McIntyre
In reply to this post by Prameela R
I see Florian has already directed you to the documentation at http://www.orbeon.com/ops/doc/reference-xforms-2#xforms-javascript.  But, just to amplify on what you will read there, you need to understand that the <xf:model id="myModel"/> element exists only on the server, not on the client.  So it will not be possible to access it using document.getElementById("myModel") in javascript which runs on the client.

To do what you have in your example, you would have to use

<script language="javascript">

function changeMe(){

    ORBEON.xforms.Document.setValue("myHiddenInput", 'Changed!');

}

</script>

and, in your form

<span style="display:none;"><xf:input id="myHiddenInput" ref="instance('myInstance')/text"/></span>

HTH,

Dave

Prameela R wrote:

Hi Florian,

 

1. I used the following function in javascrit tag.to bind the value directly to the dummy instance.But it did’t work.

 

<script language="javascript">

function changeMe(){

var model = document.getElementById("myModel");

var instance = model.getInstanceDocument ("myInstance");

var textElements = instance.getElementsByTagName("text");

textElements[0].firstChild.nodeValue = 'Changed!';

model.rebuild();

model.refresh();

}

</script>

 

In modeltag

 

<xf:model id="myModel">

<xf:instance id="city-instance">

                             <gcity xmlns="">

                             <getcity></getcity>

                             </gcity>

                         </xf:instance>

                    

<xf:bind id="getcity" nodeset="getcity"  type="xs:string"/>

</xf:instance>

 

 

 

2.tried to get te value in to some variable

 

Javascript

 

 

<script type="text/javascript"

src="http://www.google.com/jsapi?key=ABCDEFG"></script>

<script language="javascript">

function SetValue(){

 

   var city = google.loader.ClientLocation.address.city;

   return city;

}

</script>

 

 

 

 

In body tag

<xf:variable name="cityid" select="SetValue()"/>

Or

<xf:variable name="cityid" value="SetValue()"/>

 

If I can get the city value directly immediately on load I can display the respective near by events immediately who ever the client.

 

 

 

3.IS google api integrated with XForms.IF so how to use it to get the client location.


--
Orion Signature

Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com


This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


--
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: javascript-XForms

Prameela R
Orion Signature

Thank you Florian and Dave,

 

I did the same what did you suggested .it’s working fine but when iam trying to include it in Liferay,input id is getting converted to some ramdom value so in javascript

It is not able to set the value.i.e id used to setvalue in javascript is constant but input id is getting  converted.

 

That is the reason why I wanted it to bind directly to the instance from javascript or wanted to get the returned value into any variable. And this all should happen on onload.

 

Is that the only way to get the javascript value in to xforms?.

 

 

Prameela.

 

 

 


From: Dave McIntyre [mailto:[hidden email]]
Sent: Friday, December 05, 2008 6:01 AM
To: [hidden email]
Subject: [ops-users] Re: javascript-XForms

 

I see Florian has already directed you to the documentation at http://www.orbeon.com/ops/doc/reference-xforms-2#xforms-javascript.  But, just to amplify on what you will read there, you need to understand that the <xf:model id="myModel"/> element exists only on the server, not on the client.  So it will not be possible to access it using document.getElementById("myModel") in javascript which runs on the client.

To do what you have in your example, you would have to use

<script language="javascript">

function changeMe(){

    ORBEON.xforms.Document.setValue("myHiddenInput", 'Changed!');

}

</script>

and, in your form

<span style="display:none;"><xf:input id="myHiddenInput" ref="instance('myInstance')/text"/></span>

HTH,

Dave

Prameela R wrote:

Hi Florian,

 

1. I used the following function in javascrit tag.to bind the value directly to the dummy instance.But it did’t work.

 

<script language="javascript">

function changeMe(){

var model = document.getElementById("myModel");

var instance = model.getInstanceDocument ("myInstance");

var textElements = instance.getElementsByTagName("text");

textElements[0].firstChild.nodeValue = 'Changed!';

model.rebuild();

model.refresh();

}

</script>

 

In modeltag

 

<xf:model id="myModel">

<xf:instance id="city-instance">

                             <gcity xmlns="">

                             <getcity></getcity>

                             </gcity>

                         </xf:instance>

                    

<xf:bind id="getcity" nodeset="getcity"  type="xs:string"/>

</xf:instance>

 

 

 

2.tried to get te value in to some variable

 

Javascript

 

 

<script type="text/javascript"

src="http://www.google.com/jsapi?key=ABCDEFG"></script>

<script language="javascript">

function SetValue(){

 

   var city = google.loader.ClientLocation.address.city;

   return city;

}

</script>

 

 

 

 

In body tag

<xf:variable name="cityid" select="SetValue()"/>

Or

<xf:variable name="cityid" value="SetValue()"/>

 

If I can get the city value directly immediately on load I can display the respective near by events immediately who ever the client.

 

 

 

3.IS google api integrated with XForms.IF so how to use it to get the client location.

 

--


 

Dave McIntyreSoftware Developer
[hidden email]
P: +64 9 638 0600
M: +64 21 212 8087
F: +64 9 638 0699
S: <a href="callto:dave.mcintyre">dave.mcintyre
www.orionhealth.com

 

This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.



--
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