cancel
Showing results for 
Search instead for 
Did you mean: 

Validation of InputField

Former Member
0 Kudos

Hallo all!

I've got an InputField in a WebDynpro (Java) that has to be a required field. So I've set the state of this field to "required" and defined a simpletype with Built-In Type "string", min-length=1 and max-length=50. This simpletype is bound to the contextelement that is bound to the Inputfield.

The problem now is that the framework still allows the InputField to be empty. According to the described configuration I would have expected the framework to reject an empt field.

Is there any chance to let the framework do this validation?

Thanks for any help in advance!

Michael

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can write the following code onActionEnter of your inputField or wherever you want:

IWDMessage msg = new WDMessage(wdThis.wdGetAPI().getComponent() , "MissingInput", WDMessageType.ERROR , "Enter some Values");

IWDAttributeInfo addrTypeInfo = wdContext.node<Your Node>().getNodeInfo().getAttribute(IPrivate<View Name>.I<Your Node>Element.<ATTR_NAME>);

if(wdContext.node<Your Node>().current<Your Node>Element().get<Attr Name>() == null)

{

wdComponentAPI.getMessageManager().reportContextAttributeMessage(wdContext.node<Your Node>().getCurrentElement(),addrTypeInfo, msg, new Object[] {},false);

wdComponentAPI.getMessageManager().cancelNavigation();

Hope this will solve your problem.

thanks & regards,

Manoj

Answers (3)

Answers (3)

Former Member
0 Kudos

I've got an InputField in a WebDynpro (Java) that has to be a required field. So I've set the state of this field to "required" and defined a simpletype with Built-In Type "string", min-length=1 and max-length=50. This simpletype is bound to the contextelement that is bound to the Inputfield.

Hi all,

I have a question here. So even if we specified the min length and max length, we would still need to do the manual coding of the validation in the implementation?

regards

Former Member
0 Kudos

Hello,

I'd like to add a question:

If I use a form with a required string input field and an integer input field, I seem to have the following choices:

1. I let Web Dynpro perform automatic validation on the int field. The validation of the string field must, however, be performed in my action handler. Since the action handler will not be invoked when WD detects validation errors (phase model: "validate modified data" comes before "application event handlers", thus skipping the latter on errors), if a user did not type in anything, he will first see the WD message for the int field. After correcting his input, my own validation for the string field will be executed, now prompting the user (a second time) for the second field.

2. I perform all validation myself. This enables me to present all validation errors at once but requires some tedious coding.

Is this true? If so, then in my opinion the built-in validations are somewhat useless; I would have to resort to option 2. Or use frameworks like JSF and Struts with good data vaidation concepts.

Best regards

Former Member
0 Kudos

Hi,

first of all, thanks for the quick replies!

@Siva:

I tried this your suggestion but it didn't work. Maybe because I still have to use NWDS2004s SP11???

@Manjo:

That's exactly what I was looking for!!!!

Michael

Former Member
0 Kudos

hi Michael,

First create an error message in message manager with some key(MissingInput).

write this code where you want to check the inputfield value.

String value=wdcontext.node(your node).current(your contextnode element).get(your inputname);

if(val==null )

{

IWDMessageManger msgMgr=wdComponentApi.getMessageManager();

msgMgr.reportMessageAsTextAtrribute(wdContext.node(Cn),wdContext.node(Cn).currentElement.getAttributeInfo,IMessageManagerComp(YourCompName).MISSININPUT,null,true);

}

former_member197348
Active Contributor
0 Kudos

Hi Michael,

I am not sure but try this.

Open the simpleType.

In DataBase tab of simpleType select NotNull checkbox.

regards,

Siva