Wednesday, July 25, 2012

default-instantiable editor and requestfactory

Hi,

I'm having some trouble to get an editor and request factory working together.
I have made an editor of a user with an address editor within it.
The problem is with the saving of the changes with the user and the embedded address. Or I can load the user and the address by using with(..) Or If I comment that line out, I can only see the user with the address field empty but then I can save it. 
When I try the and, to load the editordriver with the adres I get the following: 
 The requested type is not default-instantiable.
someone knows what I'm doing wrong?

Many thanks in advance

Blas




public class EditUserPresenter extends PresenterWidget<EditUserPresenter.MyView> implements EditUserUiHandler

{

public interface MyView extends PopupView, HasUiHandlers<EditUserUiHandler>

{

public DialogBox getDialog();

public HTMLPanel getHtmlPanel();

public UserEditor getUserEditor();

}

private final DataRequestFactory rf;

@Inject

public EditUserPresenter(final EventBus eventBus, final MyView view, final DataRequestFactory rf)

{

super(eventBus, view);

getView().setUiHandlers(this);

this.rf = rf;

}

@Override

protected void onBind()

{

             super.onBind();

}


@Override

public void onSave()

{

editorDriver.flush().fire(new Receiver<Void>() {

@Override

public void onSuccess(Void response)

{

getView().getDialog().hide();

}

@Override

public void onConstraintViolation(Set<ConstraintViolation<?>> violations)

{

// TODO Auto-generated method stub

super.onConstraintViolation(violations);

}

@Override

public void onFailure(ServerFailure error)

{

Window.alert("fail");

// TODO Auto-generated method stub

super.onFailure(error);

}

});

}

@Override

public void onCancel()

{

getView().hide();

}


public void setUser(UserProxy user)

{

this.user = user;

}


@Override

protected void onReveal()

{

// TODO Auto-generated method stub

super.onReveal();

edit((RequestContext) null);

}


@Override

protected void onHide()

{

user = null;
super.onHide();

}


private final Driver editorDriver = GWT.create(Driver.class);;

private UserProxy user;


private void edit(RequestContext usercontext)

{


editorDriver.initialize(rf, getView().getUserEditor());

if (usercontext == null) {

fetchAndEdit();

return;

}

editorDriver.edit(user, usercontext);

getView().getDialog().center();

}


private void fetchAndEdit()

{


Request<UserProxy> req = rf.userRequest().findById(user.getId());

//req.with(editorDriver.getPaths());

req.fire(new Receiver<UserProxy>() {


@Override

public void onSuccess(UserProxy response)

{


user = response;

UserRequest context = rf.userRequest();

edit(context);

}

});

// TODO Auto-generated method stub

}


interface Driver extends RequestFactoryEditorDriver<UserProxy, UserEditor>

{

}

}

--
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/-/o20Vl3e2u7wJ.
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