cancel
Showing results for 
Search instead for 
Did you mean: 

Field length validations

Former Member
0 Kudos

Hi All,

In my application, I have to give a set of inputs...and will get the output on the basis of range set. If I dont give any input, then also BAPI will fetch all the data.

I have to set length validations(fixed, maximum) without using simple type.

How this can be achieved ?

Thanks,

Nikhil

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Nikhil:

You can put the validation in the "onEnter" event of each input or in the associate event for the save/query action. You have to validate each attribute in your code, the validation itself it´s like any validation of String, number, etc. in Java. To have the messages in the same style that the validations with simple types you should implement this:

msgMgr.reportInvalidContextAttributeException(theNode, wdContext.nodeTheNode().getNodeInfo().getAttribute("attr"),"message to be display in the associated input", true);

Hope it helps you.

Rocío.

former_member187439
Active Participant
0 Kudos

Hi Rocio, The format which you have given seems to be not working. It looks like (node, attribute info, string, boolean). But when i try that, my WebDynpro shows the invalid format error. It expects(IWDNodeElement element, IWDAttributeInfo attribute, WDNonFatalException ex, boolean cancelNavigation). Does your format work?

Thanks & Regards,

Kavitha.

Former Member
0 Kudos

Kavitha:

My mistake,sorry, it´s the element with wrong validation. The attr is the attr that not pass the validation. Ex.

Client (node)

--> name (attr)

IClientElement client = wdContext.currentClientElement();

msgMgr.reportInvalidContextAttributeException(client, wdContext.nodeClient().getNodeInfo().getAttribute("name"), "Name field must be fill", true);

Hope it helps you.

Rocío.

former_member187439
Active Participant
0 Kudos

Thank you... It works

former_member187439
Active Participant
0 Kudos

hi Rocio, It works. But i'm doing the validation for a column in my table. So, i want the red mark to be in the right row (right now, its always in the last row). Also, i want to stop any other actions, navigations etcs when this validation fails even for a single row. How could i achieve this? Here is my code. I have written my code in wdModify view as i felt thats the best place to make the validation work in every instance.


if (wdContext.nodeVn_ContactPersonaDetails().size() > 0) {

				for (int size = 0;
					size < wdContext.nodeVn_ContactPersonaDetails().size();
					size++) {
					String attrValue =
						wdContext
							.nodeVn_ContactPersonaDetails()
							.getVn_ContactPersonaDetailsElementAt(size)
							.getVa_lastName();
					if (attrValue == null) {

						IPrivateCreateCustomerInputView
							.IVn_ContactPersonaDetailsElement neCnt =
							wdContext.currentVn_ContactPersonaDetailsElement();
						wdThis
							.wdGetAPI()
							.getComponent()
							.getMessageManager()
							.reportInvalidContextAttributeException(
								neCnt,
								wdContext
									.nodeVn_ContactPersonaDetails()
									.getNodeInfo()
									.getAttribute(
									"va_lastName"),
								"Last Name field must be filled!",
								false);
						break;
					}
				}

Former Member
0 Kudos

Hi Kavita:

IPrivateCreateCustomerInputView.IVn_ContactPersonaDetailsElement theElement =wdContext.nodeVn_ContactPersonaDetails().getVn_ContactPersonaDetailsElementat(the for index);

then validate theElement and show the error useing theElement, if there´s an error break the loop.

If you do this validation is because an event fire a roundtrip so... why don´t you do this validation in the action´s eventhandler?

Good luck!.

Rocío.

Former Member
0 Kudos

Hi Nikhil,

For Example " FileName " is the Context Attribute and if u want to limit it's length to 10 Characters( Max Size ) then Write Code Like below.

if(wdContext.currentContextElement().getFileName().length()>10)

{

wdComponentAPI.getMessageManager().reportWarning("FileName Length should be less than or Equal to 10 Characters");

return;

}

With Regards,

Roop Kumar.

Former Member
0 Kudos

Hi Nikhil,

There is one more way.

Like creating one simple type under local dictionary with setting max length value in that.

And just set this as the type of the context attribute you created for this field.

This will restrict user to enter more that specified max length.

-Swati

Former Member
0 Kudos

Hi,

As for max length validation you can use the property "length" of the InputField.

All other checks must be done manually using code.

Aviad