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
prasanth kumarprasanth kumar 

visual force page showing error as unknown component. please help


Error: Unknown property 'zipcodes2.pcode

vf code:- 








apex code:-
public class zipcodes2 {
List pcode{set;get;}

public zipcodes2()
{
pcode = [SELECT Id FROM Postal_codes__c] ;

    }

}

 
Best Answer chosen by prasanth kumar
Amit Chaudhary 8Amit Chaudhary 8
Please try below code :-

Class:-
public class zipcodes2 
{
public List<Postal_codes__c> pcode{set;get;}

	public zipcodes2()
	{
		pcode = new List<Postal_codes__c>();
		pcode = [SELECT Id,Name FROM Postal_codes__c] ;
	}

}
Page should be :-
<apex:pageBlock title="p code">
        <apex:pageBlockTable value="{!pcode}" var="item">
            <apex:column value="{!item.name}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>

Please mark this as solution if this will help you, So that is some has same issue this post can help

Thanks
Amit Chaudhary

All Answers

Chamil MadusankaChamil Madusanka
Try this code 
 
public class zipcodes2 {
public List pcode{set;get;}

public zipcodes2()
{
pcode = new List();
pcode = [SELECT Id FROM Postal_codes__c] ;

    }

}

If you get the answer, please mark it as the correct answer. It will be a help to others who are facing the same problem later.
 
SarfarajSarfaraj
Or you may try lazy load. It has its own benifits,
 
public class zipcodes2 {
	public List pcode{get
									{
										return [SELECT Id FROM Postal_codes__c];
									} set;}
}

Also probably you may have missed the type of the List.
Amit Chaudhary 8Amit Chaudhary 8
Please try below code :-

Class:-
public class zipcodes2 
{
public List<Postal_codes__c> pcode{set;get;}

	public zipcodes2()
	{
		pcode = new List<Postal_codes__c>();
		pcode = [SELECT Id,Name FROM Postal_codes__c] ;
	}

}
Page should be :-
<apex:pageBlock title="p code">
        <apex:pageBlockTable value="{!pcode}" var="item">
            <apex:column value="{!item.name}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>

Please mark this as solution if this will help you, So that is some has same issue this post can help

Thanks
Amit Chaudhary
This was selected as the best answer
palash paunikar 6palash paunikar 6
Error : unknown component apex:pageblock

<apex:page controller="setterGetterapex_class" >
    <apex:form>
        <apex:pageBlock title="My calculations">
        <apex:pageBlockButtons>
            <apex:commandButton value="ADD" action="{!add}"/>
            <apex:commandButton value="SUB" action="{!sub}"/>
            </apex:pageBlockButtons>
            <apex:BlockSection title="Simple Operations">
                <apex:pageBlockSectionItem>
                    <apex:outputLabel>Enter x value</apex:outputLabel>
                    <apex:inputText value="{!xvalue}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>
                    <apex:outputLabel>Enter y value</apex:outputLabel>
                    <apex:inputText value="{!yvalue}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>
                    you ave performed{!opretion of value{!xvalue} and {!yvalue} finally result is{!result} }
                </apex:pageBlockSectionItem>
            </apex:BlockSection>
       </apex:pageBlock>
    </apex:form>
</apex:page>