Tanks Thomas for response.
The rare is that AddressView implements Editor<AddreessProxy>
I put the codes below:
Extract for TerceroNewView
public interface TerceroNewView extends View, Editor<TercerosProxy> {
public interface Presenter extends MutablePresenter<TerceroNewView>{
}
RequestFactoryEditorDriver<TercerosProxy, ? extends Editor<TercerosProxy>> createEditorDriver(
RequestFactory rf);
}
Extract for TerceroEditor
public class TerceroEditor implements TerceroNewView {
private static TerceroEditorUiBinder uiBinder = GWT.create(TerceroEditorUiBinder.class);
interface TerceroEditorUiBinder extends UiBinder<SimplePanel, TerceroEditor> {
}
interface Driver extends RequestFactoryEditorDriver<TercerosProxy, TerceroEditor> {
}
private SimplePanel root;
@UiField
ClientResource res;
@UiField
ValueBoxEditorDecorator<String> name;
@UiField
ValueBoxEditorDecorator<String> lastName;
@UiField(provided = true)
AddressView address;
private final TerceroNewView.Presenter presenter;
@Inject
public TerceroEditor(
AsyncProvider<AddressView> addressView,
@Named(Constans.TerceroNewPresenter) TerceroNewView.Presenter presenter) {
this.presenter = presenter;
addressView.get(new AsyncCallback<AddressView>() {
@Override
public void onSuccess(AddressView result) {
address = result;
ini();
}
@Override
public void onFailure(Throwable caught) {
}
});
}
private void ini(){
root = uiBinder.createAndBindUi(this);
res.erpLgkStyle().ensureInjected();
presenter.onCreate(this);
}
.....
.....
}
Extract for AddressView:
public interface AddressView extends View, Editor<AddressProxy>{
public interface Presenter extends MutablePresenter<AddressView>{
}
HasConstrainedValue<CityProxy> getCitys();
}
Extract for AddressEditor:
public class AddressEditor implements AddressView {
interface AddressWidgetUiBinder extends UiBinder<HTMLPanel, AddressEditor> {
}
interface Driver extends RequestFactoryEditorDriver<AddressProxy, AddressEditor> {
}
private static AddressWidgetUiBinder uiBinder = GWT.create(AddressWidgetUiBinder.class);
private HTMLPanel root;
private AddressView.Presenter presenter;
@UiField
ValueBoxEditorDecorator<String> address;
@UiField
ValueBoxEditorDecorator<Integer> number;
@UiField
ValueBoxEditorDecorator<String> code;
@UiField(provided = true)
SelectorCityView city;
@Inject
public AddressEditor(
AsyncProvider<SelectorCityView> selectorCity,
@Named(Constans.AddressNewPresenter) AddressView.Presenter presenter) {
this.presenter = presenter;
// TODO ver si hay otra forma de inicializar las vistas
selectorCity.get(new AsyncCallback<SelectorCityView>() {
@Override
public void onSuccess(SelectorCityView result) {
city = result;
init();
}
@Override
public void onFailure(Throwable caught) {
}
});
}
private void init(){
root = uiBinder.createAndBindUi(this);
presenter.onCreate(this);
}
...
...
}
Extract for TerceroNewPresenter
public class TerceroNewEditorPresenter implements TerceroNewView.Presenter {
private final PlaceController placeController;
private final ErpRequestFactory requestFactory;
private RequestFactoryEditorDriver<TercerosProxy, ? extends Editor<TercerosProxy>> terceroDriver;
@Inject
public TerceroNewEditorPresenter(final AddressNewPresenter addressPresenter,
final ErpRequestFactory requestFactory, final PlaceController placeController) {
this.placeController = placeController;
this.requestFactory = requestFactory;
}
@Override
public void goTo(Place place) {
placeController.goTo(place);
}
@Override
public void save() {
RequestContext context = terceroDriver.flush();
boolean hasClientErrors = terceroDriver.hasErrors();
if (!hasClientErrors) {
context.fire(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
placeController.goTo(new DefaultPlace());
}
@Override
public void onViolation(Set<Violation> errors) {
terceroDriver.setViolations(errors);
}
@Override
public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
terceroDriver.setConstraintViolations(violations);
}
});
}
}
@Override
public void onCreate(final TerceroNewView view) {
terceroDriver = view.createEditorDriver(requestFactory);
TercerosRequest context = requestFactory.getTercerosRequest();
TercerosProxy tercero = context.create(TercerosProxy.class);
AddressProxy address = context.create(AddressProxy.class);
tercero.setAddress(address);
context.persist(tercero).with(terceroDriver.getPaths());
terceroDriver.edit(tercero, context);
}
...
...
}
Extract for GIN configurations:
bind(TerceroNewView.class).to(TerceroEditor.class).in(Singleton.class);
bind(AddressView.class).to(AddressEditor.class).in(Singleton.class);
Data sent by Client to Server
{"F":"com.logikas.erp.shared.request.ErpRequestFactory","O":[{"T":"oNrI9YUtkvx6RRVjmYN2ooLeKvQ=","P":{"lastName":"Rinaldi","address":{"T":"jVTUhBxMFgABvM07abYHRgwY8ps=","R":"1","C":2},"name":"Cristian"},"C":1,"R":"1","O":"PERSIST"},{"T":"jVTUhBxMFgABvM07abYHRgwY8ps=","C":2,"R":"1","O":"PERSIST"}],"I":[{"P":[{"T":"oNrI9YUtkvx6RRVjmYN2ooLeKvQ=","R":"1","C":1}],"R":["address"],"O":"tNTGSDAwvU0DpOikzbM$SKIPFQw="}]}
Data sent by Server to Client
{"X":[{"T":"{javax.validation.constraints.NotNull.message}","P":"code","R":{"T":"jVTUhBxMFgABvM07abYHRgwY8ps=","R":"1","C":2},"L":{"T":"jVTUhBxMFgABvM07abYHRgwY8ps=","R":"1","C":2},"M":"no puede ser null"},
{"T":"{javax.validation.constraints.NotNull.message}","P":"address","R":{"T":"jVTUhBxMFgABvM07abYHRgwY8ps=","R":"1","C":2},"L":{"T":"jVTUhBxMFgABvM07abYHRgwY8ps=","R":"1","C":2},"M":"no puede ser null"},
{"T":"{javax.validation.constraints.NotNull.message}","P":"number","R":{"T":"jVTUhBxMFgABvM07abYHRgwY8ps=","R":"1","C":2},"L":{"T":"jVTUhBxMFgABvM07abYHRgwY8ps=","R":"1","C":2},"M":"no puede ser null"}]}
About other question, tanks for sugestion.
Regards
A.U.S Cristian Rinaldi
Teléfono Móvil: (0342) 155 238 083
www.logikas.com
Lisandro de la Torre 2643 Of 5 - 3000 - Santa Fe
Teléfono Fijo: (0342) 483 5138
|
|