cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt on Validation......

Former Member
0 Kudos

Hi all,

I have a particular InputField.

When i don’t enter the Number in one particular field,the system should take 1 as the value by default .

Can anyone help me out in this regard.

Thanks and regards,

Chandrashekar.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Do it manually using this

if(wdContext.currentContextElement().get<InpField>()==null ||

wdContext.currentContextElement().get<InpField>().length==0)

{

wdContext.currentContextElement().set<InpFields>("1");

}

Regards

LakshmiNarayana

Answers (2)

Answers (2)

Former Member
0 Kudos

You should set it's value to 1 by default then, as Siva Rama Krushna said.

The problem i see is, that if you leave empty an inputfield bound to a numeric context, dynpro framework will activate its automatic validation, and will paralyze your action code execution until a valid number has been entered.

So again, set 1 as default value, and change it if needed.

Regards,

Julio

former_member197348
Active Contributor
0 Kudos

Hi Chandra,

If your context attribute bound to the field is int. Just do like this.

if ( wdContext.wdCurrentContextElement().get<attrbute>()==0 )

{

wdContext.wdCurrentContextElement().set<attrbute>("1");

}

But if it is a String do like the following.

if ( wdContext.wdCurrentContextElement().get<attrbute>()== null || wdContext.wdCurrentContextElement().get<attrbute>().trim().length()==0 )

{

wdContext.wdCurrentContextElement().set<attrbute>("1");

}

One more suggestion:

Using this in wdDoInit() wdContext.wdCurrentContextElement().set<attrbute>("1");

if you set all attributes to "1" default. Then it will be more easy.

Hope this is helpful.

regards,

Siva