Results 1 to 2 of 2

Thread: Abstract classes and bean definitions

  1. #1
    Join Date
    Mar 2005
    Posts
    4

    Default Abstract classes and bean definitions

    I’m new to Spring and have run into a problem with some of my bean definitions. I have the following classes:

    Code:
    public class User {
    	
       private UserType userType = null;
    
    	public User (UserType userType) {
    		this.userType = userType;
    	}	
            public UserType getUserType() {
    		return userType;
    	}
    	public void setUserType(UserType type) {
    		userType = type;
    	}
    }
    
    public abstract class UserType {
    	//some abstract methods;
    }
    public abstract class Customer extends UserType {
    	//some abstract methods;
    }
    public class Staff extends UserType {
    	public Staff() {}	
    }
    public class Business extends Customer {
    	public Business() {}	
    }
    public class Individual extends Customer {
    	public Individual () {}	
    }
    I was hoping to use the User object on my JSP’s so that I can access some common attributes in the following manner:
    Code:
    <spring&#58;bind path="user.userType.someCommonAttribute">
    but I’m running into problems because UserType is abstract.

    I read the Spring reference guide section on Abstract and Child Bean Definitions, but I’m not sure how to define the User and UserType beans since UserType is an abstract class and also an attribute of User. I was looking into bean factories, but I’m not sure if that is the right approach. I would think this would be a fairly common issue, but didn’t have any luck finding answers when I searched the forums. Does anyone have any advice? Thanks in advance.

  2. #2
    Join Date
    Nov 2004
    Location
    St. Louis, Missouri USA
    Posts
    33

    Default

    have a look in the docs regarding Abstract and child bean definitions

Similar Threads

  1. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  2. Circular Dependencies
    By samokk in forum Container
    Replies: 4
    Last Post: Aug 4th, 2005, 12:38 PM
  3. Replies: 1
    Last Post: Jul 28th, 2005, 05:08 PM
  4. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  5. Replies: 7
    Last Post: Oct 6th, 2004, 02:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •