cancel
Showing results for 
Search instead for 
Did you mean: 

Validate form field for CE 7.1 SP3

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Following methods are not depricated.

reportContextAttributeMessage(IWDAttributePointer[] attributes, IWDMessage message, Object[] args)

reportContextAttributeMessage(IWDAttributePointer attribute,

IWDMessage message, Object[] args)

Regards

Ayyapparaj

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks guys.

I found my solution.


String attributeValue = wdContet.currentContextElement().getAttributeAsText(field);

if (attributeValue.length() == 0) {

 ...

}