I am creating a new Proxy:
LayoutExampleRequest r = requestFactory.employeeRequest();
DepartmentProxy d = r.create(DepartmentProxy.class);
r.save(d);
departmentEditor.editProxy(d, r);
Then pass the Proxy and the Request(LayoutExampleRequest ) to my editor
driver.edit(proxy, request);
Ultil here ! everything works as espected. Now iam getting with a suggest box Proxys of EmployeeProxy.
search = new SuggestBox(new SuggestOracle() {
@Override
public void requestSuggestions(final Request request,final Callback callback) {
System.out.println(request.getQuery());
//ignore less than 3
if(request.getQuery().length() > 3){
requestFactory.employeeRequest().search(request.getQuery()).fire(new Receiver<List<EmployeeProxy>>(){
@Override
public void onSuccess(List<EmployeeProxy> response) {
List<MySuggestion<EmployeeProxy>> suggestions = new ArrayList<MySuggestion<EmployeeProxy>>();
for(EmployeeProxy e:response){
MySuggestion<EmployeeProxy> suggestion = new MySuggestion<EmployeeProxy>();
suggestion.setModel(e,e.getFirstName(),e.getFirstName()+" "+e.getLastName());
suggestions.add(suggestion);
}
callback.onSuggestionsReady(request, new Response(suggestions));
}
});
}
}
});
Now i want to add this EmployeeProxy to my DeparmentProxy since i have a @OneToOne on JPA.
search.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {
@Override
public void onSelection(SelectionEvent<Suggestion> event) {
MySuggestion<EmployeeProxy> s = (MySuggestion<EmployeeProxy>)event.getSelectedItem();
proxy.setSupervisor(s.getModel());
}
});
proxy is a EntityProxy for Deparment
then i fire the driver:
departmentEditor.getDriver().flush().fire(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
Window.alert("Success");
// refresh the datagrid
Range range = dataGrid.getVisibleRange();
dataGrid.setVisibleRangeAndClearData(range, true); //1st way
// create a new DepartmentProxy to bind to the Editor.
createProxy();
// change button text
updateButton.setText("Save");
}
@Override
public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
for(ConstraintViolation v :violations){
Window.alert(v.getMessage()+" "+v.getPropertyPath());
}
}
@Override
public void onFailure(ServerFailure error) {
Window.alert(error.getMessage());
}
});
The problem is iam getting ConstraintViolations from the EmployeeProxy, is like the driver atach the EmployeeProxy but with null values.
(Take a look iam validating my Entityes with JSR-330 )
Dont know how to make a relationship with a new Proxy with other taked from the server.
Any help would be nice!
Thank you
2012/2/25 Thomas Broyer <t.broyer@gmail.com>
Without seeing more code, I'd say it's your server-side code fault: when sending the Address back to the server, you're not retrieving the entity back from the database but creating a new one, *or* you don't "attach" the entity correctly to your "session" when persisting, which then persists a new row instead of updating an existing one.To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/3zxrNhST0bwJ.
On Friday, February 24, 2012 5:31:04 PM UTC+1, Rocky wrote:Hi,--
I have two objects person and address
class Person{
String name;
@one-to-one
Address adderss;
}
class Address{
String HNo;
String street;
String zip;
}
I developed a screen with Person information and a ValueListBox with
all the available addresses and a save button. By clicking on save
button I need to map only one address to a new Person object. I am
using RequestFactoryEditorDriver. But when i click on save button, a
new addess row is getting created with Null values and its id is
refering by new Person row in database instead of refering already
selected Address object in the ValueListBox.
Please suggest...
Thanks,
Rocky
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
ISC. Daniel Mauricio Patiño León.
Director ejecutivo
Liondev S.A. de C.V.
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+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