My VF tags:

<apex:column >
    <apex:facet name="header">Sales Price</apex:facet>
    <apex:inputText value="{!prod.SalesPrice}"/>    

Controller code:

public string SalesPrice{get; set;}
oli.UnitPrice =decimal.valueOf(pi.SalesPrice);

It works when a user insert 15 and 15.00 but it doesn´t with 15,00(comma).

I m using apex:inputText linked to a controller apex property because apex:inputfield is not allowed.

I´ve tried with apex:input with type=number but it doesn´t look good, (small button to increase/decrease inserted value). Is there another Visualforce tag that i can use with a property? Is the only solution to replace comma with dot in the controller?

  • Shouldn't this depend on user locale ? As far as I know comma as decimal separator works if your user is configured with such settings. Oct 27, 2014 at 13:24
  • Thanks Samuel, problem for me is that with commas fails with decimal.valueOf conversion; and i can´t use directly OpportunityLine Item field (unitprice )in my visual force page.
    – Enry
    Oct 27, 2014 at 15:34
  • as you've probably figured out, apex:inputText transmits a string as typed to the controller field's setter and then you are stuck parsing this. As an alternative consider binding your VF field via inputField to some proxy Sobject with field of type Number.
    – cropredy
    Oct 27, 2014 at 17:51

2 Answers 2


Since you are simply assigning to the UnitPrice field on OpportunityLineItem you could instead expose the OpportunityLineItem record to the controller and use apex:inputField to bind directly to the UnitPrice field.

In your controller:

public OpportunityLineItem oli { get; set; }

Then in your Visualforce page:

<apex:inputField value="{!oli.UnitPrice}"/>

UPDATED: You can use standard html tag and parse using JS and pass on to Controller.

  • Thanks but i ve already tried with it. It s in the question description.
    – Enry
    Oct 27, 2014 at 10:38
  • @Enry i would suggest you an option to invoke the javascript first and then the controller method, during your submission(using ActionFunction). In the javascript, collect the SalesPrice text boxes and remove comma using regex (replace method ). You can collect the Salesprice text boxes easily by using a custom styleClass for the apex:inputText and use getElementsByClassName.
    – Vignex
    Oct 27, 2014 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.