4

I have one field "MyYear__c" on my custmon object. This field has following details:

Data Type: Number
Length: 4
Decimal Places: 0

At the visualforce page it looks like this:

<apex:inputField value="{!obj.MyYear_c}" required="true"/>

The user must fill this field out and then the outputPanel is re-rendered. After that there is a dot in this field:

enter image description here

Is there a way to remove the dot? I don't want to use any "not clear" solutions like Javascript. I want to know is there a "native" visualforce or apex solution for that. I know there are some workrounds, but only for the outputText, not for inputField.

Thank you.


Here my code:

Page:

<apex:pageBlock id="mainBlock">
    <apex:pageBlockSection columns="2">
        <apex:inputField value="{!obj.MyNumber__c}" required="true"/>
        <apex:commandButton value="Validate" action="{!doValidation}" reRender="mainBlock"/>
    </apex:pageBlockSection>
</apex:pageBlock>

Controller:

public MyObject__c obj { get; set; }

public MyClass(){
    obj = new MyObject__c();
}

public PageReference doValidation(){
    // Validation stuff here
    return null;
}
10
  • where comma is? I can only see dot.
    – doga
    Commented Feb 26, 2013 at 9:13
  • Can you post your controller code? Commented Feb 26, 2013 at 15:07
  • @KevinO'Hara Hey Kevin, i don't think it will help, but i've posted my code (very simplified). Commented Feb 26, 2013 at 16:15
  • 2
    Here's the idea to support number display formats. I think you'd need something like that if you want to use inputField and no JS. Commented Feb 26, 2013 at 16:50
  • 2
    Thanks to the constraints on the edit page, not in any way that would be desirable (ie a full override, but that defeats the page layout in general). Another option would be similar to your formula field solution, but instead of a formula field use a text field and then coordinate the validation and values between the two via workflows/triggers. So your "public" field would be text, and your value field would be the current one.
    – joshbirk
    Commented Feb 26, 2013 at 20:38

1 Answer 1

1

Have you tried using inputText in your Visualforce?:

<apex:inputText value="{!obj.MyNumber__c}" required="true"/>

You will need to validate that the text is a number in your controller.

You will also need to make use of a formula field for standard UIs.

1
  • I will accept this answer as only solution for the "problem", apparently there are no other "native" solutions. Thanks Stephen. Commented Feb 27, 2013 at 7:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .