cancel
Showing results for 
Search instead for 
Did you mean: 

How can we remove zero from Integer type input field in webdynpro java ?

Former Member
0 Kudos

Hi All,

When i run my webdynpro java application with integer type input field.It show 0 in input field default,i want blank input field .how can i do ?

Thanks and regards

Sumit Shrivastava

Accepted Solutions (0)

Answers (2)

Answers (2)

Sharathmg
Active Contributor
0 Kudos

default value of int is zero. it will show it.

As suggested by Robin, then u may have to use string and convert it to Integer Object and push to your model.

Keep one value attribute of type string. Accept user input and then convert it to integer before executing the model. Set the converted integer value to model's input params and execute it.

Note: Mind you, by doing this you increase the cases of validation. Ex: null value, characters and unknown symbols can be entered in this attribute. So, you may have to additionally check for these while converting to int. If its worth the effort, pls. go ahead and do it.

Regards,

Sharath

Former Member
0 Kudos

hi robin ,sarath,

Actually i need input field with integer type symbol without 0.

former_member197472
Active Participant
0 Kudos

Hi Sumit,

Not possible in Webdynpro java..

Use string type attribute. And on Change event parse it to integer.

**Use regex for validating entered string(input) first.

*Agree with Sharath

--

Regards,

Amey

Sharathmg
Active Contributor
0 Kudos

Try to use " inputPrompt" if you are working on 7.3. Its similar to field displaying text which disappears after typing.

Else, add the ruppe symbol to the label.

Then, use a string variable to the input field.

Later, convert value to integer object and call the model.

Regards,

Sharath

Qualiture
Active Contributor
0 Kudos

This is just meant as a tip, but I would reconsider if entering an empty value in a field used for calculations is really what you want. Logically it doesn't make any sense, and it may confuse your users as well

amol_gaddamwar
Explorer
0 Kudos

Hi Sumit,

As Amey Palve sid, it is not possible in Web Dynpro JAVA.

Also i guess it is even not possible in any technology using JAVA atleast.

All variables will be set to it's default value when created. It may be basic datatype or Object.

As 0 is the defaut value for int it will be set to 0 and null is the default value for String it will be set to null.

Regards,

Amol

Former Member
0 Kudos

Hi Robin,

if u have remember,when we insert value in input field then u need to remove that zero to insert your value in inputfield. so i wanted to overcome from that problem.

Qualiture
Active Contributor
0 Kudos

Aha, now that is indeed a valid point A theoretical solution could be that on selecting/entering the field, the 0 vanishes (or is pre-selected in order to instantly overwrite), but then again, sometimes a zero is just as intended.

As a workaround, you could use the Tab key to navigate to your input field, which in effect selects the entire value of that field. By typing in a new value, this would overwrite the selected value.

But I agree, the mandatory deletion of the initial zero in favor of another value is indeed a PITA 😉

Sharathmg
Active Contributor
0 Kudos

PITA, it is.

Sumit,

It will add unnecessary code which may or may not accomplish this. A workaround will be a burden on the performance.

It is more a nice to have feature which addresses some users. Considering this day and age, people will be able to delete a zero while typing numbers.

Try to engage with the stakeholders who are requesting thsi feature and explain the futility in implementing this feature.

Thats your best bet.

Regards,

Sharath

Qualiture
Active Contributor
0 Kudos

In Java, that is simply not possible, since an empty value or null is not a valid value for int.

You may revise your model to see if you really need an int in this case. If you do, you could use a String or Integer object, and convert to an int afterwards, but then again it makes no sense to fill in a blank anyway.