function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
d3developerd3developer 

Visualforce component nullifies width and height variables

Vaguely recall seeing this before but couldn't find any previous discussion so here we go:

 

If you use a variable named "width" or "height" in your Visualforce component the value will be reset to null (or to an empty string) even if you initialize it.

 

Example controller method:

 

 

public void init() {

  height = '200';

}

 

 

Example visualforce page:

 

 

height: {!height}

 

 

Example output:

 

 

height: 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
d3developerd3developer

Solution:

 

Use a different variable name.

All Answers

d3developerd3developer

Solution:

 

Use a different variable name.

This was selected as the best answer
Jeremy.NottinghJeremy.Nottingh

"Doctor, it hurts when I do this!"

 

"So don't do that."

 

I try to avoid using short, common words as properties, so as not to run into stuff like this. I bet it was fun troubleshooting this problem, though! Thanks for sharing.

 

Jeremy

d3developerd3developer

 

thanks for the encouragement!

 

I just hope that some googling developer gets the right thread identifying the problem so they don't make as many holes in the wall as I do (some times the wall loses, sometimes it is my head).

 

d3developerd3developer

Same behavior for "rowNumber"

d3developerd3developer

And "rowOptions"

 

Crazy!