0

Helo,

I would like to ask primefaces dialog related question.

PrimeFaces-4.0-SNAPSHOT contains new Dialog Framework that enables you to dynamically generate dialog if you return action outcome pretended with dialog:. http://www.primefaces.org/showcase/ui/dialogFrameworkData.jsf
As I understand it takes outcome and renders it as auto generated dialog contents.

Because Primefaces 4.0 is going to take some time to complete, I was wondering if similar functionality is achievable in some other way. By similar functionality I mean showing (or rendering to) another view in dialog.

Project I am currently working on is hugely dynamic, based mostly on BPM and ability to show dialogs with dynamic content would be very useful.

UPDATE: I have been investigating Primefaces repository myself and found revision with POC dialog framework implementation: https://code.google.com/p/primefaces/source/detail?r=8808

Thanks.

1 Answers1

0

Yes. You could use jQuery UI dialogs

The usage is pretty simple. Let's say you have a <h:panelGroup> whose content you wish to display in the dialog, then you could re-render this panelGroup first and then call the dialog() method on it.

 <h:panelGroup id="dialogContainer" styleClass='dialog'>  
        <p:dataTable var="car" value="#{tableBean.carsSmall}">  
            <p:column headerText="Model">  
                <h:outputText value="#{car.model}" />  
            </p:column>  

            <p:column headerText="Year">  
                <h:outputText value="#{car.year}" />  
            </p:column>  

            <p:column headerText="Manufacturer">  
                <h:outputText value="#{car.manufacturer}" />  
            </p:column>  

            <p:column headerText="Color">  
                <h:outputText value="#{car.color}" />  
            </p:column>  

            <p:column headerText="Color">  
                <p:commandButton icon="ui-icon-search" actionListener="#{tableBean.selectCarFromDialog(car)}" />  
            </p:column>  
        </p:dataTable>  
    </h:panelGroup>  

And on click of a button you first need to re-render dialogContent and then call $('.dialog').dialog(); (please read the API for complete set of params to dialog())

But I'm not really sure what do you mean by

Because Primefaces 4.0 is going to take some time to complete

Do you mean that the framework itself will take time to reach final stage or the learning curve is steep? If it's the former, using jQuery UI dialogs makes sense. If it's the latter, I don't think taking any other approach would be faster! Anyway, hope this helps :)

UPDATE: Actually, you could just re-render the contents rather than the container itself. So in this example you can re-render the p:dataTable rather than the container.

Niks
  • 4,802
  • 4
  • 36
  • 55
  • Yes, by `is going to take some time to complete` i meant framework itself will take time to reach final stage and we can't use beta versions on production level software. – Pavel Jakovlev May 07 '13 at 07:02
  • I have never used jQuery before, so I haven't thought about it, so your suggestion is good, but what if I want to render, lets say same `panelGroup`, but it is defined in separate `xhtml` file. Only way I can think of is utilizing `iframe` in some way.. – Pavel Jakovlev May 07 '13 at 07:09
  • @PavelJakovlev Woah there..I think you need to get your `JSF` basics right first. A simple `` within your `panelGroup` would do that. No `iframe` required. – Niks May 07 '13 at 08:18
  • ok, but `` is just basic templating mechanism, if I rerender `panelGroup` with `include` inside it will create my view scoped bean for that page, but I correct me if I am wrong, it will not call `` method, nor I have any way of passing any `GET` parameters to that page. My case is that I would like to put fully functional, separate `view` into the dialog on my parent page, there can be no coupling of pages or managed beans, because there might be some case, where I would need to show my child view as standalone page. – Pavel Jakovlev May 07 '13 at 12:31
  • Umm I think `preRenderView` will be fired. Because it is fired after view parameters have finished processing, but before the view is rendered. And for the GET params, refer to this http://stackoverflow.com/questions/5291181/jsf-1-2-uiinclude-with-parameters – Niks May 08 '13 at 05:23