+ Start a Discussion
amorganamorgan 

Properties don't work in Pages

I have this Controller:

public class TestPageCon {

    public class Row {
        public Integer closed {
            get{
                return 54;
            }
        }
    }
    
    public Row[] getRows() {
        Row[] rows = new Row[5];
        for (Integer i=0; i < 5; i++) {
            rows[i] = new Row();
        }
        return rows;
    }
}

I have this Page:

<apex:page controller="TestPageCon">
<apex:repeat var="row" value="{!rows}">
%{!row.closed}%<br/>
</apex:repeat>
</apex:page>



I expect this:


%54%
%54%
%54%
%54%
%54%

I get this instead:


%54%
%%
%%
%%
%%



Message Edited by amorgan on 02-02-2009 12:09 PM
Message Edited by amorgan on 02-02-2009 12:11 PM
JeremyKraybillJeremyKraybill

I can't tell you exactly why, but I bet this fixes it:

 

public class Row { private Integer closed = 54; public Integer getClosed() { return closed; } }

I've seen some similar oddities with the get/set builders, so now just always use the above pattern for getters/setters.

 

Jeremy Kraybill

Austin, TX