Primefaces widget: how to check inheritance relationship like java instanceof?

Viewed 25

Primefaces widget: how to check inheritance relationship like java instanceof?

WidgetA
   |
WidgetB
   |
WidgetC

How to check if a widget is instance of any widget type in a hierarchy? like java instanceof.

How to determine if a widget type is subtype of another widget type?

1 Answers

You can do it the old fashioned way using instanceof in JavaScript...

    // stop any PF pollers and idle monitors
    for (item in PrimeFaces.widgets) {
        widget = PrimeFaces.widgets[item];

        // stop all pollers
        if (widget instanceof PrimeFaces.widget.Poll) {
            widget.stop();
        }

        // stop idle monitor
        if (widget instanceof PrimeFaces.widget.IdleMonitor) {
            widget.pause();
        }
    }
Related