0

In xhtml Primefaces page, I search to get a widget's reference that represents a specific DialogFrameWork widget.

The problem is that this widget is generated dynamically using some Java code on J2EE JSF server and is not defined directly in xhtml file.

The only solution I see is to inspect the DOM after DialogFrameWork has been loaded.

Primefaces seems to generate a element in DOM.

Using JQuery, I can find this element.

In this element there exist 2 custom attributes that are

  1. data-widgetvar
  2. data-pfdlgcid

What are these attributes ?

Can I use them to get PrimeFaces widget ?

How ?

schlebe
  • 3,387
  • 5
  • 37
  • 50
  • I don't see these in the PrimeFaces showcase... And checking the **values** of these attributes should give you a good indication what they actually are (e.g. by setting a widgetVar in the xhtml and comparing the values. – Kukeltje Feb 22 '18 at 10:49
  • I see it in PrimeFaces showcase. This is not an attribute of but an attribute of
    element generated by PrimeFaces to represent DialogFramework. I can see it in clicking on "Inspect element" on Chrome browser.
    – schlebe Feb 22 '18 at 11:54
  • I knowhere mentioned `p:dialog`... I know `p:dialog` != dialogFramework. And it indeed is there when doing an 'inspect element' but not when you do a view-source. And when I take a quick look, my previous comments about how to check things (assuming you as a veteran PrimeFaces user knows what the widgetVar actually does...). It very, very simply is the value of the widgetVar attribute. So you can use it in a PF('...') to retrieve the widget. IF YOU DO IT IN THE RIGHT WINDOW. What the other attribute does is beyond my knowledge and for it I suggest to inspect the source in github – Kukeltje Feb 22 '18 at 12:05

1 Answers1

0

data-widgetvar attribute of DialogFrameWork widget represent a reference and can be used to get widget variable.

example:

 jQuery(".ui-dialog.ui-overlay-visible",window.parent.document)
     .each
         (function(nIndex)
             {
             var sWidgetName = $(this).attr('data-widgetvar');
             var wgDialog = window.parent.PF(sWidgetName);
             wgDialog.hide();
             });
tramex
  • 149
  • 6
  • Hmmm... just like I stated, but there was a 2nd attribute. What does that do? Nothing in this answer refers to that. So it is effectively not 'the' answer ;-) – Kukeltje May 18 '18 at 13:46