1

I have the following object definition:

component persistent="true" table="settings" hint="Settings" extends="coldbox.system.orm.hibernate.ActiveEntity" {

property name="id" fieldtype="id" generator="native";
property name="type" ormtype="string" length="10" index="setting_type";
property name="name" ormtype="string" length="20" index="setting_name";
property name="ownerID" ormtype="integer" index="setting_ownerID";


property name="valueNumber" ormtype="float";



//return the appropriate value
public function getValue(){
        return this.getValueNumber();
}

The problem I am having is that this.getValueNumber() is returning the number, but with spaces in front of it.

Wrapping it in trim() trim(this.getValueNumber()) doesn't remove the space before the number.

This doesn't seem to cause an issue when working with the number in CF, but it does when I place the number into a JS function and attempt to work with it in JS.

Has anyone come across this problem? Any way to stop it? It is happening on both cf9, cf10 and Railo 4.0.

Fish Below the Ice
  • 1,273
  • 13
  • 23
Jason
  • 1,957
  • 2
  • 20
  • 34
  • 1
    How do you know that there are spaces before the number? – Antony Jun 12 '14 at 04:32
  • If trimming it doesn't remove the space, then it's not simply a space character (ASCII char 32) or a tab character (char 9). It might be something like ` ` – duncan Jun 12 '14 at 08:13
  • 1
    Make sure your function and or component is explicitly setting `output='false'`. – Fish Below the Ice Jun 12 '14 at 12:38
  • Can you paste the value with the leading 'space' into the question? What type is the valueNumber defined as in the database? – Ryan Guill Jun 12 '14 at 15:00
  • You have not provided the code that demonstrates `getVallueNumber()` generating unwanted white space, nor the code that actually invokes any of this. Which are kinda of necessary pieces of the puzzle. It will almost certainly be unrelated to the code you have provided here, and entirely down to not having `output="false"` on some tag-based code, or similar. – Adam Cameron Jun 12 '14 at 20:11
  • Thanks All.. I can see the spaces when dumping out this.getValueNumber(). Even if dumping this.getValueNumber() directly, before being passed up through other functions. I am actually starting to wonder if the Coldbox ActiveEntity is overriding the implicit getter and being the cause of the problem. Still investigating.. will post findings. Thanks – Jason Jun 12 '14 at 23:56
  • Did you every get to the bottom of this? I'm just running into this now. Very strange! – philcruz Nov 12 '15 at 23:29
  • Hi Phil, No. Never did. In the end had to give up and write straight SQL to get the values. Are you using ColdBox? – Jason Nov 17 '15 at 08:51

0 Answers0