samedi 28 février 2015

JSF Probleme mit Data Table

Hallo liebes Forum ich habe eine Frage warum bei mir das nicht funktioniert:



Also ich habe eine einfache Data Table erzeugt.



<?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/nuHeHq;

<html xmlns="http://ift.tt/rO9lWA;

xmlns:h="http://ift.tt/1x2KsZ1;

xmlns:f="http://ift.tt/1AmiKIo;

xmlns:p="http://ift.tt/1z85qfZ;

<h:head>

<title>Facelet Title</title>

</h:head>

<h:body>

<h:form id="form">



<p:dataTable var="p" value="#{Bean.pers}">

<p:column headerText="Vorname">

<h:outputText value="#{p.getvName}" />

</p:column>



<p:column headerText="Nachname">

<h:outputText value="#{p.getnName}" />

</p:column>



<p:column headerText="Alter">

<h:outputText value="#{p.alter}" />

</p:column>





</p:dataTable>

</h:form>

</h:body>

</html>







Die dazugehörigen anderen Files:

Bean.java // zu Testzwecken so bennant:



/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package test;



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.ManagedProperty;

import javax.faces.bean.ViewScoped;



/**

*

* @author Christian

*/

@ManagedBean(name = "Bean")

@ViewScoped

public class Bean implements Serializable{

private List<Person> pers;



@ManagedProperty("#{PersService}")

private PersService service;



@PostConstruct

public void init() {

pers = service.createList();

}



public List<Person> getPers() {

return pers;

}



public void setService(PersService service) {

this.service = service;

}



}



PersonService.java:



/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package test;



import java.util.ArrayList;

import java.util.List;

import javax.faces.bean.ApplicationScoped;

import javax.faces.bean.ManagedBean;



/**

*

* @author Christian

*/



@ManagedBean(name = "carService")

@ApplicationScoped

public class PersService {



public List createList()

{

List retVal= new ArrayList();



retVal.add(new Person("Hans", "Wurst", 18));

retVal.add(new Person("Peter", "Schlesinger", 18));

retVal.add(new Person("Albert", "Einstein", 18));

retVal.add(new Person("Max", "Mustermann", 18));



return retVal;

}



}



Person.java:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package test;



import java.util.ArrayList;

import java.util.List;



/**

*

* @author Christian

*/

public class Person {



String vName, nName;

int alter;



public Person(String vName, String nName, int alter) {

this.vName = vName;

this.nName = nName;

this.alter = alter;



}







public String getvName() {

return vName;

}



public void setvName(String vName) {

this.vName = vName;

}



public String getnName() {

return nName;

}



public void setnName(String nName) {

this.nName = nName;

}



public int getAlter() {

return alter;

}



public void setAlter(int alter) {

this.alter = alter;

}



}





Die Fehlermeldung die Ausgegeben wird ist :



Bei der Ressourcen-Einspeisung auf dem verwalteten Bean Bean ist ein Fehler aufgetreten.





JSF Probleme mit Data Table

0 commentaires:

Enregistrer un commentaire