cancel
Showing results for 
Search instead for 
Did you mean: 

Checking All mandatory Input fields .

Former Member
0 Kudos

Hi All,

I have a general checkMandatory function which is working fine wiht current InputFields on view.

Now, When I add another row of input fields on that form I want them also to be checked through checkMandatory function.

How can I perform this as I want them to be checked only at the click of button.

Can I iterate through all UI elements in OnAction and then do something?

Please guide!

please reply soon1

Sumit

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Add this code in your Action method.

this.checkMandatory("Please enter Order ","Search_Term");

wdThis.wdGetAPI().getComponent().getMessageManager().raisePendingException();

// test for another input field

this.checkMandatory("Please enter Status ","Search_Status");

wdThis.wdGetAPI().getComponent().getMessageManager().raisePendingException();

And this context field(Search_Status) is avail in currentContext only.

Then it should work.

Other post if any issues.

thanks,

Lohi.

Former Member
0 Kudos

Hi,

Actually I have some inputfield sin a row.

On click of Addrow button another row is entered. All these inputfields are mandatory.

So when new fields are added how can i use check mandatory with them using:

this.checkMandatory("Please enter Status ","Search_Status");

wdThis.wdGetAPI().getComponent().getMessageManager().raisePendingException();

Because this code is to be written in OnAction of Submit button.

Please guide !

Sumit

sid_sunny
Contributor
0 Kudos

Hi Sumit,

It seems that you are dynamically adding the input field in WDDoModify.

If I am right then the way you are checking the mandatoryness for the existing fields you can also do it for the dynamically generated one too.

you can check this tutorial havin the similar kind of mandatory function in it you can slighty modify it to make it genric so that the function is called also for the new fields generated at runtime, the tutorial is given below:

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/a%20simple%20input%20form%20with%20message%20and%20error%20service%20support.pdf">Link</a>

Regards

Sid

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sumit,

Check this

post the code in your "checkMandatory " function.

Regards,Anilkumar

Former Member
0 Kudos

Hi,

This is my checkMandatory code:

public void checkMandatory( java.lang.String displayName, java.lang.String fieldContextID )

{

//@@begin checkMandatory()

IWDMessageManager messageMgr =wdThis.wdGetAPI().getComponent().getMessageManager();

String attributeValue = wdContext.currentContextElement().getAttributeAsText(fieldContextID);

IWDAttributeInfo attributeInfo =wdContext.getNodeInfo().getAttribute(fieldContextID);

if (attributeValue != null)

attributeValue = attributeValue.trim();

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

//String fieldLabel = this.wdContext.getNodeInfo().getAttribute(displayName).getSimpleType().getFieldLabel();

messageMgr.reportContextAttributeMessage(wdContext.currentContextElement(),attributeInfo,

IMessagePoInvoice.EMPTY__INPUT,

new Object[] { displayName },

true);

I have also done the simple types thing. It is not working. Do I have to change any other property.

Can't I do it by iterating through all elements and then checking for mandatory Inputfields and calling checkMandatory function for them.

please reply soon!

Sumit

Former Member
0 Kudos

Sumit,

The code looks ok. Describe your context structure and provide calls to checkMandatory method -- probably you are using wrong letter case for attribute names or similar.

Btw, "not working" means "no messages on UI" or it means "exception thrown"?

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

monalisa_biswal
Contributor
0 Kudos

Replace if (attributeValue.length() == 0) this line with following

if (attributeValue==null || attributeValue.length() == 0 )

because by default a string variable holds null value