on 03-06-2008 10:01 AM
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.
Hi,
Following methods are not depricated.
reportContextAttributeMessage(IWDAttributePointer[] attributes, IWDMessage message, Object[] args)
reportContextAttributeMessage(IWDAttributePointer attribute,
IWDMessage message, Object[] args)
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks guys.
I found my solution.
String attributeValue = wdContet.currentContextElement().getAttributeAsText(field);
if (attributeValue.length() == 0) {
...
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.