jsf - Hide all primefaces blockui elements -
i have lot of .xhtml views. many of them have blockui elements, example:
<p:blockui block="tab" widgetvar="subscriberselectblocker"> </p:blockui> sometimes there more 1 of them per view. hide blockui above have method in according bean subscriberfilterbean.java:
public void hidesubscriberselectblockui() { requestcontext.getcurrentinstance().execute("subscriberselectblocker.hide()"); } now problem need hide existing blockuis @ once. hide them individually above, mean have same code repeated on 15 times , method execute these methods huge.
is there way hide elements of tag? like
public void hidesubscriberselectblockui() { requestcontext.getcurrentinstance().execute("p:blockui.hide()"); }
when specifying widgetvar in primefaces element, javascript widget object instantiated , assigned global variable specified name in window scope. means objects found , manipulated.
i suggest finding them blockui ids. widget object contains it's id, after obtaining global objects , blockui ids page, can determine of global objects blockui widgets. blockui ids page obtained using jquery class selector, have common css style: .ui-blockui.
here javascript example code shows blockui components on page:
var keys = object.getownpropertynames( window ); var blocks = $('.ui-blockui'); var blockids = []; blocks.each (function (index,value) { blockids[index] = value.id; }); $.each(keys, function (index, value) { var obj = window[ value ]; if (obj != null) { gobj = window[ value ]; if(gobj.blocker != undefined) { if ($.inarray(gobj.blocker.attr('id'), blockids) != -1) { gobj.show(); } } } });
Comments
Post a Comment