I'm trying to get a primefaces data list working and not sure I'm doing this correctly, having a problem with getting this view to display. Here is my xhtml ...
And the supporting code ...<f:view> <p:scrollPanel id="cclist" header="CCList" styleClass="cc-log"> <p:dataList value="contactController.contacts" var="contact" type="ordered"> <f:facet name="header"> Call List </f:facet> #{contact.firstName}, #{contact.lastName} </p:dataList> </p:scrollPanel> </f:view>
@EJB(name="ejb/ContactBean", beanInterface=IContact.class) @ManagedBean(name="contactController") @ViewScoped public class ContactController { private IContact icontact; private List<Contact> contacts; public ContactController() { try { icontact = (IContact) (new InitialContext()).lookup("java:comp/env/ejb/ContactBean"); } catch (Exception e) { e.printStackTrace(); } } public List<Contact> getContacts() throws Exception { try { contacts = icontact.getContacts(); } catch (Exception e) { } return contacts; } } @Stateless public class ContactBean implements IContact { @PersistenceContext(unitName="contactbean-pu") private EntityManager em; private List<Contact> contacts; public List<Contact> getContacts() { try { contacts = (List<Contact>) em.createNamedQuery("Contact.findAll").getResultList(); } catch (Exception e) { throw new EJBException(e.getMessage()); } return contacts; } } @Entity @SequenceGenerator(name="contactIdGen", initialValue=1000, sequenceName="contact_seq", allocationSize=1) @NamedQuery(name="Contact.findAll", query="SELECT c FROM Contact c") @Table(name="contact") public class Contact implements Serializable { @Id @Column(name="id") @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="contactIdGen") private Integer id; @Column(name="first") private String first; @Column(name="last") private String last; @Column(name="phone") private String phone; public Contact() { } public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } public String getFirstName() { return this.first; } public void setFirstName(String first) { this.first = first; } public String getLastName() { return this.last; } public void setLastName(String last) { this.last = last; } public String getPhone() { return this.phone; } public void setPhone(String phone) { this.phone = phone; } }
The error output to the console is ...
Error Rendering View[/users/index.xhtml] javax.el.ELException: /users/index.xhtml: The class 'java.lang.String' does not have the property 'firstName'. at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:88) at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82) at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:67) ...