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
Daniel MasonDaniel Mason 

Error: Unknown property 'testWrapper.materialWrapper.select'

Afternoon All, 

I am trying to save my VF page but i am getting the following error "Error: Unknown property 'testWrapper.materialWrapper.select' ". 

Aim - The user will go to the sales_and_marketing__c object ,scroll down to the Materials_Junction related list. click "new", this should then call the VF page listed below. and return all the records from the Materials object which are active (Crtieria in Class). The user then selects the Materials, fills in quantity. When the User Saves this should then be mapped back to the sales_and_marketing__c object

Really appreciate your help 

I have the following Controller : 

public with sharing class testWrapper
{
    public List<Materials__c> Materials {get;set;} 
    public List<materialWrapper> materialWrapperList {get;set;} 
    
    public testWrapper()
    {
        Materials = [select ID,name,Product__c, Item__c,Quanity__c, Active__c from Materials__c where Active__c =true limit 10];
        for(Materials__c obj : Materials)
        {
            materialWrapper tempObj= new materialWrapper();
            tempObj.recordId = obj.id;
            tempObj.name = obj.name;
            tempObj.product = obj.Product__c;
            tempObj.item = obj.Item__c;
            tempObj.quantity = obj.Quanity__c;
            tempObj.selectB = false;
            materialWrapperList.add(tempObj);
        }
    }

    //save method
    public void save()
    {
        list<Materials_Junction__c> recordToInsert = new list<Materials_Junction__c>();
        
        for(materialWrapper obj : materialWrapperList)
        {
         Materials_Junction__c temp ;
            if(obj.selectB == true)
            {
                temp = new Materials_Junction__c();
                temp.sales_and_marketing__c = '01I20000000rV6V';
                temp.Materials__C= obj.recordId;
                temp.quantity__C = obj.quantity; 
            }
            recordToInsert.add(temp);
        }
        insert recordToInsert;
    }
    
    
    public class materialWrapper
    {
        public string recordId {get; set;}
        public string name {get; set;}
        public string product {get; set;}
        public string item {get; set;}
        public Decimal quantity {get; set;}
        public boolean selectB {get; set;}
        
        public void materialWrapper()
        {
            recordId = '';
            name = '';
            product = '';
            item = '';
            quantity = 0.0;
            selectB = false;
        }
    }
}

Visual Force Page :

apex:page controller="testWrapper">
<apex:form >
    <apex:pageBlock title="Select Product">

        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlockButtons>

        <apex:pageBlockTable value="{!materialWrapperList}" var="MKT"> 
            <apex:column value="{!MKT.select}"/>
            <apex:column value="{!MKT.name}"/>       
            <apex:column value="{!MKT.Product}"/>
            <apex:column value="{!MKT.Item}"/>
            <apex:column headerValue="Quanity">
                <apex:inputField value="{!MKT.Quanity}"/>
            </apex:column>

        </apex:pageBlockTable>

    </apex:pageBlock>
</apex:form>
Best Answer chosen by Daniel Mason
Magesh Mani YadavMagesh Mani Yadav
Hi Daniel,

i have updated you code. should work for you.
public with sharing class testWrapper
{
    public List<Materials__c> Materials {get;set;} 
    public List<materialWrapper> materialWrapperList {get;set;} 
    
    public testWrapper()
    {	
        materialWrapperList = new List<materialWrapper>();
        Materials = [select ID,name,Product__c, Item__c,Quanity__c, Active__c from Materials__c where Active__c =true limit 10];
        for(Materials__c obj : Materials)
        {
            materialWrapper tempObj= new materialWrapper();
            tempObj.recordId = obj.id;
            tempObj.name = obj.name;
            tempObj.product = obj.Product__c;
            tempObj.item = obj.Item__c;
            tempObj.quantity = obj.Quanity__c;
            tempObj.selectB = false;
            materialWrapperList.add(tempObj);
        }
    }

    //save method
    public void save()
    {
        list<Materials_Junction__c> recordToInsert = new list<Materials_Junction__c>();
        
        for(materialWrapper obj : materialWrapperList)
        {
         Materials_Junction__c temp ;
            if(obj.selectB == true)
            {
                temp = new Materials_Junction__c();
                temp.sales_and_marketing__c = '01I20000000rV6V';
                temp.Materials__C= obj.recordId;
                temp.quantity__C = obj.quantity; 
                recordToInsert.add(temp);
            }
            //recordToInsert.add(temp); you are adding element outside the if condition that the reason for save button error
        }
        insert recordToInsert;        
    }
    
    
    public class materialWrapper
    {
        public string recordId {get; set;}
        public string name {get; set;}
        public string product {get; set;}
        public string item {get; set;}
        public Decimal quantity {get; set;}
        public boolean selectB {get; set;}
        
        public void materialWrapper()
        {
            recordId = '';
            name = '';
            product = '';
            item = '';
            quantity = 0.0;
            selectB = false;
        }
    }
}

 

