tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yosemite <kmic...@hotmail.com>
Subject ValueEncoder stopped working in 5.017
Date Thu, 04 Dec 2008 08:13:48 GMT

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
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <head><title>myapp Start Page</title></head>
        <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>
	            [<t:pagelink t:page="Index">refresh</t:pagelink>]
			<t:select t:value="year" t:model="yearModel"  t:encoder="encoder" />        
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 {
    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;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    <display-name>myapp Tapestry 5 Application</display-name>
        <!-- The only significant configuration for Tapestry 5, this informs
of where to look for pages, components and mixins. -->
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org

View raw message