Hi Experts
I want to validate the form field and I follow the example of the SimpleError Form sample:
public void checkMandatory(java.lang.String fieldName) {
//@@begin checkMandatory()
IWDMessageManager messageMgr =
wdComponentAPI.getMessageManager();
Object attributeValue =
wdContext.currentContextElement().getAttributeValue(fieldName);
IWDAttributeInfo attributeInfo =
wdContext.getNodeInfo().getAttribute(fieldName);
if (attributeValue instanceof String) {
if (((String) attributeValue).length() == 0) {
String fieldLabel =
wdContext.getNodeInfo().getAttribute(fieldName)
.getSimpleType().getFieldLabel();
messageMgr.reportContextAttributeMessage(
wdContext.currentContextElement(),
attributeInfo,
IMessageSimpleErrors.MISSING_INPUT,
new Object[] { fieldLabel },
true);
}
}
//@@end
}
...
public void onActionSave(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionSave(ServerEvent)
this.checkMandatory(IPrivateForm.IContextElement.NAME);
this.checkDateInPast(IPrivateForm.IContextElement.BIRTHDAY);
this.checkDesired(IPrivateForm.IContextElement.E_MAIL_ADDRESS);
wdComponentAPI.getMessageManager().raisePendingException();
wdComponentAPI.getMessageManager().reportSuccess(
"The sample form data was successfully saved!");
}
However, I realise that some of the methods used in the sample are already depreciated. Methods such as reportContextAttributeMessage and raisePendingException();
I am currently using CE7.1 SP3
Can advise ?
Thank you.