All posts tagged id

  • Get widgetVar by Id

    I have many cases in my apps where I needed to get the widgetVar object in Javascript by the component Id.
    I have made this helpful function in order to achieve that goal .

    function getWidgetVarById(id) {
        for (var propertyName in PrimeFaces.widgets) {
          if (PrimeFaces.widgets[propertyName].id === id) {
            return PrimeFaces.widgets[propertyName];



    This will return the object, in the previous case a dialog widgetVar object is returned, to show it simply call show()  right away.


    – Conclusion

    All the widgetVars are stored in the PrimeFaces.widgets. namespace.
    Iterating over that namespace and comparing the given Id with the object’s is the way to find your widgetVar.

    Note: this equals to the expression  #{p:widgetVar(‘form:dialogId’)}  (Server-side evaluation)