I have the following structure
public class CitaWidget{
//here i load a complex graph with request factory
// in some place of this class i create a Editor of each proxy on a list
for(UnidadProxy unidadProxy: response.getUnidades()){
// i create editors here ...
final UnidadCitaEditor unidadCitaEditor = new UnidadCitaEditor(unidadProxy);
//
}
}
public class UnidadCitaEditor implements Editor<UnidadProxy>{
// this class is a editor for the UnidadProxy obtained by the previous class
// here each UnidadProxy has many CitaProxy so i created a ListEditor
@UiField(provided=true) CitaListEditor citas;
protected DefaultRequestFactory factory = DefaultRequestFactory.instance;
protected interface Driver extends RequestFactoryEditorDriver<UnidadProxy, UnidadCitaEditor>{}protected Driver driver = GWT.create(Driver.class);
public UnidadCitaEditor (){
driver.initialize(this);factory.initialize(new SimpleEventBus());
// then i create the top driver and the request context
final UnidadRequest unidadRequest = factory.unidadRequest();
unidadRequest.citaUnidadChange(unidadProxy).with("citas","citas.alumno","citas.doctor","citas.responsable").to(new Receiver<UnidadProxy>() {@Overridepublic void onSuccess(UnidadProxy response) {UnidadRequest unidadRequest = factory.unidadRequest();unidadRequest.citaUnidadChange(response).with(driver.getPaths()).to(this);
// iam trying to reuse the editor with a new RequestContext, for better ui experience for the final user
driver.edit(response, unidadRequest);}});driver.edit(unidadProxy, unidadRequest);
}
}
public class CitaListEditor extends FlexTable implements IsEditor<ListEditor<CitaProxy, CitaEditor>>, HasRequestContext<List<CitaProxy>>{
protected class CitaEditorSource extends EditorSource<CitaEditor>{
// business logic for the cita editor source
}
private void onNewProxy(){
final CitaProxy citaProxy = ctx.create(CitaProxy.class);
// the cita proxy is atached to the list
// the the CitaEditor can handle the binding ...
// on save of the CitaEditor i fire the main RequestContext that one on the UnidadCitaEditor to persist the data
}
}
Well as you friends can see i have a widget that retrive a list of Unidades then each unidad has a List of Citas then i create a editor for each Unidad.
Then the user call the onNewProxy() the new cita proxy its atached to the list correctly.
The thing here is i want when a user creted a new CitaProxy and when the editor of this Cita hides () call save fire the requestcontext
This because iam using a extensive UI layout (FlexTable DND some visual validation, etc..) to represent the Cita's proxys.
I want to maintain the Client side ui but save the CitaProxy on the server.
I know the RequestFactory is per request only, so i have a problem here.
I tryed to getback the same Unidad proxy and then reatach to the driver as the follow lines of the class UnidadCitaEditor :
unidadRequest.citaUnidadChange(unidadProxy).with("citas","citas.alumno","citas.doctor","citas.responsable").to(new Receiver<UnidadProxy>() {@Overridepublic void onSuccess(UnidadProxy response) {UnidadRequest unidadRequest = factory.unidadRequest();unidadRequest.citaUnidadChange(response).with(driver.getPaths()).to(this);driver.edit(response, unidadRequest);}});
Iam trying to reuse the editor and create a new RequestContext to be fired when a new CitaProxy is added to the list of the ListEditor
so my ListEditor CitaListEditor can maitain the UI and add the new ones only.
The problem is that iam getting an exception here...
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.AssertionError: Unfrozen bean with null RequestContext
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.checkStreamsNotCrossed(AbstractRequestContext.java:981)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.editProxy(AbstractRequestContext.java:509)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$4.visitCollectionProperty(AbstractRequestContext.java:1036)
at mx.com.liondev.GrupoEndodontico.shared.Model.Unidad.UnidadProxyAutoBean_com_google_web_bindery_requestfactory_shared_impl_EntityProxyCategory_com_google_web_bindery_requestfactory_shared_impl_ValueProxyCategory_com_google_web_bindery_requestfactory_shared_impl_BaseProxyCategory.traverseProperties(UnidadProxyAutoBean_com_google_web_bindery_requestfactory_shared_impl_EntityProxyCategory_com_google_web_bindery_requestfactory_shared_impl_ValueProxyCategory_com_google_web_bindery_requestfactory_shared_impl_BaseProxyCategory.java:243)
at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.traverse(AbstractAutoBean.java:166)
at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.accept(AbstractAutoBean.java:101)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.cloneBeanAndCollections(AbstractRequestContext.java:1006)
at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.editProxy(AbstractRequestContext.java:526)
etc...
etc...
How can i solve this.
What aproach you friends recomend to me to follow.
I want to use EditorFramework to persist the changes on the DB but mantain the UI on the client
i was thinking in this four ways:
--- On the CitaEditor that one that the CitaEditorSource manage create a RequestContext with a copy of the Proxy
i cannot use that proxy cuze it is used by another RequestContext so i need copy it.
never fire the UnidadCitaEditor editor so i can keep all the ui on the client side.
how can i make a copy of a proxy?
-- Just after every persited CitaProxy re draw the ui.
not friendly for the final user, for example i use DND to drag widgets on the FlexTable (CitaListEditor)
so on drop,bum!! wait to load all the ui again.
-- The way iam using right now, but don't know why happens this exception.
-- Just let the user add citas proxy... then put a big save button to persist all the data.
if user close the browser ? all the data not saved will be lost.
Iam updating a Google Calendar too. What if the user dont press save and the calendar was updated.
i really dont want to follow this strategy
Any help would be apreciated.
Thank you.
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/-/nk8sev1b5OEJ.
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