1
votes

Prerequisites:

  • JSF 2.1
  • Primefaces 5.2
  • Glassfish 3.1

User Story:

When clicking on a CommandButton, a Window should pop up.


Implementation:

commandbutton

<p:commandButton value="+"  actionListener="#{beanname.showDialogue}" />

bean

public void showDialogue() {
    RequestContext.getCurrentInstance().openDialog("/Dialogues/Dialogue");}

faces-config

<?xml version="1.0" encoding="UTF-8"?>

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
    version="2.1">
<application>
   <action-listener>org.primefaces.application.DialogActionListener</action-listener>
    <navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
    <view-handler>org.primefaces.application.DialogViewHandler</view-handler>
</application>

</faces-config>

The popup to open is placed in src/main/webapp/Dialogues


Outcome:

Outcome

When Clicking on the button the URL reloads from host/applicationname/ to host/applicationname/faces/[pagewherecommandbuttonis]


Question:

What am i (possibly) missing here, in order to get the popup working?

1
Your setup seems correct, only think i can think of is a wrong url to the dialogue xhtml - Emil Kaminski

1 Answers

0
votes

You must do this:

org.primefaces.context.RequestContext.getCurrentInstance().execute("PF('widgetName').show();");