You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dan Adams <da...@ifactory.com> on 2008/05/22 17:51:33 UTC

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org