What is the equivalent for postValidate() in v7.0 screens? I used to have this:
@Override
protected void postValidate(ValidationErrors errors) {
if (getItem().getRtype().equals(RtypeEnum.GlobalSuppress) ||
getItem().getRtype().equals(RtypeEnum.FrontEndSuppress) ||
getItem().getRtype().equals(RtypeEnum.OfferTypeSuppress) ||
getItem().getRtype().equals(RtypeEnum.OfferSuppress)) {
if (getItem().getSrcode() == null) {
errors.add("Please choose a Suppress Reason for a Suppress record.");
}
}
for (Item item : itemsDs.getItems()) {
if (item.getSourceId() == null) {
errors.add("Please choose a Source Code or choose 'UNKNOWN'");
}
if (item.getStepid() != null && item.getEntrynumber() == null) {
errors.add("Missing Entry Number. Please make sure that you have a unique entry number for every puzzle entry.");
}
if (item.getStepid() == null && item.getEntrynumber() != null) {
errors.add("Missing Game/Step. Plesae make sure that every entry has a puzzle game/step assigned.");
}
}
super.postValidate(errors);
}
Similary, for preCommit():
@Override
protected boolean preCommit() {
if (!getItem().getRtype().equals(RtypeEnum.GlobalSuppress) &&
!getItem().getRtype().equals(RtypeEnum.FrontEndSuppress) &&
!getItem().getRtype().equals(RtypeEnum.OfferTypeSuppress) &&
!getItem().getRtype().equals(RtypeEnum.OfferSuppress) &&
getItem().getSrcode() != null) {
getItem().setSrcode(null);
}
// Load all suppitems for this customer, if there are any
LoadContext<Suppitem> loadContext = LoadContext.create(Suppitem.class)
.setQuery(LoadContext.createQuery("select c from rade$Suppitem c where c.customer.id = :customer")
.setParameter("customer", getItem()))
.setView(View.LOCAL);
List<Suppitem> suppitems = dataManager.loadList(loadContext);
// Delete any suppitems that already exist
if (suppitems.size() > 0) {
for (Suppitem item: suppitems) {
dataManager.remove(item);
}
}
// Add back the selected suppitems, if there are any
if (getItem().getRtype().equals(RtypeEnum.OfferTypeSuppress) || getItem().getRtype().equals(RtypeEnum.OfferSuppress)) {
Collection chosen = (Collection) optSuppitems.getLookupSelectedItems();
for (Object value : chosen) {
Suppitem suppitem = metadata.create(Suppitem.class);
suppitem.setCustomer(getItem());
if (lookupRtype.getValue().equals(RtypeEnum.OfferTypeSuppress)) {
suppitem.setOffertype((String) value);
} else {
suppitem.setOffer((Offer) value);
}
dataManager.commit(suppitem);
}
}
return super.preCommit();
}
How would I code this instead?