Monday, November 29, 2010

Extended Methods for EntityProxies

Hi,

-== Context ==-
I have created a widget that implicitly holds an EntityProxy as it's
backing value.

eg:

MySpecialDisplayPanel<E extends EntityProxy>

I use this panel (which has a Label and other decorations) when I need
to display the entity.
Click on the entity and it swaps to a listbox to choose another. So
the Entity attached to the MySpecialDisplayPanel is the "chosen" value
and a list of applicable entities is the backing store.

I call a method E getEntity() to get back the chosen Entity.

-== My Question ==-
I have a few entities which are displayed by this display panel and I
wanted to add a generic "toString() or getDisplayText() for all
entities so I can reliably just show it anywhere and as "how " the
entity needs to be displayed.

(a) is this the best approach for creating "proxy holding widgets ? "
(b) if it is, how do you suggest I implement the toString across the
board.
Does the EntityProxy prardigm only work with get/set pairs. ?
(that I have to add a {get|set}DisplayString() to all real entities
(abstract base class) ..
or is there an easier / nicer way).

on the real entity.. I was thinking of something like:

@MappedSuperclass
public abstract class AbstractEntity {
// .. other fields common for all entities
@Transient // ignore for JPA
private String displayString;
public void setDisplayString(String displayString )
{ this.displayString = displayString;}
public String getDisplayString() { return this.displayString; }
}

@Entity
public class BusinessArea extends AbstractEntity {

private String name;
public void setName(String name) { this.name = name;
this.setDisplayString(name);}
public String getName() { return this.name; }

}

}

(I recall that RequestFactory can't deal with Abstract classes yet -
though)

My fall back is a displayhelper.
suggestions ?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment