Software interface

I want to dynamically create a punch dialog from a backup bean. I wrote the code above:

public void showDialog(){
    UIComponent panelGroup = facesContext.getViewRoot().findComponent("form1");
    System.out.println("found or not??"+ panelGroup.toString());
    Dialog dialog = new Dialog();
    dialog.setId("sample");
    dialog.setWidgetVar("widget");
    dialog.setHeader("Sample");
    dialog.setVisible(true);
    dialog.setMinimizable(true);

    dialog.setDynamic(true);
    dialog.setHideEffect("fade");
    dialog.setFooter("footer");

    dialog.setDraggable(true);
    dialog.setMinWidth(600);
    dialog.setClosable(true);
    dialog.setModal(true);
    dialog.setAppendToBody(false);

    panelGroup.getChildren().add(dialog);

    RequestContext requestContext = RequestContext.getCurrentInstance();
    requestContext.openDialog("widget");
    requestContext.update("form1");
}

and on my jsf page: I have

 <h:form id="form1" >
        <h:commandButton value="show Dialog" action="#{createDialog.showDialog()}" />

 </h:form>

The problem is that when I set it to visible, I got a dialog, but neither can I close (I do not get the close icon and I can not drag it)!

+4
source share
1 answer

You need to replace this line:

requestContext.openDialog("widget");

:

requestContext.execute("PF('widget').show()");     

The RequestContext.openDialog () method refers to the Primefaces API, which is different from the p: dialog component.

From the interface guide:

A dialog box (DF) is used to open an external xhtml page in a dialog that is dynamically generated at run time.

, RequestContext.openDialog() , xhtml .

p: dialog javacript api show() hide() .

+3

All Articles