webMethods

webMethods

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.

 View Only
Expand all | Collapse all

Binding expression error

  • 1.  Binding expression error

    Posted Tue August 16, 2016 11:11 AM

    Hi All,

    I want to do an interesting thing and up to now did not find any solution to solve it.

    I want to set the focus property of an element.
    Given a simple image object with a clientside click event setfocusitem(‘elementid’);

    There is a script block on page to handle this click event.
    Here is my javascript code:

    
    function setfocusitem(item){
    setTimeout(function() {   
    var elem = CAF.model("#{activePageBean.clientIds['"+item+"']}");  
    elem.setFocused(true);
    }, 1000);
    }

    It gets binding expression error.
    My question is that, how to concatenate the correct expression string in javascript.
    I want to use this javascript function from page, from more controls with different parameter, so it means the parameter ‘elementid’ is always different.

    Many thanks for your help.

    Zsolt


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


  • 2.  RE: Binding expression error

    Posted Sun December 11, 2016 07:17 AM

    HI Zsolt,

    It is not possible to concatenate the binding expression once it is loaded. The state of binding expression will change to a static element ID.
    A binding expression is parsed before they are loaded and only the resultant value is displayed on UI.

    Not the best approach, but a workaround to your requirement is as below.

    var desiredID = "htmlInputText";
    var currButton = 'htmlCommandButton'
    var eleStr = "#{activePageBean.clientIds['htmlCommandButton']}";
    var dynamicID = eleStr.replace("htmlCommandButton", "htmlInputText")
    alert(eleStr);
    var ele = document.getElementById(dynamicID); 
    alert(ele.value);

    Here, once the binding expression is loaded to the neighbouring element, you can update the ID portion of it to point the desired element. This ID string will change depending on the hierarchy on the element position in the CAF screen.


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