Hi!

I was upgrading vom Tapestry 2.6 to 3.0 and have one issue:

                if(encoder == null){
                        encoder = new EnumValueEncoder<E>(enumType); 
                }
                return encoder;

the EnumValueEncoder does not exist anymore as a contructor with one
parameter. Now, I need a TypeCoercer as the first paramter, but have no idea
for what. There are no examples. This is really one thing which demotivates
me using tapestry. Rather than bringing easy examples, new methods occur
quickly. 


code>

package com.airwriting.frontend.components.html;

import org.apache.tapestry5.ValueEncoder;

import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Radio;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.util.EnumValueEncoder;

public class RadioEnum<E extends Enum<E>>{
        @Parameter(required=true)
        private Class<E> enumType;
        @Property @SuppressWarnings("unused")
        @Parameter(required=true)
        private E value;
        
  @InjectComponent("radioEnum")
  private Radio radio;
        @Inject
        private Messages messages;
        
        @Property
        private E currentValue;
        
        private ValueEncoder<E> encoder;
        
        public ValueEncoder<E> getEncoder(){
                if(encoder == null){
                        encoder = new EnumValueEncoder<E>(enumType); 
                }
                return encoder;
        }
        
        public E[] getValues(){
                return enumType.getEnumConstants();
        }
        
        public String getCurrentRadioId(){
                return radio.getClientId();
        }
        
        public String getLocalizedValue(){
                return messages.get( enumType.getSimpleName() + "." + 
currentValue.name()
);
        }
        
}


--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/TypeCoercer-Example-tp5687042.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to