improve requirements doc

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2018-10-08 12:15:22 +02:00
parent 9225585c77
commit 2dc5e3518c
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 11 additions and 3 deletions

View File

@ -50,23 +50,31 @@ to be replaced by :
```java
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
req.bindJSON(this, json);
save();
try (BulkChange bc = new BulkChange(this)) {
req.bindJSON(this, json);
bc.commit();
}
return true;
}
@DataBoundSetter
public void setSmtpHost(String smtpHost) {
this.smtpHost = nullify(smtpHost);
save();
}
@DataBoundSetter
public void setReplyToAddress(String address) {
this.replyToAddress = Util.fixEmpty(address);
save();
}
```
note: you might not even need to implement `configure` once [#3669](https://github.com/jenkinsci/jenkins/pull/3669)
notes:
- you also need matching getters for jelly view to render current value, but you probably already have them declared.
- use of BulkChange allows to avoid repeated calls to `save()` to actually persist to disk only once fully
configured.
- you might not even need to implement `configure` once [#3669](https://github.com/jenkinsci/jenkins/pull/3669)
is merged.
### Rule 2: don't use pseudo-properties for optional