disable radio button group option using CAF javascript API

Hi,

How can I access a radio button group option using CAF javascript API in order to disable it?
In my use case I have a Radio Button Group named gdnRadio and an option with id selectItemNativo and I’m calling this javascript:

CAF.model("#{caf:cid('selectItemNativo')}").setDisabled(true);

On run-time this fails to execute because the CAF model returns null.

I noticed that the caf:cid(…) resolves to an id, but it doesn’t seem to be the proper one:
This is the value it resolves to: jsfwmp17615:importTemplate:importTemplateNumbering:numberingForm:selectItemNativo
This is the option element id on the HTML: jsfwmp17615:importTemplate:importTemplateNumbering:numberingForm:gdnRadio:7397

Thanks
Bruno

Try something like this:

var radioGroupModel = CAF.model("#{caf:cid('gdnRadio')}");
var item = radioGroupModel.get('selectItemNativo');
var itemModel = CAF.model(item);
itemModel.setDisabled(true);

Hi,

It is recommended that you use a “Disableable Panel” as a parent of the components you are trying to enable/disable, and use the javascript calls on this panel.

br,
Vlad

Hi,

Eric, tried that but it didn’t work out…

var item = radioGroupModel.get('selectItemNativo');  

resolves to null.

Vlad, how can I wrap one item with a disableable panel? Designer doesn’t let me do that.

Thanks
Bruno

Strange, I thought that worked when I tried it. Which version of MWS (and fix level) are you using?

Another option would be to lookup the index of the item and then get it by index like this:


    var radioGroupModel = CAF.model("#{caf:cid('gdnRadio')}");  
    var itemIndex = radioGroupModel.indexOf('selectItemNativo');
    if (itemIndex == -1) {
        alert("item not found");
    } else {
        var item = radioGroupModel.get(itemIndex);  
        var itemModel = CAF.model(item);  
        itemModel.setDisabled(true);  
    }

Or if you just want to list what the values of all the items in the radio group are you could do this:


    var radioGroupModel = CAF.model("#{caf:cid('gdnRadio')}");  
    var itemList = radioGroupModel.list();
    for (var i=0; i < itemList.length; i++) {
        var item = itemList[i];
        alert("item #" + i + " value is: " + item.getValue());
    }

Also, see the jsdocs for the RadioGroup model @ http://techcommunity.softwareag.com/ecosystem/documentation/webmethods/wmsuites/wmsuite8-2_sp2/My_webMethods/8-2-SP1_CAF_JavaScript_Reference/CAF.Select.Radio.Model.html

Hi,

MWS_8.2_SP1_Fix8

Done it by index.

Thanks for your help.
Bruno