1

I have two variables that are causing problems: “students” and “stuinclass”. Previously these variables were incrementing the number of classes (in a school, not Apex classes) contributing to a specific average, and everything worked fine. I needed to make the average weighted, so I changed the variable name and formula for establishing it. That broke my code.

The variables are producing the same error, but in different ways. One prevents me from saving the VF page (I'm using Eclipse, but I also tried within SF and had the same error) with the error message "Compilation error: Unknown property 'School_Implementation__cStandardController.students'". When I commented out the VF code that called the variable students, my page saved. But when I tried to run the page, I was redirected to a SF error page with the message "Unknown property 'SchoolImplementationController2.GradeWrapper.stuinclass'".

To make things more confusing, when I changed students to groupAstu, everything worked fine. Then I changed the definition of groupAstu to be the same as that of students, and everything worked fine.

Here's the code for students, which prevents me from saving the VF page:

Controller

[line 321]  public Decimal students {get; set;}
[line 326]  public void getSummaryPageMetrics(){
[line 338]      students =0;
                    for(Class_Implementation__c ci:classes){
                         for(Class_Metric__c cmet:ci.Class_Metrics__r){
                             students +=    (cmet.of_Students_in_Class__c!=NULL)    ? cmet.of_Students_in_Class__c : 0;

[code for lots of other variables with similar formulas that don’t cause problems here]

[line 353]          }
            }

        [other stuff]

[line 369]  }

VF Page

        <table class="noborder">     
        <tr>
            <td width="27%">Prev. Week:</td>
                <td style="text-align:right" width="6%">
                    <apex:outputText value="{0, number, ###.##'%'}" rendered="{!!ISNULL(students)&&students!=0}">
                        <apex:param value="{!groupA / students}" />
                    </apex:outputText>
                </td>
                <td width="1.5%"/>
            <td width="27%">Prev. Week:</td>
                <td style="text-align:right" width="9%"> 
                    <apex:outputText value="{0, number, ###.## hours}" rendered="{!!ISNULL(groupAstu) && groupAstu!=0}">
                        <apex:param value="{!groupHO / groupAstu}" />
                    </apex:outputText>
                </td>
                <td width="1.5%"/>
            <td width="24%">Total Reasoning Mind Teachers:</td>
                <td style="text-align:right" width="4%">
                    <apex:outputText value="{0, number, ##}">
                        <apex:param value="{!totalti}" />
                    </apex:outputText>
                </td>
        </tr>
    </table>

Here's the code for stuinclass, which throws the runtime error:

Controller

[line 531]  public void getGradeMap(){    
            for(Class_Implementation__c cimp:classes){
                for(Class_Metric__c cm:cimp.Class_Metrics__r){
                    if(!gradeMap.containsKey(cimp.Grade__c))
                        gradeMap.put(cimp.Grade__c, new GradeWrapper(cimp.Grade__c));

            GradeWrapper grade = gradeMap.get(cimp.Grade__c);      
            [lots of other variables with similar formulas that don’t cause problems]
                grade.stuinclass += (cimp.of_Students_in_Class__c!=NULL)     ? cimp.of_Students_in_Class__c: 0;
                    }
                }
            }   



[line 561]  public class GradeWrapper{
                public Integer stuinclass {get; set;} 
                public String grade {get; set;}

                public gradeWrapper(String grade){
                        stuinclass = 0;
                        this.grade = grade;
                 }
            }

VF Page

        <table class="summary">
    <apex:repeat value="{!wrappedSchools}" var="ws">
        <tr>
            <td style="border-left-color:white;text-align:left">{!ws.school.School__r.School_Nickname__c}</td>
            <apex:repeat value="{!ws.gradeMap}" var="gmKey">
                <td><!--Grade-Level Hours Online for the Week-->
                    <apex:outputText value="{0,number,###.##}">
                        <apex:param value="{!IF(ws.gradeMap[gmKey].stuinclass==0,0,ws.gradeMap[gmKey].HOWk / ws.gradeMap[gmKey].stuinclass)}"/>
                    </apex:outputText>
                </td>
                <td><!--Grade-Level Hours Online YTD-->
                    <apex:outputText value="{0,number,###.##}">
                        <apex:param value="{!IF(ws.gradeMap[gmKey].stuinclass==0,0,ws.gradeMap[gmKey].HOCuml / ws.gradeMap[gmKey].stuinclass)}"/>
                    </apex:outputText>
                </td>
                <td class="{!IF(IF(ws.gradeMap[gmKey].stuinclass==0,0,ws.gradeMap[gmKey].HOtarget / ws.gradeMap[gmKey].stuinclass)>=80, 'highlight', 'lightbg')}"><!--Grade-Level % Met Hours Online Target for the Week-->
                    <apex:outputPanel >
                        <apex:outputText value="{0,number,###.##}" id="HOTarget">
                            <apex:param value="{!IF(ws.gradeMap[gmKey].stuinclass==0,0,ws.gradeMap[gmKey].HOtarget / ws.gradeMap[gmKey].stuinclass)}"/>
                        </apex:outputText>
                    </apex:outputPanel>
                </td>               
            </apex:repeat> 
        </tr>
    </apex:repeat>
        </table>

I've tried to include just the relevant code without cutting anything important, but I'm pretty new to this, so apologies if I cut something important that you need to see to help me with my problem!

  • Can you please provide more information? It would be helpful to know where you are calling getSummaryPageMetrics as well has what is happening during the instantiation of your controller. – techbusinessman Sep 16 '14 at 22:46
  • I changed the names of the variables in my controller back to their original values, and everything worked. I'm not sure why the name of the variable should matter (provided it's used consistently). I used find and replace to ensure I replaced every instance.. ` public SchoolImplementationController2 (ApexPages.StandardSetController controller){ allSchools = controller.getSelected(); public PageReference GenerateReport(){ setUpLists(); PageReference p = Page.iwrTesting; p.setRedirect(false); return p; } }` – LHatRM Sep 23 '14 at 20:36
-1

the students variable in the 1st Controller block needs to be declared Integer students = 0; if it's not a property/variable of the class.

in the gradeWrapperClass constructor, try this.stuinclass = 0; instead of stuinclass = 0;

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.