Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: help rendering view

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help rendering view

    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 ...
    <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>
    And the supporting code ...
    @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)
    ...


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: help rendering view

    The naming of the accessor methods is critical and must coincide with the names of the properties, following the naming convention. Check the names of the properties and the names of the accessor methods and correct those that do not follow the naming convention.

Similar Threads

  1. Game rendering
    By Whoameye2u in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 20th, 2013, 03:33 PM
  2. Images not rendering?
    By deathman12e3 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 24th, 2013, 08:07 PM
  3. [SOLVED] 3D rendering?
    By kaskoepoes112 in forum Java Theory & Questions
    Replies: 7
    Last Post: June 10th, 2013, 07:59 AM
  4. [SOLVED] JSF? not rendering.
    By newbie in forum Web Frameworks
    Replies: 2
    Last Post: March 21st, 2011, 08:45 PM
  5. JMonkeyEngine 3 not rendering.
    By scribbleno1 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 13th, 2010, 02:29 AM