简体   繁体   中英

Can Primefaces dialog framework display xhtml from an external domain?

when I read about the Primefaces Dialog Framework (DF), which is " used to open an external xhtml page in a dialog ", I assumed this meant you could display xhtml from another domain.

If this is the case, how can I give an absolute url to the method... requestContext.getCurrentInstance().openDialog(outcome) ?

These don't seem to resolve.

If this is not the case, then what is the purpose/advantage of the DF? If I can only display xhtml from within the same app, why not just use the declarative <p:dialog> component? It can be put inside a <ui:composition> if you want to reuse a dialog from multiple pages, for instance.

OpenDialog enables the page author to open an xhtml referenced via a JSF navigation outcome in a dialog, the options are the configuration attributes for dialog like modal, draggable and finally the optional params are the view params to pass parameters to the dialog.

Actually the PrimeFaces blog entry referring to that means to use an internal application view outcome for the dialog to refer to. That bounds the path to your application JSF navigation cases.

Then what's the advantage of the dialog framework? I would say, bringing you the ability to specify the outcome and the dialog attributes at runtime. Let's say you have a car table, where you open a detail dialog when user clicks on one row. Suposing you need to display different content depending on car's branch, it would be easy to control what is going to be rendered inside the dialog:

String outcome = "dialogs/genericCar";
if (car.getBranch.equals("Ferrari")){
    outcome = "dialogs/ferrariCar";
}
else if (car.getBranch.equals("Aston Martin")){
    outcome = "dialogs/astonCar";
}
RequestContext.getCurrentInstance().openDialog(outcome);

Doing that would be so clean an straight forwarded. Otherwise with the classing p:dialog tag you're limited to a single dialog with conditional rendering inside depending on the content you want to display.

The chance of being able to change the dialog attributes depending on what you want to render seems interesting too.

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM