Idempiere 5804 - Info Window mandatory parameters are not beeing display correctly. (#1951)

* IDEMPIERE-5804 - Fix display of mandatory parameters within display logic

* IDEMPIERE-5804 - Implements ZK constraints for mandatory Info Window parameters

* IDEMPIERE-5804 - Removes the use of ZK Constraints and implements use of ZK  WrongValueException

* IDEMPIERE-5804 - Removes unsed line and fix javadoc
This commit is contained in:
Marcos Gabriel de Oliveira Favaretto 2023-07-28 11:27:45 -03:00 committed by GitHub
parent 5af9e7de56
commit 9af815acf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 2 deletions

View File

@ -128,6 +128,7 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -2275,6 +2276,9 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
if (asiChanged && otherEditor instanceof WInfoPAttributeEditor)
((WInfoPAttributeEditor)otherEditor).clearWhereClause();
if (otherEditor.getGridField() != null)
otherEditor.setMandatory(otherEditor.getGridField().isMandatory(true));
otherEditor.dynamicDisplay();
}
}
@ -2342,6 +2346,9 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
super.onEvent(event);
}
} else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_REFRESH))) {
setMandatoryFieldsConstraint();
super.onEvent(event);
}
else
{
@ -3386,4 +3393,24 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
return true;
}
}
/**
* That method will search at all Editors to validate if it is mandatory and has
* to be provided by user.
*/
private void setMandatoryFieldsConstraint() {
int index = 0;
for (WEditor editorFrom : editors) {
WEditor editorTo = editors2.get(index++);
if (editorFrom.isMandatory() && editorFrom.getValue() == null)
throw new WrongValueException(editorFrom.getComponent(), Msg.getMsg(Env.getCtx(), "Missing required parameters"));
if (editorTo != null && editorTo.isMandatory() && editorTo.getValue() == null)
throw new WrongValueException(editorTo.getComponent(), Msg.getMsg(Env.getCtx(), "Missing required parameters"));
}
}
}