+ Start a Discussion
theitdeptrockstheitdeptrocks 

Error: Unknown property 'Photo__cStandardController.render'

Hi all,


I was wondering if anyone could help me out with this error message.  The ultimate end goal is a getter method that could be passed a field's API name, check against two maps to determine if it should be rendered or not.

 

I'm currently caught up with this:  Error: Unknown property 'Photo__cStandardController.render'

 

public with sharing class test3 {
    public map<string,integer> st = new map<string,integer>();
    public map<string,integer> rt = new map<string,integer>();
   
    private final Photo__c p;
    public boolean getrender(string a){
    
        integer x;
        integer y;
        
             x = rt.get(a);
             y = st.get(a);
             if(x*y==0){
                 return false;
             }
             else{
                 return true;
             }
        

    } 

    public test3(ApexPages.StandardController controller) {
        this.p = (Photo__c)controller.getRecord();
        st = new map<string,integer>();
        rt = new map<string,integer>();
        if(p.Pose__c == 'Service Type 1'){
            this.st.put('Collection__c',1);
            this.st.put('Location__c',0);
        }
        if(p.Collection__c == 'Record Type 1'){
            this.rt.put('Collection__c',1);
            this.rt.put('Location__c',0);
        }
    }
}


<apex:inputField value="{!Photo__c.Collection__c}" rendered="{!render['Collection__c']}" />

I would greatly appreciate any help you could provide with this.  Thanks in advance!

bob_buzzardbob_buzzard

You can't pass parameters to getter methods in Visualforce.

 

The nearest you'll be able to get to this is to build a third map that is keyed by the field name and contains the boolean value that indicates if it should be rendered or not.  You can then pull this value from the Map inside the page.  You'll need to set this map up in advance though.

theitdeptrockstheitdeptrocks

Thanks Bob for both replies - really grasping at straws here to meet the project's deadline.

 

So it sounds like I'm in a corner when it comes to making this fairly dynamic with a minimal amount of code.  For the current record, would I be able to use an if statement to determine what the values within that map end up being?

 

Example:

if(p.Pose__c == 'Service Type 1' && p.Collection__c == 'Record Type 1'){
    this.newMap.put('Collection__c',1);
    this.newMap.put('Location__c',0);
}
else if(p.Pose__c == 'Service Type 2' && p.Collection__c == 'Record Type 2'){
    this.newMap.put('Collection__c',0);
    this.newMap.put('Location__c',0);
}
...and so on

 Unfortunately there are about 120 possible combinations and realistically 30 combinations of the two controlling fields currently in use. 

 

Would I be better with an approach like the above, creating a map, but assigning the key and values through if/else if statements or creating unique VF formulas for each apex:inputfield's rendered parameter?  The first seems cleaner, but not sure of other consequences.

 

Again, thanks!

bob_buzzardbob_buzzard

The first has the advantage that you only have one place to change things if the rules change, rather than striping it through the page.  It also fits better with MVC in terms of the logical separation of presentation from logic.  I can't think of another obvious solution to this at the moment.  If any synapses do fire I'll post back here.