Skip to Content
author's profile photo Former Member
Former Member

Validate form field for CE 7.1 SP3

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 06, 2008 at 10:11 AM

    Hi,

    Following methods are not depricated.

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

    reportContextAttributeMessage(IWDAttributePointer attribute,

    IWDMessage message, Object[] args)

    Regards

    Ayyapparaj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 29, 2008 at 03:50 AM

    Thanks guys.

    I found my solution.

    String attributeValue = wdContet.currentContextElement().getAttributeAsText(field);
    
    if (attributeValue.length() == 0) {
    
     ...
    
    }
    
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.