Women in Technology

Hear us Roar



Article:
  Java Web Development with Stripes
Subject:   Code typo?
Date:   2007-01-25 11:08:32
From:   garthabrindoid
Is the code for HelloWorldAction in the first code snippet correct? I'm confused about how this part in particular:



private Person person;


...


public void setPerson(String person) {this.person = person;}
public String getPerson() { return person;}


Judging by the setter and getter, person should be a String and not a Person, right? Or are the getter and Setter wrong?

Full Threads Newest First

Showing messages 1 through 3 of 3.

  • Code typo?
    2007-01-25 11:41:14  mjeagle [View]

    Sorry, the field is of type Person and the accessors should look like this:


    public void setPerson(Person person) {this.person = person;}

    public Person getPerson() { return person;}

    Sorry for the confusion.



    Mark
    • Code typo?
      2007-03-13 22:39:37  keytasks [View]

      I tried the correction - you suggested though I'm getting 'cannot find symbol error' in my IDE editor on the following line of code - as well as the getter and setters


      private Person person;


      The article looks great - I'm hoping to get the article working with Spring1.4.2 with NetBeans5.5


      Thanks Derek







      • Code typo?
        2007-03-14 05:46:50  mjeagle [View]

        Here is the code for the Person class:

        package com.meagle.blog.domain;

        /**
        * Simple Person object
        *
        * User: meagle
        * Date: Jan 7, 2007
        * Time: 8:55:47 PM
        */
        public class Person {

        private int id;
        private String firstName;
        private Integer age;

        public int getId() {
        return id;
        }

        public void setId(int id) {
        this.id = id;
        }

        public String getFirstName() {
        return firstName;
        }

        public void setFirstName(String firstName) {
        this.firstName = firstName;
        }

        public Integer getAge() {
        return age;
        }

        public void setAge(Integer age) {
        this.age = age;
        }
        }