Primefaces 5.0 widgetvar dialog box

I am building a website using web interfaces 5 and wildfly server. I have a problem using a component. I have in each line as follows. Button defined an actionlistener property that calls the bean method support, and after that it should display a dialog box. Here is the code:

<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:pt="http://java.sun.com/jsf/composite/components" template="../templates/mainTemplate.xhtml"> <ui:define name="title"></ui:define> <ui:define name="main-content"> <h:form> <p:dataTable id="dataTable" value="#{bean.list}" var="item" styleClass="hide-column-header small-text"> <!-- some columns --> <p:column style="width: 18%; text-align: center;"> <p:commandButton value="Open dialog" actionListener="#{bean.buttonListener(item)}" oncomplete="PF('dlg').show();"/> </p:column> </p:dataTable> </h:form> <p:dialog id="dialog" widgetVar="dlg" resizable="false" modal="true" header="Dialog"> <h:form> <!-- some inputs --> </h:form> </p:dialog> </ui:define> </ui:composition> 

But it does not work. I check the chrome console and get the message "Widget for var" Widget for var 'dlg' is unavailable! "when I clicked on a button, so I checked" Primefaces.widgets "and there really is no widget for my dialog. Can someone help me with this?

//edit
Ok, I’ll finally get back to work. As a result of trial and error, I found this line in my template:

 <script type="text/javascript" src="//code.jquery.com/jquery-2.1.1.min.js"></script> 

After the deletion, it all started as planned. I think this is due to the fact that price lists have their own version of jquery?

+6
source share
1 answer

Primefaces already has jQuery, so it is highly recommended not to use another jQuery library when working with Primefaces.

Try removing the external jQuery library and invoking the dialog with the PF command ('dlg'). show ();

You can check this and other changes in the migration guide: https://code.google.com/p/primefaces/wiki/MigrationGuide

+5
source

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


All Articles