You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mark <ma...@xeric.net> on 2011/03/07 17:52:51 UTC

Translator to and From a List

I am trying to create a translator that will let me create and edit a
list of topics in a space separated text field.  I want a string of
space separated words to be translated to and from a list of
List<Topic>.  So a text field that might look something like:

Topics: apples oranges bananas

Each topic is a separate object stored in the database.  If you change
an item in the list the translator will try to find it in the
database.  If it doesn't exist, it will create a new topic with the
requested name. I am creating a translator like this:

public class TopicsTranslator extends AbstractTranslator<List<Topic>>{

    Session session;
    public TopicsTranslator(Session session) {
        super("topics", List.class, "topics-format-exception");
        this.session = session;
    }


My problem seems to be with this line:

super("topics", List.class, "topics-format-exception");

The error I'm getting is:
The constructor AbstractTranslator<List<Topic>>(String, Class<List>,
String) is undefined

You can't parameterize a .class so this doesn't work:

super("topics", List<Topic>.class, "topics-format-exception");

Is there  a way to call the constructor on AbstractTranslator in a way
that tells it to use a parameterized class type? If not, what other
ways are there to achieve this?  Is an unparamterized list my only
option?

Mark

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


Re: Translator to and From a List

Posted by Mark <ma...@xeric.net>.
> Why don't you implement Translator directly, without subclassing
> AbstractTranslator? It's a very, very short class with no logic at all.

Ah ok.  That makes sense.  I was following the example and didn't
think about just skiping the AbstractTranslator.

Thanks!

Mark

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


Re: Translator to and From a List

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 07 Mar 2011 13:52:51 -0300, Mark <ma...@xeric.net> wrote:

> public class TopicsTranslator extends AbstractTranslator<List<Topic>>{
>
>     Session session;
>     public TopicsTranslator(Session session) {
>         super("topics", List.class, "topics-format-exception");
>         this.session = session;
>     }

Why don't you implement Translator directly, without subclassing  
AbstractTranslator? It's a very, very short class with no logic at all.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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