Show growl using Javascript

I want to show a growl on the client side using Javascript.

I mean this UI component:

enter image description here

I found this thread . However, I cannot find an object named: topBar

It is also known that using:

grep -rl , to find the text in the files, will lead to the detection of this JS:

 /** * PrimeFaces NotificationBar Widget */ PrimeFaces.widget.NotificationBar = PrimeFaces.widget.BaseWidget.extend({ init: function(cfg) { this._super(cfg); var _self = this; //relocate this.jq.css(this.cfg.position, '0').appendTo($('body')); //display initially if(this.cfg.autoDisplay) { $(this.jq).css('display','block') } //bind events this.jq.children('.ui-notificationbar-close').click(function() { _self.hide(); }); }, show: function() { if(this.cfg.effect === 'slide') $(this.jq).slideDown(this.cfg.effect); else if(this.cfg.effect === 'fade') $(this.jq).fadeIn(this.cfg.effect); else if(this.cfg.effect === 'none') $(this.jq).show(); }, hide: function() { if(this.cfg.effect === 'slide') $(this.jq).slideUp(this.cfg.effect); else if(this.cfg.effect === 'fade') $(this.jq).fadeOut(this.cfg.effect); else if(this.cfg.effect === 'none') $(this.jq).hide(); }, isVisible: function() { return this.jq.is(':visible'); }, toggle: function() { if(this.isVisible()) this.hide(); else this.show(); } }); 
+6
source share
1 answer

The component you are referring to is Growl, on the client side it is represented by PrimeFaces.widget.Growl , which has a renderMessage function to render a single growl word.

Assuming you already defined the growl component on your page named widgetVar:

 <p:growl widgetVar="growlWV" /> 

Now in javascript

 PF('growlWV').renderMessage({"summary":"summary goes here", "detail":"detail goes here", "severity":"warn"}) 

Severity is obviously of three types:

  • Information

    info growl

  • will warn

    warn growl

  • Error

    error growl

+26
source

Source: https://habr.com/ru/post/974341/


All Articles