Results 1 to 1 of 1
- 04-02-2011, 02:55 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 1
- Rep Power
- 0
Out-Abstracted Myself: Creating Uniform JSP for classes extending Abstract parent
I am working with Spring Roo for a web project.
I am implementing a Clothes management system that tracks sizes. Because there are different ways of measuring size: Small-Medium-Large, 00-0-2-4-6, Petite-Small Petite-etc, I decided to create an Abstract SizeType class.
I then have subclasses extend it with their own measurement fields. For example, the small medium large type looks like this:Java Code:public abstract class SizeType { private String noteCode; private Date dateCreated; }
The Size Range is a class that just holds a couple of floats for expressing a range:Java Code:public class SizeSML extends SizeType { private SizeRange sizeS; private SizeRange sizeM; private SizeRange sizeL; }
The problem I am now getting into is creating the JSP interface for populating this object. The SizeChart class contains the SizeType and that is the entry point.Java Code:public class SizeRange { @NotNull private Float minVal; private Float maxVal; }
My JSP populates all of the SizeChart fields, accesses the SizeType field... and then what? I was originally trying using getClass() on the instance to find out what type of size chart, then using getFields to find out which SizeRange variables were there, but it is just turning into a big mess.
I want some way to enforce the integrity of the chart without hard-coding the values into the JSP. If I create extra subclasses of SizeType I'd like this uniform JSP to be able to populate a form for entering the measurements in dynamically.
Is Abstract the wrong way to go here? Should I instead create an Interface that provides an Iterator across the different data types maybe?
Any thoughts are appreciated.
Similar Threads
-
I'm having trouble with extending classes
By ziongio in forum New To JavaReplies: 2Last Post: 03-15-2011, 07:33 AM -
Abstract Classes??? Creating a new object????
By jonytek in forum New To JavaReplies: 2Last Post: 03-07-2011, 03:34 AM -
Problems adding new method to an extending abstract class
By harukia in forum New To JavaReplies: 1Last Post: 12-17-2010, 09:24 AM -
Extending Classes and What is Necessary
By GavinCash in forum New To JavaReplies: 10Last Post: 10-11-2010, 07:07 AM -
Got confused with extending classes.
By nethz13 in forum New To JavaReplies: 7Last Post: 04-19-2010, 12:19 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks