I know there are plenty of questions about this topic, but none could help me.

I just want to open a dialog via my managed bean because I need a plain object to work on, so I wanted an actionListener, which produces a new object and then opens the dialog.

Problem: It does not work. Why? I do not know.

I do not get any error in any console. No JS-errors, nothing in my Tomcat-Console, nothing in his logs. And I am very, very sure it should work this way.

Here is what I made:

The "add"-Button:

```
<p:outputPanel style="float:right">
<p:commandButton value="Hinzufügen" icon="ui-icon-plusthick"
    actionListener="#{lessonTypeController.addLessonTypeDialog}" />
</p:outputPanel>

```

The actionListener looks as follows:

```
public void addLessonTypeDialog() {

    lessonType = new LessonType();
    lessonType.setTypicalDuration(getTypicalDuration());
    RequestContext context = RequestContext.getCurrentInstance();
    context.execute("PF('addLessonTypeDialog').show()");

}

```

And the dialog that should be opened (but does not want to):

```
<p:dialog header="Add a lessontype"
    id="addLessonTypeDialog" widgetVar="addLessonTypeDialog"
    minHeight="600" modal="true" draggable="false" resizable="false">
    <p:ajax event="close" update="@form" />
    <p:outputPanel>
        ... Some content which works fine if dialog is called different
    </p:outputPanel>
</p:dialog>

```

The dialog is placed in the same xhtml-page as the calling button.

I really don't know why this does not work. As I said I am really, really sure it is correct this way. Also no errors. Just not a single reaction when I click the button.

Everything else works fine, I also use dialogs which are in own xhtml-pages, which works fine, but has to be refactored now, because I need the close-event to update the form.

If I call the dialog directly via JS (like I did in the bean, just with an onlick-event for the button) it works, but I get problems because the actionListener is not fast enough to produce a new object before the JS has already shown the dialog what results in errors and NullPointerExceptions.

Please help me, this is for an important project in school I have to finish alone due to my mates doing nothing and I really don't know what to do.