I use a TextField<Float> as shown below. Since this field represents a
currency unit (in this case, pound sterling) I want to have two decimal
places shown always. For example:
  0.00
  5.00
  6.10
  3.28.

What I find when I run my web application is that, after form submission,
the model's Float value is always shown without any trailing zeroes in the
decimals. To use the same examples again, I get:
  0
  5
  6.1
  3.28.

Is there anything simple I can do to get my component to display two decimal
places always?

(Failing this, I intend to work around my problem by changing the
TextField<Float> to a TextField with a String for its model, and converting
this String to a Float value myself after form submission.)


HTML mark-up
------------
  &lt;input type="text" wicket:id="flPriceInPounds" size="10"/&gt;


Java code (within a WebPage)
----------------------------
  Form frmForm = new Form("frmForm")
  {
    [...]
  };
  frmForm.setModel(new CompoundPropertyModel([...]));
  add(frmForm);

  TextField<Float> txtMriceInPounds =
   new TextField<Float>("flPriceInPounds", Float.class);
  frmForm.add(txtPriceInPounds);


Java code: declaration within the form's compound property model
----------------------------------------------------------------
  public Float flPriceInPounds = null;


Regards,

Ian Marshall
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Displaying-decimal-places-using-a-TextField-Float-tp3074547p3074547.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to