Question
· Jun 16, 2016

How to use <radioSet> and set its value

Hello,

I have a question about how to set the value of a radioSet.  Yes, I know -- the documentation says that setValue can be used "client side", but gives no example.  Plus, I'm trying to set the value of a radioSet in %onAfterCreatePage, which is a Zen method? Server side method? I'm not sure.

 

In my Zen page I create a radioSet like this:

<radioSet id="appRadio" name="appRadio" 
displayList="App One,App Two,App Three" 
valueList="One,Two,Three"/>

 

I want to select a radio based on a sepcific value, that I get from code.

e.g.

Method %OnAfterCreatePage() as %Status

set value = class.aMethodThatReturnsAValue()                                     //e.g. "Two"

set %page.GetComponentById("appRadio").setValue(value)

 

Nope.  That does not compile.

set %page.GetComponentbyId("appRaiod").value = value           //?

 

Thanks,

Laura

Discussion (4)2
Log in or sign up to continue

Your last example is really close - probably just the typo in the component ID that's the problem.

Class DC.ZenRadioOnLoad Extends %ZEN.Component.page
{

/// This XML block defines the contents of this page.
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen" title="">
<radioSet id="appRadio" name="appRadio" 
displayList="App One,App Two,App Three" 
valueList="One,Two,Three"
/>
</page>
}

/// This callback is called after the server-side page 
/// object and all of its children are created.<br/>
/// Subclasses can override this to add, remove, or modify 
/// items within the page object model, or to provide values
/// for controls.
Method %OnAfterCreatePage() As %Status
{
    Set ..%GetComponentById("appRadio").value = "Three"
    Quit $$$OK
}

}

Methods in Zen classes declared with "Method" or "ClassMethod" are all server-side. These may also have the ZenMethod keyword, which allows them to be called from javascript (e.g., zenPage.MethodName().)

If you want to have a JavaScript method in a Zen class, the method should be declared as a ClientMethod with [Language = javascript].

A useful convention you'll see in %ZEN is that server-side, non-ZenMethods have names starting with %, ZenMethods (Methods or ClassMethods with the ZenMethod keyword) start with capital letters, and ClientMethods start with lower case letters. It's useful to follow the same convention when you build your own Zen pages.