cancel
Showing results for 
Search instead for 
Did you mean: 

Nullable InputField with Integer Simple Type

tobit_kollenberg
Explorer
0 Kudos

Hi all,

I have an InputField with a corresponding integer simple type that is not nullable. The inputfield has state required. The problem is, when the user removes all characters from the the inputfield and presses a button, WebDynpro will automatically set the value to '0'. The values will now be written into the database, even if the user does not wanted to use '0' as value. The "required" state does not work in this case.

is there a way to distinguish between an empty InputField and the value '0' in the field, if the corresponding simple type is an integer?

Cheers,

Tobit

Accepted Solutions (1)

Accepted Solutions (1)

wozjac
Product and Topic Expert
Product and Topic Expert
0 Kudos

I don't think so - backing type is primitive integer, which have default start value 0 and don't have "null" value.

Try with to assign type com.sap.dictionary.predefined.objecttypes.integerObject to as a context attribute type.

or you can use string type and do needed conversion in your logic.

Regards,

Jacek

tobit_kollenberg
Explorer
0 Kudos

Thanks for the reply. Even if I don't understand why that works (the object version is also presented as a simple type...) it is very useful. But my next problem is: How can I configure minimum and maximum values on that integerObject datatype, so that the user input is automatically validated by the Web Dynpro framework?

Cheers,

Tobit

wozjac
Product and Topic Expert
Product and Topic Expert
0 Kudos

Did you create your simple type in Dictionary, based on integer simple type?

tobit_kollenberg
Explorer
0 Kudos

Yes, in the Local Dictionary of the project.

wozjac
Product and Topic Expert
Product and Topic Expert
0 Kudos

And in the last tab in this type ("Database") do you have "Not null" selected?

tobit_kollenberg
Explorer
0 Kudos

I have tried it with "nullable" and "not nullable" (not nullable is the way the representation of the integerObject works), but both does not work on the simple integer type.

wozjac
Product and Topic Expert
Product and Topic Expert
0 Kudos

With "not null" there will be always initial value written to a database

http://help.sap.com/saphelp_nwce10/helpdata/en/9c/1c713eeaac5441e10000000a114084/content.htm

integerObject initial value is null and, in turn, it gives empty string as initial value.

So you can use primitive integer and make some additional logic in code responsible for database save or use integerObject and add custom validation.

Regards,

Jacek

tobit_kollenberg
Explorer
0 Kudos

Yes, thats of course a solution. But I searched for a way to use the Web Dynpro validation and addtionally provide the possibility to insert null. But it seems like that doesn't work.

Anyhow, thanks for your help.

Answers (0)