IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
  • 1.  selected option in a group radio

    Posted Thu July 11, 2013 11:50 AM

    Hi,

    I have a Radio Button Group with two choices, when a click event for example, I want to check for each option, if “ON” is selected call treatment 1, else if “OFF” is selected call another treamtment 2.

    Radio-Button Group ID : htmlSelectOneRadio
    Individual option 1 ID : optOn
    Individual option 2 ID : optOff

    The value and Item value for the 2 Individual options are empty.

    something like this :

    
    var radioGroupModel = CAF.model("#{caf:cid('htmlSelectOneRadio')}");    
    var itemOn = radioGroupModel.get('optOn');
    var itemOff = radioGroupModel.get('optOff');
    
    if (itemOn.selected() == true) {  
    treatment1();
    }
    if (itemOff.selected() == true) {  
    treatment2();
    }
    

    the code return null.

    if you have an idea how to do it.

    Thanks


    #webMethods
    #MWS-CAF-Task-Engine
    #webMethods-BPMS


  • 2.  RE: selected option in a group radio

    Posted Thu July 11, 2013 12:45 PM

    I’m not sure what code would return null there (there’s no return statement) but you’re calling a nonexistent method to see whether or not the item is checked.

    Either (in Javascript) do this:

    if (itemOn.checked) { 

    Or using CAF.Model [pdf], do this:

    if(isSelected(itemOn)) 

    Either way notice you don’t have to put if( == true) - your test is a boolean, so just do this: if().


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods


  • 3.  RE: selected option in a group radio

    Posted Thu July 11, 2013 01:08 PM

    Hi Rob,

    Thanks for your response :slight_smile:
    I test the code, but it doesn’t work :frowning:
    No message is alerted whn I click on one of the 2 options

    
    var radioGroupModel = CAF.model("#{caf:cid('htmlSelectOneRadio')}");    
    var itemOn = radioGroupModel.get('optOn');
    var itemOff = radioGroupModel.get('optOff');
    
    if(isSelected(itemOn))  {  
    alert("On !!");  
    }
    
    if (itemOff.checked) { 
    alert("Off !!");  
    }

    #webMethods
    #webMethods-BPMS
    #MWS-CAF-Task-Engine


  • 4.  RE: selected option in a group radio

    Posted Thu July 11, 2013 02:11 PM

    Get the index of a item in the radio group:
    http://techcommunity.softwareag.com/ecosystem/documentation/webmethods/wmsuites/wmsuite8-2_sp2/My_webMethods/8-2-SP1_CAF_JavaScript_Reference/CAF.Select.Model.html#indexOf

    Check if the item is selected:
    http://techcommunity.softwareag.com/ecosystem/documentation/webmethods/wmsuites/wmsuite8-2_sp2/My_webMethods/8-2-SP1_CAF_JavaScript_Reference/CAF.Select.Model.html#isSelected

    So your script should be something like this:

    var radioGroupModel = CAF.model("#{caf:cid('htmlSelectOneRadio')}");    
    var itemOnIdx = radioGroupModel.indexOf('optOn');
    var itemOffIdx = radioGroupModel.indexOf('optOff');
    
    if(radioGroupModel.isSelected(itemOnIdx))  {  
    alert("On !!");  
    }
    
    if (radioGroupModel.isSelected(itemOffIdx)) { 
    alert("Off !!");  
    }

    #MWS-CAF-Task-Engine
    #webMethods
    #webMethods-BPMS


  • 5.  RE: selected option in a group radio

    Posted Thu July 11, 2013 02:28 PM

    Thanks Eric,

    The code is very logic, but when i click nothing happens, no alert !! ( i tested in chrome and IE)

    Do I have to set the item value or value of the 2 options ? or change the javascript event ?

    Thanks & regards


    #MWS-CAF-Task-Engine
    #webMethods
    #webMethods-BPMS


  • 6.  RE: selected option in a group radio

    Posted Thu July 11, 2013 02:32 PM

    Yes, the indexOf call is matching the ‘Item Value’ of the item, so your ‘Options’ need an Item Value


    #MWS-CAF-Task-Engine
    #webMethods
    #webMethods-BPMS


  • 7.  RE: selected option in a group radio

    Posted Thu July 11, 2013 02:34 PM

    Coool, tested and worked fine :slight_smile:

    thanks man :wink:


    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods


  • 8.  RE: selected option in a group radio

    Posted Mon September 29, 2014 11:05 AM

    Thank you for this post. It was very helpful for me.
    Regards,


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods