You need to sign in to do that
Don't have an account?
cedg
Error: Unknown property in VFpage with custom controller
I'm becoming mad with this error. I checked the similar post . In those i see the error and in my code i don't see anything wrong.
Error is : Error: Unknown property 'CO01_RegSport_Data.RegistrationChild.indexChild'
The VF page is :
<apex:pageBlockTable value="{!data.regChildren}" var="child"> <apex:column > <apex:facet name="header">number</apex:facet> <apex:outputText value="{!child.indexChild}" /> </apex:column> <apex:column > <apex:facet name="header">{!labels.FirstName__c}</apex:facet> <apex:inputField value="{!child.reg.Firstname__c}" /> </apex:column> </apex:pageBlockTable>
{!child.reg.Firstname__c} is working fine, but not {!child.indexChild}
and the controller is :
public class CO01_RegSport_Data{ private Registration__c regMain; private List<RegistrationChild> regChildren; public CO01_RegSport_Data(String userId, CO01_RegSport mainclass){ ... } public Registration__c getRegMain(){return regMain;} public List<RegistrationChild> getRegChildren(){return regChildren;} public PageReference addRegistrationChild(){ if (regChildren == null) regChildren = new List<RegistrationChild>(); regChildren.add(new RegistrationChild(regMain, 'Child', this, empl, regChildren.size()+1)); return null; } public class RegistrationChild{ private Registration__c reg; private Registration__c regParent; private CO01_RegSport_Data data; private Employee__c empl; private Integer indexChild; public RegistrationChild(Registration__c regParent, String relation, CO01_RegSport_Data data, Employee__c empl, Integer indexChild){ reg = new Registration__c(); ... this.indexChild = Integer.valueOf(indexChild); } public Integer getIndexChild(){return indexChild;} public Registration__c getReg(){return reg;} } }
Please help me. Tnx in advance.
From your sample code I created a Registration__c custom object with field Firstname__c, 2 classes and a VF page and it compiles fine. I run the page [salesforce.com/apex/RegSport] and I see a '1' and the name 'Bill' in a table.
[Note: I had to remove references to Employee__c since theres no clue as to what it is, and I initialised regChildren with 1 row]
VF page
Class
Class
All Answers
What does data refer to in this line ? Could you remove it ? {!regChildren} would work I think (from your code snippet).
sorry, i forgot to mention :
the real controller is the class CO01_RegSport which instantiates the class CO01_RegSport_Data
so, {!data....} shouldn't be the problem as i use it for all other fields.
If you comment out that first visualforce column does it give a similar error about Firstname__c ?
I'm wondering if its a visibility issue with the inner class.
if i comment the first column, i've no error, it's working fine but i need this index.
In fact the original problem is i would like to know the index of a each row of the table so as to use in some JS.
So i put the indexChild as a property buty i can't reach it while i can reach the other properties.
perhaps try this approach
or would this work for you:
http://blog.jeffdouglas.com/2010/04/02/visualforce-row-counter-for-iteration-components/
I checked the example of Jeff Douglas and i think it's the same.
his class "DataTableWrapper" corresponds to my class "RegistrationChild"
his "counter" is my "indexChild"
a stupid question : i replaced
by
and now i've error in the class CO01_RegSport when calling data.someitem.getReg().Lastname__c (Method does not exist or incorrect signature:)
I'm new in Apex dev, but it's the same isn't it ???
It might need to be public, not private.
I think you'll need to recompile (save) both classes.
From your sample code I created a Registration__c custom object with field Firstname__c, 2 classes and a VF page and it compiles fine. I run the page [salesforce.com/apex/RegSport] and I see a '1' and the name 'Bill' in a table.
[Note: I had to remove references to Employee__c since theres no clue as to what it is, and I initialised regChildren with 1 row]
VF page
Class
Class
indeed , by deploying with Eclipse,it's working. I was changing directly in salesforce ...
Thanks for your help and your time, Colin