[SalesForce] Reason behind element value must resolve to a String type!

I faced an issue with <apex:inputText> while using disabled attribute with it.

The scenario is i can disable and enable the <apex:inputText> using a checkbox.

<apex:inputText> is binded with an Integer variable.

But when i enable the

<apex:inputText>

i get error : element value must resolve to a String type!

I tried these workarounds given in this post
apex:inputText disabled binding causing "element value must resolve to a String type!"

But the above workarounds changes the appearance , the goal is not achievable.

When i tried binding <apex:inputText> with String , the functionality worked fine , however now i have to make use of Integer.valueOf(myStringVariable) everywhere i need to do calculations in my code.

I just want to know the reason behind this error element value must resolve to a String type!

Why this doesn't work with integer value.

Best Answer

This looks to be a bug in Visualforce - its been around since 2008 by the look of this post on the Developerforce Discussion Boards:

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000951yIAA

The best I've been able to do with this is to have the underlying property still stored as an Integer, but have a string based getter/setter for it that converts to/from a string. That way I can use the property as an Integer within my code and I just have to convert it once.

You'll need an answer from Salesforce as to why it works this way - given that people have been complaining about this behaviour for nearly 6 years, it feels like they might think its working correctly. Although Doug Chasman does suggest its a bug in the developerforce post above.