1

I have a JSF page which works with a ViewScoped managed bean, that page requires an viewParam which is passed from URL.

I'm using Primefaces 4.0, and I want to know if there's a way to use that xhtml page inside a p:dialog and then pass some param to it.

From where I want to summon that dialog is a different page with a different bean, ViewScoped too.

My dialog actually looks like this:

    <p:dialog widgetVar="w_dialogAgregarInfo">
        <h:form id="dialogAgregarInfo">
            <p:tabView id="tabView">   
                <c:forEach items="#{iniciarProcesoController.mfuncionesAsociadas}" var="mFuncion" varStatus="loop1">      
                    <p:tab id="t_funcion_#{loop1.index}" title="#{mFuncion.nombre}" titleStyle="font-size:15px;font-style: normal;font-weight: normal">
                        <f:subview id="tab_#{loop1.index}">
                            <o:massAttribute target="javax.faces.component.UIInput" name="disabled" value="#{mFuncion.soloLectura}">
                                <p:panelGrid id="pg_funcion_#{loop1.index}" style="margin: 0 auto; box-shadow: none; width: 100%">
                                    <ui:include src="#{mFuncion.paginaFuncion}"></ui:include>
                                </p:panelGrid>
                            </o:massAttribute>
                        </f:subview>
                    </p:tab>
                </c:forEach>
            </p:tabView>
        </h:form>
    </p:dialog>

And I'm calling this dialog as I usually do: just tell it to show.

<p:commandButton value="Agregar información" oncomplete="w_dialogAgregarInfo.show()"/>

But it show empty, pretty sure that I need to initialize the dialog's controller somehow, but I have no idea how to achieve that, any help would be apreciated, Thanks!!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Yayotrón
  • 1,759
  • 16
  • 27
  • How are you calling this p:dialog? – kosa Aug 12 '15 at 16:22
  • Added that to the question. I'm calling it when a button is clicked, just show it. – Yayotrón Aug 12 '15 at 16:24
  • Not sure why you mention ViewScoped, the dialog has all the same contexts as the view. It's part of the same view. Maybe you just need `update=":dialogAgregarInfo"` in the button that opens the dialog. Dialog Framework is probably not needed here, see http://stackoverflow.com/a/26507691/1341535. – Vsevolod Golovanov Aug 14 '15 at 10:56

3 Answers3

2

How do I pass parameters to DialogFramework?

Create a map with your parameters:

      Map<String, List<String>> params = new HashMap<String, List<String>>();
        List<String> values = new ArrayList<String>();
        values.add("value1");
        values.add("value3");
        params.put("paramKEy", values);

Then call

  RequestContext.getCurrentInstance().openDialog("yourxhtmlpath", options, params);

Here is one nice example, primefaces dialog framework.

kosa
  • 65,990
  • 13
  • 130
  • 167
1

You may use DialogFramework

It allows you to call any xhtml by using something like :

RequestContext.getCurrentInstance().openDialog("anyPage", options, params);

where "anyPage" match your "anyPage.xhtml" page name, options are a set of properties given to the dialog. It takes a Map<String,Object> like the following:

Map<String, Object> options = new HashMap<>();
options.put("modal", "true");
options.put("draggable", "false");
options.put("resizable", "false");
options.put("position", "top");
options.put("dynamic", "true");
options.put("appendTo", "@(body)");

And params are the parameters that the page receives, it takes a Map<String, List<String>> params = new HashMap<>();

List<String> values = new ArrayList<>();
values.add("exampleValue");
params.put("exampleParam", values);
Yayotrón
  • 1,759
  • 16
  • 27
Karbos 538
  • 2,977
  • 1
  • 23
  • 34
0

You can extend your bean class to have the same funcionality with another bean name.

Ruben Lins
  • 11
  • 2