I already did a rudimentary implementation of this in my GWT projects for
the same reason (MCV pattern). Here they are, feel free to use them in any
way you want. It's not much what I have though :P
public interface Observer {
public void update();
}
public class Observable {
private List<Observer> observers;
public synchronized void deleteObservers() {
getObservers().clear();
}
public synchronized void addObserver(Observer o) {
getObservers().add(o);
}
public synchronized int countObservers() {
return getObservers().size();
}
public synchronized void deleteObserver(Observer o) {
getObservers().remove(o);
}
private List<Observer> getObservers() {
if(observers == null)
observers = new ArrayList<Observer>();
return observers;
}
protected void broadcastObservers(){
for(Observer o: getObservers())
o.update();
}
}
2010/3/22 jcb <[email protected]>
>
> Thank you, interesting link !
>
>
> On Mar 22, 7:40 am, Nathan Wells <[email protected]> wrote:
> > Can't speak for the GWT team here, but this could be a reason:
> >
> > http://forums.sun.com/thread.jspa?threadID=5336733
> >
> > On Mar 20, 10:43 am, jcb <[email protected]> wrote:
> >
> >
> >
> > > I am very satisfied with gwt, and I am making a simple gwt app with
> > > just client side code.
> > > I want to separate model and view, so I wanted to use the simple
> > > Observer/Observable classes of java.util but it is not emulated in GWT
> > > (cf. references).
> > > Someone know why these classes are not emulated ?
> >
> > > Of course it's not a big issue I can create similar classes in client
> > > side, but it seems a pity if we have to invent/copy again the wheel.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.