Acivities and Places - passing by reference

2012-02-02 Thread dparish
I'm refactoring a MVP app I have that currently uses Events and an
AppController to handle navigation transitions.

Activities and Places appear to only pass state via tokens, not by
passing by reference. is there another way?

A use case may help here:
Think of two screens, A Student List screen and an Add Edit Student
screen.

Without places using events, clicking on a Student in Student List
fires off an event CONTAINING the student, so when the Add Edit
Student view picks it up, it already knows about the student.

With Places when you click on a student in student list, the
PlaceManager gives you a place and an id for that student.  The Add
Edit Student Actiivity has to look up the student based off the passed
in id.  This seems like a major design drawback. What I was expecting
was some method to pass the object.  In the case where someone
navigates straight to:

#AddEditStudentPlace:2

I would expect my code to handle the fact that it does not have a
passed in student and in THAT case, fetch it from the server. If
you've already clicked on the Student in a list view, it's insane to
look it up again.  That's about as un GWT as you can get.

Yes I could put it in a app cache, but that's a hack and introduces
client side memory issues.

There must be some way to handle this that keeps the model simple.

The only thing I can think of is putting my events back in on top of
places, but what good is that?? If I do that, why even use Places?


-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Acivities and Places - passing by reference

2012-02-02 Thread John99
you need to put your student into EditStudentPlace and initialize new 
EditStudentActivity with it in ActivityMapper

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



Re: Acivities and Places - passing by reference

2012-02-02 Thread dparish
SWEET. That was exactly it.  I added a setStudent and getStudent to
StudentAddEditPlace

In my activity mapper I get the activity for the place, then set the
student into the activity that I get from the place.

Subtle but obvious now that I see it.  Thank you very much.

-Dave


On Feb 2, 2:44 pm, John99 smy...@gmail.com wrote:
 you need to put your student into EditStudentPlace and initialize new 
 EditStudentActivity with it in ActivityMapper

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Acivities and Places - passing by reference

2012-02-02 Thread -sowdri-
Hi, If you want activities to be talking to each other, one way of 
achieving them is via encapsulating the data in the Place, as mentioned 
above. 

Imagine a complex application, where in a lot of objects are required by 
different activities. In events like that, you have to pass on all the 
required objects through Place(s). Which is kind of chain, where sometimes, 
some values have to be passed just to enable the construction of all the 
possible places/activities that could be triggered from there. 

A simple solution on that case could be to have  a singleton value store, 
and use it for value types. 

@Singleton
public class ValueStore {

private MapString, Object values = new HashMapString, Object();

public Object getValue(String key) {
return values.get(key);
}

public void putValue(String key, Object value) {
values.put(key, value);
}

public boolean hasValue(String key) {
return values.containsKey(key);
}
}

Such that the data populated in one activity could be consumed by a host of 
other related activities. 

Just another way of achieving the same! 

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