• Viktor Iliukhin
  • NEWBIE
  • 10 Points
  • Member since 2019
  • Volga Dnepr

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
SF developers,

I need an advice. I have visual page with inputText 
<apex:page controller="inputIntegerCtrl">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!saveValue}" reRender="bs"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1" id="bs">
                <apex:inputText label="value" value="{!intValue}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public class inputIntegerCtrl {
    public Integer intValue {get;set;}
    public void saveValue() {
    }
}
When I try to delete variable value and press button "Save", value integer variable is becoming "0" instead of "null"
I found a page that describes this problem https://salesforce.stackexchange.com/questions/64339/apex-inputtext-bound-to-integer-takes-0-instead-of-null

I try to create string setter 
public class inputIntegerCtrl {
    public Integer intValue;

    public String getIntValue() {
        return String.valueOf(intValue);
    }

    public void setIntValue(string intValue) {
        if (intValue != null)
            this.intValue = Integer.valueOf(intValue);
    }

    public void saveValue() {
    }
}

But, now, i have error message "
Error: Read only property 'inputIntegerCtrl.intValue'"

Does anyone know how to solve this problem?
Hi gays
I have apex class
public class inputIntegerCtrl {
     public Integer intValue { get; set; }
     ......
}
and visual page
<apex:page controller="inputIntegerCtrl">
   <apex:inputText label="value" value="{!intValue}" />
...
</apex:page>

When I try to set "null" (empty) in apex:inputText, I get value "0" instead of "null". How set "null" value ?
 
SF developers,

I need an advice. I have visual page with inputText 
<apex:page controller="inputIntegerCtrl">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!saveValue}" reRender="bs"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1" id="bs">
                <apex:inputText label="value" value="{!intValue}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public class inputIntegerCtrl {
    public Integer intValue {get;set;}
    public void saveValue() {
    }
}
When I try to delete variable value and press button "Save", value integer variable is becoming "0" instead of "null"
I found a page that describes this problem https://salesforce.stackexchange.com/questions/64339/apex-inputtext-bound-to-integer-takes-0-instead-of-null

I try to create string setter 
public class inputIntegerCtrl {
    public Integer intValue;

    public String getIntValue() {
        return String.valueOf(intValue);
    }

    public void setIntValue(string intValue) {
        if (intValue != null)
            this.intValue = Integer.valueOf(intValue);
    }

    public void saveValue() {
    }
}

But, now, i have error message "
Error: Read only property 'inputIntegerCtrl.intValue'"

Does anyone know how to solve this problem?