Hello,
the attached code worked fine in 5.011 but in 5.017 it blows up saying:
Render queue error in BeforeRenderTemplate[Index:select]: Failure reading
parameter 'encoder' of component Index:select: Could not find a coercion
from type org.example.myapp.util.IntegerEncoder to type
org.apache.tapestry5.ValueEncoder. Maybe I missed in version 5.017 the
encoder works different?
Any help really appreciated
Karel
---
index.tml:
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
    <head><title>myapp Start Page</title></head>
    <body>
        <form t:id="form">
                <h1>myapp Start Page</h1>
                <p> This is the start page for this application, a good place to
start your modifications.
                    Just to prove this is live: </p>
                <p> The current time is: ${currentTime}. </p>
                <p>
                    [<t:pagelink t:page="Index">refresh</t:pagelink>]
                </p>
                        <t:select t:value="year" t:model="yearModel"  
t:encoder="encoder" />        
        </form>
    </body>
</html>
---
package org.example.myapp.pages;
import java.util.Calendar;
import java.util.Date;
import org.apache.tapestry5.SelectModel;
import org.apache.tapestry5.ValueEncoder;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.corelib.components.Form;
import org.example.myapp.util.IntegerEncoder;
import org.example.myapp.util.IntegerSelectModel;
public class Index {
        @Component
    private Form form;
        private Calendar c = Calendar.getInstance();
        public Date getCurrentTime() {
                return new Date();
        }
        public int getYear() {
                return c.get(Calendar.YEAR);
        }
        public SelectModel getYearModel() {
                return (SelectModel) new IntegerSelectModel(1900, 2010);
        }
        public ValueEncoder getEncoder() {
                return (ValueEncoder) new IntegerEncoder();
        }
}
---
package org.example.myapp.services;
import java.io.IOException;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.services.Request;
import org.apache.tapestry5.services.RequestFilter;
import org.apache.tapestry5.services.RequestHandler;
import org.apache.tapestry5.services.Response;
import org.slf4j.Logger;
public class AppModule {
        public static void bind(ServiceBinder binder) {}
        public RequestFilter buildTimingFilter(final Logger log) {
                return new RequestFilter() {
                        public boolean service(Request request, Response 
response,
                                        RequestHandler handler) throws 
IOException {
                                long startTime = System.currentTimeMillis();
                                try {
                                        return handler.service(request, 
response);
                                } finally {
                                        long elapsed = 
System.currentTimeMillis() - startTime;
                                        log.info(String.format("Request time: 
%d ms", elapsed));
                                }
                        }
                };
        }
}
---
package org.example.myapp.util;
import org.apache.tapestry5.ValueEncoder;
public class IntegerEncoder implements ValueEncoder {
        public String toClient(Object i) {
                return i.toString();
        }
        public Object toValue(String s) {
                return new Integer(s);
        }
}
---
package org.example.myapp.util;
import java.util.Map;
import org.apache.tapestry5.OptionModel;
public class IntegerOptionModel implements OptionModel {
  private Number number;
  public IntegerOptionModel(Number num) {
    number = num;
  }
  public Map<String, String> getAttributes() {
    return null;
  }
  public String getLabel() {
    return "" + number;
  }
  public Object getValue() {
    return number;
  }
  public boolean isDisabled() {
    return false;
  }
}
---
package org.example.myapp.util;
import java.util.ArrayList;
import java.util.List;
import org.apache.tapestry5.OptionGroupModel;
import org.apache.tapestry5.OptionModel;
import org.apache.tapestry5.util.AbstractSelectModel;
public class IntegerSelectModel extends AbstractSelectModel {
        private List<OptionModel> options = new ArrayList<OptionModel>();
        public IntegerSelectModel(int numFrom, int numTo) {
                int increment = numTo > numFrom ? 1 : -1;
                for (int i = numFrom; i <= numTo; i += increment) {
                        options.add(new IntegerOptionModel(i));
                }
        }
        public List<OptionGroupModel> getOptionGroups() {
                return null;
        }
        public List<OptionModel> getOptions() {
                return options;
        }
}
---
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app>
    <display-name>myapp Tapestry 5 Application</display-name>
    <context-param>
        <!-- The only significant configuration for Tapestry 5, this informs
Tapestry
of where to look for pages, components and mixins. -->
        <param-name>tapestry.app-package</param-name>
        <param-value>org.example.myapp</param-value>
    </context-param>
    <filter>
        <filter-name>app</filter-name>
        <filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>app</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>
      
-- 
View this message in context: 
http://www.nabble.com/ValueEncoder-stopped-working-in-5.017-tp20828992p20828992.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to