You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joel Wiegman <Jo...@dswinc.com> on 2008/01/29 19:41:01 UTC
T5: Simple Module not loading [5.0.9]
All,
Let me tell you a quick story... Got an error in my app which I'm sure
some of you have seen:
Failure writing parameter value of component
app/controllist/consignment/EditControl:departmentid: Coercion of null
to type java.lang.Integer (via null --> String, String --> Long, Long
--> Integer) failed: null
I thought to myself... well I guess that makes sense... let me add a
Module definition and contribute the coercion for nulls to Integers.
So I check my web xml (abridged):
<context-param>
<param-name>tapestry.app-package</param-name>
<param-value>com.foo.web</param-value>
</context-param>
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry.spring.TapestrySpringFilter</filter-cl
ass>
</filter>
And conclude that I need to create the following file:
package com.foo.web.services;
import org.apache.tapestry.ioc.Configuration;
import org.apache.tapestry.ioc.services.Coercion;
import org.apache.tapestry.ioc.services.CoercionTuple;
public class AppModule {
public static void contributeTypeCoercer(
Configuration<CoercionTuple> configuration) {
System.out.println("Coercion added!");
add(configuration, void.class, Integer.class,
new Coercion<Void, Integer>() {
public Integer coerce(Void
input) {
return null;
}
});
}
private static <S, T> void add(Configuration<CoercionTuple>
configuration,
Class<S> sourceType, Class<T> targetType,
Coercion<S, T> coercion) {
CoercionTuple<S, T> tuple = new CoercionTuple<S,
T>(sourceType,
targetType, coercion);
configuration.add(tuple);
}
}
Problem is... I never see the System.out, so I can only assume that my
module never loaded (and of course, I still get the error).
Can anyone spot my flaw? I'm totally stumped.
Joel
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Simple Module not loading [5.0.9]
Posted by Howard Lewis Ship <hl...@gmail.com>.
Great that you're moving again.
I'd look for a better alternative that coercing null to 0. That
causes a lot of grief in other areas. There's now more explicit
handling of nulls and blanks from the user via the nulls parameter on
TextField & friends.
On Jan 29, 2008 11:12 AM, Joel Wiegman <Jo...@dswinc.com> wrote:
> Never mind... The module class was in src/test/java not src/main/java.
>
> <Walks off with tail between legs>
>
>
> -----Original Message-----
> From: Joel Wiegman [mailto:JoelWiegman@dswinc.com]
> Sent: Tuesday, January 29, 2008 1:41 PM
> To: Tapestry users
> Subject: T5: Simple Module not loading [5.0.9]
>
> All,
>
> Let me tell you a quick story... Got an error in my app which I'm sure
> some of you have seen:
>
> Failure writing parameter value of component
> app/controllist/consignment/EditControl:departmentid: Coercion of null
> to type java.lang.Integer (via null --> String, String --> Long, Long
> --> Integer) failed: null
>
> I thought to myself... well I guess that makes sense... let me add a
> Module definition and contribute the coercion for nulls to Integers.
>
> So I check my web xml (abridged):
>
> <context-param>
> <param-name>tapestry.app-package</param-name>
> <param-value>com.foo.web</param-value>
> </context-param>
>
> <filter>
> <filter-name>app</filter-name>
>
> <filter-class>org.apache.tapestry.spring.TapestrySpringFilter</filter-cl
> ass>
> </filter>
>
> And conclude that I need to create the following file:
>
> package com.foo.web.services;
>
> import org.apache.tapestry.ioc.Configuration;
> import org.apache.tapestry.ioc.services.Coercion;
> import org.apache.tapestry.ioc.services.CoercionTuple;
>
> public class AppModule {
>
> public static void contributeTypeCoercer(
> Configuration<CoercionTuple> configuration) {
>
> System.out.println("Coercion added!");
>
> add(configuration, void.class, Integer.class,
> new Coercion<Void, Integer>() {
> public Integer coerce(Void
> input) {
> return null;
> }
> });
> }
>
> private static <S, T> void add(Configuration<CoercionTuple>
> configuration,
> Class<S> sourceType, Class<T> targetType,
> Coercion<S, T> coercion) {
> CoercionTuple<S, T> tuple = new CoercionTuple<S,
> T>(sourceType,
> targetType, coercion);
>
> configuration.add(tuple);
> }
>
> }
>
> Problem is... I never see the System.out, so I can only assume that my
> module never loaded (and of course, I still get the error).
>
> Can anyone spot my flaw? I'm totally stumped.
>
> Joel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
Creator Apache Tapestry and Apache HiveMind
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: T5: Simple Module not loading [5.0.9]
Posted by Joel Wiegman <Jo...@dswinc.com>.
Never mind... The module class was in src/test/java not src/main/java.
<Walks off with tail between legs>
-----Original Message-----
From: Joel Wiegman [mailto:JoelWiegman@dswinc.com]
Sent: Tuesday, January 29, 2008 1:41 PM
To: Tapestry users
Subject: T5: Simple Module not loading [5.0.9]
All,
Let me tell you a quick story... Got an error in my app which I'm sure
some of you have seen:
Failure writing parameter value of component
app/controllist/consignment/EditControl:departmentid: Coercion of null
to type java.lang.Integer (via null --> String, String --> Long, Long
--> Integer) failed: null
I thought to myself... well I guess that makes sense... let me add a
Module definition and contribute the coercion for nulls to Integers.
So I check my web xml (abridged):
<context-param>
<param-name>tapestry.app-package</param-name>
<param-value>com.foo.web</param-value>
</context-param>
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry.spring.TapestrySpringFilter</filter-cl
ass>
</filter>
And conclude that I need to create the following file:
package com.foo.web.services;
import org.apache.tapestry.ioc.Configuration;
import org.apache.tapestry.ioc.services.Coercion;
import org.apache.tapestry.ioc.services.CoercionTuple;
public class AppModule {
public static void contributeTypeCoercer(
Configuration<CoercionTuple> configuration) {
System.out.println("Coercion added!");
add(configuration, void.class, Integer.class,
new Coercion<Void, Integer>() {
public Integer coerce(Void
input) {
return null;
}
});
}
private static <S, T> void add(Configuration<CoercionTuple>
configuration,
Class<S> sourceType, Class<T> targetType,
Coercion<S, T> coercion) {
CoercionTuple<S, T> tuple = new CoercionTuple<S,
T>(sourceType,
targetType, coercion);
configuration.add(tuple);
}
}
Problem is... I never see the System.out, so I can only assume that my
module never loaded (and of course, I still get the error).
Can anyone spot my flaw? I'm totally stumped.
Joel
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org