WebSphere HATS - Re: How to address HATS objects and GV in JavaScript functions?

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere HATS > June 2005 > Re: How to address HATS objects and GV in JavaScript functions?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: How to address HATS objects and GV in JavaScript functions?
Will Smythe

2005-06-05, 5:45 pm

KenDK wrote:
> How do we address HATS objects in JavaScript functions?
> I tried document.formName.objName but does not work --> error: object does
> not exist.
>
> Also, how to address global variables? I tried the (TransformInfo)request.
> getAttribute().getGlobalVariable(gvName), but was always flagged with error.
> This method works within <% - %> tag and business logic.
>
> I have a dropdown list, and when selection is changed (onchange=), I want to
> run a function to set a global variable to the selection, or selectionIndex.
> I imagine this should be simple, but I am lost, and I could not find any
> real example in any docs.
> Would appreciate any sample code, or manual/document, if any.
>
> Or, is there a better way to achieve this without Javascript?
> Thanks and regards,
> Ken
>
>


Because global variables are server-side variables, you must manually
create client-side variables to use them from within Javascript.

You could accomplish this by adding code similar to the following into
your transformation or template JSP file:

<script language="javascript">

var myGv = "<%=
((TransformInfo)request.getAttribute(CommonConstants.REQ_TRANSFORMINFO)).getGlobalVariable("myGlobalVariable",
true).getString() %>";

</script>

If you view the source of your Web page (after running it on server),
you'll see something like the following:

<script language="javascript">

var myGv = "My value here";

</script>

Where "My value here" is actually the value of the "myGlobalVariable"
global variable. You can now use this "myGv" client-side javascript
variable in your client-side javascript.

Hope this makes sense.

Will
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com