All Answers

Magesh Mani YadavMagesh Mani Yadav
Hi Daniel,

It seems that you have missed 'B'
Replace this
<apex:column value="{!MKT.select}"/>
with the below
<apex:column value="{!MKT.selectB}"/>

Should work now.
 
Daniel MasonDaniel Mason

Hi Magesh, 

Updated VF page to 

<apex:page controller="testWrapper">
    <apex:form >
        <apex:pageBlock title="Select Product">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>

            <apex:pageBlockTable value="{!materialWrapperList}" var="MKT"> <!-- for loop of contact in Materials -->
                <apex:column value="{!MKT.selectB}"/>
                <apex:column value="{!MKT.name}"/>       
                <apex:column value="{!MKT.Product}"/>
                <apex:column value="{!MKT.Item}"/>
                <apex:column headerValue="Quanity">
                    <apex:inputField value="{!MKT.Quanity}"/>
                </apex:column>

            </apex:pageBlockTable>

        </apex:pageBlock>
    </apex:form>
</apex:page>
 

But i know get ' Error: Could not resolve the entity from <apex:inputField> value binding '{!MKT.Quanity}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.'

 

Magesh Mani YadavMagesh Mani Yadav
Again you have spelling mistake!
replace 'Quanity' with 'quantity' 
Daniel MasonDaniel Mason

HI Magesh, 

Still the same error "Error: Could not resolve the entity from <apex:inputField> value binding '{!MKT.quantity}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable."

Magesh Mani YadavMagesh Mani Yadav
Hi Daniel,
the MKT.quantity is a variable not the sobject filed so you need to use <apex:inputText value={!MKT.quantity} /> instead of <apex:inputField>
Daniel MasonDaniel Mason

HI Magesh, 

Its allowed me to save the visual force page. When i click on the "preview" button i get the following error 

System.NullPointerException: Attempt to de-reference a null object 
Class.testWrapper.<init>: line 18, column 1

 

Do you have 5mins so we can discuss ? 

Magesh Mani YadavMagesh Mani Yadav
Hi Daniel,
In the constructor you need to declare "materialWrapperList"
like this
materialWrapperList = new List<materialWrapper>();
Daniel MasonDaniel Mason
Hi magesh,

Do you have 5 mins to go through this ? I am a little confused .
Magesh Mani YadavMagesh Mani Yadav
yes sure
Daniel MasonDaniel Mason
Drop me an email on djmason2001@googlemail.com And we can discuss offline Your help is much appreciated
Magesh Mani YadavMagesh Mani Yadav
Hi Daniel,

i have updated you code. should work for you.
public with sharing class testWrapper
{
    public List<Materials__c> Materials {get;set;} 
    public List<materialWrapper> materialWrapperList {get;set;} 
    
    public testWrapper()
    {	
        materialWrapperList = new List<materialWrapper>();
        Materials = [select ID,name,Product__c, Item__c,Quanity__c, Active__c from Materials__c where Active__c =true limit 10];
        for(Materials__c obj : Materials)
        {
            materialWrapper tempObj= new materialWrapper();
            tempObj.recordId = obj.id;
            tempObj.name = obj.name;
            tempObj.product = obj.Product__c;
            tempObj.item = obj.Item__c;
            tempObj.quantity = obj.Quanity__c;
            tempObj.selectB = false;
            materialWrapperList.add(tempObj);
        }
    }

    //save method
    public void save()
    {
        list<Materials_Junction__c> recordToInsert = new list<Materials_Junction__c>();
        
        for(materialWrapper obj : materialWrapperList)
        {
         Materials_Junction__c temp ;
            if(obj.selectB == true)
            {
                temp = new Materials_Junction__c();
                temp.sales_and_marketing__c = '01I20000000rV6V';
                temp.Materials__C= obj.recordId;
                temp.quantity__C = obj.quantity; 
                recordToInsert.add(temp);
            }
            //recordToInsert.add(temp); you are adding element outside the if condition that the reason for save button error
        }
        insert recordToInsert;        
    }
    
    
    public class materialWrapper
    {
        public string recordId {get; set;}
        public string name {get; set;}
        public string product {get; set;}
        public string item {get; set;}
        public Decimal quantity {get; set;}
        public boolean selectB {get; set;}
        
        public void materialWrapper()
        {
            recordId = '';
            name = '';
            product = '';
            item = '';
            quantity = 0.0;
            selectB = false;
        }
    }
}

 
This was selected as the best answer