You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by dick_hu <di...@gmail.com> on 2012/03/19 05:55:35 UTC

A translator error

I write a string translator  like this:
public class EditorTranslator extends AbstractTranslator<String> {
	public KindEditorTranslator() {
		super("editor", String.class, "editor-format-exception");
	}
	public String parseClient(Field field, String clientValue, String message)
			throws ValidationException {
		//do some other thing
		return clientValue;

	}
	public void render(Field field, String message, MarkupWriter writer,
			FormSupport formSupport) {

	}
	public String toClient(String value) {
		//do some other thing
		return value;
	}
	
}

and I contribute the translator in my AppModule like this:
public static void contributeTranslatorSource(
	MappedConfiguration<Class, Translator> configuration) {
	configuration.addInstance(String.class, EditorTranslator.class);
}

but it cause a exception 

Error invoking service contribution method
org.apache.tapestry5.services.TapestryModule.contributeTranslatorSource(MappedConfiguration,
NumericTranslatorSupport): Service contribution (to service
'TranslatorSource') conflicts with existing contribution (by
com.lai2.services.AppModule.contributeTranslatorSource(MappedConfiguration)
(at AppModule.java:140)).

I think it maybe  two "String" translator cause the exception,because the
TapestryModule has contributed
the StringTranslator.
I really need this "String" translator,Can anyone help me . Thanks a lot.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/A-translator-error-tp5576150p5576150.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


Re: A translator error

Posted by dick_hu <di...@gmail.com>.
Thank you very much

--
View this message in context: http://tapestry.1045711.n5.nabble.com/A-translator-error-tp5576150p5576432.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


Re: A translator error

Posted by Paul Stanton <pa...@mapshed.com.au>.
I think you want to ...

     public void 
contributeTranslatorAlternatesSource(MappedConfiguration<String, 
Translator<?>> configuration)
     {
         configuration.add("EditorTranslator", new 
EditorTranslator("EditorTranslator"));
     }

On 19/03/2012 3:55 PM, dick_hu wrote:
> I write a string translator  like this:
> public class EditorTranslator extends AbstractTranslator<String>  {
> 	public KindEditorTranslator() {
> 		super("editor", String.class, "editor-format-exception");
> 	}
> 	public String parseClient(Field field, String clientValue, String message)
> 			throws ValidationException {
> 		//do some other thing
> 		return clientValue;
>
> 	}
> 	public void render(Field field, String message, MarkupWriter writer,
> 			FormSupport formSupport) {
>
> 	}
> 	public String toClient(String value) {
> 		//do some other thing
> 		return value;
> 	}
> 	
> }
>
> and I contribute the translator in my AppModule like this:
> public static void contributeTranslatorSource(
> 	MappedConfiguration<Class, Translator>  configuration) {
> 	configuration.addInstance(String.class, EditorTranslator.class);
> }
>
> but it cause a exception
>
> Error invoking service contribution method
> org.apache.tapestry5.services.TapestryModule.contributeTranslatorSource(MappedConfiguration,
> NumericTranslatorSupport): Service contribution (to service
> 'TranslatorSource') conflicts with existing contribution (by
> com.lai2.services.AppModule.contributeTranslatorSource(MappedConfiguration)
> (at AppModule.java:140)).
>
> I think it maybe  two "String" translator cause the exception,because the
> TapestryModule has contributed
> the StringTranslator.
> I really need this "String" translator,Can anyone help me . Thanks a lot.
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/A-translator-error-tp5576150p5576150.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
>
>

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