There's an outstanding issue about this; may be a tough nut to crack.

On Thu, May 22, 2008 at 9:13 AM, Toby Hobson <[EMAIL PROTECTED]> wrote:
> Funny you should ask that Dan ... I was just struggling with something very 
> similar:
>
> BasePage.java
>
> public abstract class BasePage<T extends Serializable> {
>
>    @Inject
>    private Session session;
>
>    @Property
>    private List<T> items
>
>    private Class entityClass;
>
>    public BasePage(Class entityClass) {
>        this.entity = entuty
>    }
>
>    void onActivate() {
>        items = (List<T>) session.createCriteria(entityClass).list();
>    }
>
> }
>
> ListUsers.java
>
> public class ListUsers extends BasePage<User> {
>    public ListUsers() {
>        super(User.class);
>    }
> }
>
> The theory was that I could reuse the logic in the BasePage.java (and 
> BasePage.tml) but it doesn't seem to work.
>
> ----- Original Message ----
> From: Dan Adams <[EMAIL PROTECTED]>
> To: Tapestry users <users@tapestry.apache.org>
> Sent: Thursday, 22 May, 2008 4:51:33 PM
> Subject: Generics with contexts?
>
> I have a base class for add/edit pages that is genericized (sp?) to accepts 
> as the entity to edit as the activitation context when editing:
>
>    void onActivate(E entity) {
>        adding = false;
>        this.entity = entity;
>    }
>
>    E onPassivate() {
>        if (entity == null || entity.getId() == null)
>            return null;
>
>        return entity;
>    }
>
> The problem is that this isn't supported because tapestry doesn't know at 
> runtime what the type is. How have people got around this kind of thing? One 
> solution is to have onActivate() be in the subclass and call the one in the 
> superclass but that seems artificial and gross. Another solution would be to 
> have it accept the id of the entity rather than the entity and the load it by 
> id. Any other suggestions?
>
> Dan Adams
> Senior Software Engineer
> Interactive Factory
> p: 617.235.5857
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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

Reply via email to