Dialog Framework - Data issue

UI Components for JSF
Post Reply
yahampath
Posts: 8
Joined: 06 Aug 2014, 06:20
Location: Sri Lanka

15 Oct 2014, 06:01

hi all,
i tried to use primeface 5.1 "Dialog Framework - Data"(http://www.primefaces.org/showcase/ui/df/data.xhtml) example in my computer but it doesn't work i can't find out what is the problem here because i didn't add anything new and i only did copy codes from example and past it. im using jboss 6.2 EAP as my server and jsf 2.1.21.

data.xhtml

Code: Select all

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

    </h:head>
    <h:body>
        <h:form>
            <p:growl id="growl" showDetail="true" />
            <p:commandButton value="Select Car" icon="ui-icon-extlink" actionListener="#{dfView.chooseCar}">
                <p:ajax event="dialogReturn" listener="#{dfView.onCarChosen}" update="growl" />
            </p:commandButton>
        </h:form>
    </h:body>
</html>
DFView.java

Code: Select all

import javax.faces.bean.ManagedBean;
import org.primefaces.context.RequestContext;
import org.primefaces.event.SelectEvent;
 
@ManagedBean(name = "dfView")
public class DFView {
         
    public void chooseCar() {
        RequestContext.getCurrentInstance().openDialog("selectCar");
    }
     
    public void onCarChosen(SelectEvent event) {
//        Car car = (Car) event.getObject();
//        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Car Selected", "Id:" + car.getId());
//         
//        FacesContext.getCurrentInstance().addMessage(null, message);
    }
selectCar.xhtml

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">
     
    <h:head>
        <title>Cars</title>
                <style type="text/css">
            .ui-widget {
                font-size: 90%;
            }
        </style>
    </h:head>
     
    <h:body>
        <h:form>
            <p:dataTable var="car" value="#{dfCarsView.cars}">
                <p:column headerText="Id">
                    <h:outputText value="#{dfCarsView.cars}" />
                </p:column>
 
                <p:column headerText="Year">
                    <h:outputText value="#{dfCarsView.cars[1]}" />
                </p:column>
 
                <p:column headerText="Brand">
                    <h:outputText value="#{dfCarsView.cars[2]}" />
                </p:column>
 
                <p:column headerText="Color">
                    <h:outputText value="#{dfCarsView.cars[3]}" />
                </p:column>
            </p:dataTable>
        </h:form>
    </h:body>
     
</html>
DFCarsView.java

Code: Select all

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
 
@ManagedBean(name = "dfCarsView")
@ViewScoped
public class DFCarsView implements Serializable {
     
    private List<String[]> cars;
 
//    @ManagedProperty("#{carService}")
    //private CarService service;
     
    @PostConstruct
    public void init() {
        cars = new ArrayList<String[]>();
        String c[] = {"A","B","C","D"};
        cars.add(c);
    }

    public List<String[]> getCars() {
        return cars;
    }

    public void setCars(List<String[]> cars) {
        this.cars = cars;
    }
     
//    public void selectCarFromDialog(Car car) {
//        RequestContext.getCurrentInstance().closeDialog(car);
//    }
}
please help findout what is the problem here ASAP. :?: :roll:

thanks and best regaurds

yahampath
Posts: 8
Joined: 06 Aug 2014, 06:20
Location: Sri Lanka

15 Oct 2014, 07:12

Hi all,
I think i found what is the problem. So i add following code to faces-config.xml file and problem fixed.

Code: Select all

 <application>
        <action-listener>org.primefaces.application.DialogActionListener</action-listener>
        <navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
        <view-handler>org.primefaces.application.DialogViewHandler</view-handler>
    </application>


i think this code help to some one else. :D

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

15 Oct 2014, 08:43

Thanks, but this was already posted several times and is alzo in the documentation. And I was told by core pf members that this would be explicitly added in the showcase with 5.1. Maybe it got postponed to 5.2

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 41 guests