Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page jsf into dialog not working

I try to folow exemple from primefaces site .using Dialog Framework - Basic

    <p:commandButton value="Options" icon="ui-icon-extlink" action="#{dialogBean.viewCarsCustomized}" />

Bean DialogBean

public class DialogBean {

public String viewCarsCustomized() {  
    return "dialog:viewCars?modal=true";  
}  

}

viewCars.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"  
    xmlns:h="http://java.sun.com/jsf/html"  
    xmlns:f="http://java.sun.com/jsf/core"  
    xmlns:ui="http://java.sun.com/jsf/facelets"  
    xmlns:p="http://primefaces.org/ui">  

    <h:head>  

    </h:head>  

    <h:body>  
        <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:dataTable>  
    </h:body>  

</html> 

this is My exemple on My Bean . I Try like this

public String viewComposant(){
        return "dialog:AjoutC?modal=true"; 
    }

it is not working,I try to do like this .but every time error

Impossible de trouver un cas de navigation correspondant depuis l'ID de vue '/pagess/Parsing/ReacgModule.xhtml' pour l'action '#{parserXls.viewComposant()}' avec le résultat 'dialog:/pagess/pagesComposant/AjoutC.jsf?modal=true'.

public String viewComposant(){
        return "dialog:/pagess/pagesComposant/AjoutC.jsf?modal=true"; 
    }

But When I do like this the page returend but not as I like

public String viewComposant(){
            return "/pagess/pagesComposant/AjoutC.jsf"; 
        }
like image 566
Adriano_jvma Avatar asked May 21 '13 13:05

Adriano_jvma


1 Answers

3.5 version of primefaces

The dialog: navigation outcome prefix from "Dialog Framework" is introduced in PrimeFaces 4.0 and don't work in older versions.

So, you've 2 options:

  1. Upgrade to PrimeFaces 4.0 (note: it's currently still in beta)
  2. Use the "old" approach of dialogWidgetVar.show() in JavaScript or visible="#{someCondition} in JSF. See also the <p:dialog> examples in PrimeFaces showcase.

Update: as per the comment, here's how you could use it with widgetVar approach in JS:

<p:button value="Open dialog" onclick="w_dialog.show(); return false;" />
<p:dialog widgetVar="w_dialog">
    <p>Dialog's content.</p>
<p:dialog>

And here's how you could use the visible approach in JSF:

<h:form>
    <p:commandButton value="Open dialog" action="#{bean.showDialog}" update=":dialog" />
</h:form>
<p:dialog id="dialog" visible="#{bean.showDialog}">
    <p>Dialog's content.</p>
<p:dialog>

with

private boolean showDialog;

public void showDialog() {
    showDialog = true;
}

public boolean isShowDialog() {
    return showDialog;
}

You can if necessary move <p:dialog> into an include file which you include by <ui:include>.

like image 162
BalusC Avatar answered Oct 14 '22 04:10

BalusC