velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ChadDavis <chadmichaelda...@gmail.com>
Subject iteration over a list broke from 1.4 - 1.6
Date Wed, 18 Feb 2009 00:03:59 GMT
This is interesting.  I just migrated from 1.4 to 1.6 and broke an
existing template.

That template iterated over a List returned by an Enum object.  The
following pseudo code shows what I'm doing.  Note, the getter that
returns the list
is an abstract member of the Thing enum.  Each of the defined
instances of this enum implement it.  This worked on velocity 1.4, but
doesn't on 1.6.  To get it to work on 1.6, I had to change the
abstract method to a normal method that each of the enum's override.
It guess this is some sort of reflection API issue.    Seems like it
should work as it did before to me.  Thoughts?


public enum Thing {

	    NUMBER_ONE(  ){
			public List<String> getInnerThings() {
				//initialize innerThings if this is first time
				if ( this.innerThings == null ) {
					innerThings = new ArrayList<String>();	
					innerThings.add( "blah blah" );
					innerThings.add("blah blah"  );
					
				}
				return innerThings;
			}
		},
		 NUMBER_TWO(  ){
			public List<String> getinnerThings() {
				//initialize innerThings if this is first time
				if ( this.innerThings == null ) {
					innerThings = new ArrayList<String>();	
					innerThings.add( "blah blah" );
					innerThings.add("blah blah"  );
					
				}
				return innerThings;

			}
		},
		 NUMBER_THREE(  ){
			public List<String> getinnerThings() {
				if ( this.innerThings == null ) {
					innerThings = new ArrayList<String>();	
					innerThings.add( "blah blah" );
					innerThings.add("blah blah"  );
					
				}
				return innerThings;

			}
		};


	List<String> innerThings;
	
	//This was an abstract method, but Velocity 1.6 quite working with it.
	public abstract List<String> getinnerThings();
	
	
}

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message