0

RequestFactory と Editors で使用される GWT Client Validation に問題がありました。

編集コードは次のとおりです。

LocalityRequest localityContext = //create Request 
Locality locality = //Locality Entity Proxy loaded from the server
driver.edit(locality, localityContext); //Edit the proxy
request = localityContext.updateLocality(locality);

保存コードは次のとおりです。

this.localityContext = (LocalityRequest) driver.flush(); //Flush the request
Set<ConstraintViolation<LocalityProxy>> violations = validator.validate(this.locality); //Local validate the object
if (!violations.isEmpty()) {
    Set<ConstraintViolation<?>> sets = new HashSet<ConstraintViolation<?>>(violations);
    driver.setConstraintViolations(sets);
    editLocalityView.setErrors(sets); //give errors to the editors
    return;
}
localityContext.fire(); //else send the request

私の問題は、ローカル検証が常に読み込まれたバージョンで検証され、ユーザーが編集したバージョンでは検証されないことです。リクエストに保存されたフラッシュされたオブジェクトを取得するにはどうすればよいですか?

ありがとう

4

1 に答える 1

0

編集したオブジェクトをキャッシュ/保存する必要があります (詳細については、こちらを参照してください)。

LocalityRequest localityContext = //create Request 
Locality locality = //Immutable Locality Entity Proxy loaded from the server
Locality modifedLocality = ctx.edit(locality); // Create Mutable copy 
driver.edit(modifedLocality, localityContext); //Edit the mutable proxy
request = localityContext.updateLocality(modifedLocality);

そして保存コードで:

this.localityContext = (LocalityRequest) driver.flush(); //Flush the request
Set<ConstraintViolation<LocalityProxy>> violations = validator.validate(this.modifedLocality); //Local validate the mutable Proxy
if (!violations.isEmpty()) {
    Set<ConstraintViolation<?>> sets = new HashSet<ConstraintViolation<?>>(violations);
    driver.setConstraintViolations(sets);
    editLocalityView.setErrors(sets); //give errors to the editors
    return;
}
localityContext.fire(); //else send the request
于 2014-12-11T10:53:15.360 に答える