You need to sign in to do that
Don't have an account?

Unable to display results on VF page (Records obtained from Apex Class)
Hi,
I have below Apex class , returning Id and Name based on the given condition.(Able to see the values in Debug Log)
public class NewJobPostings
{
public static void getpostdetails()
{
NewJobPostings__c NJP = New NewJobPostings__c();
NJP = [Select id,Name from NewJobPostings__c where Job_Status__c=true];
}
}
Used this controller in VF page to display the records on VF page which are obtained from Apex class. But unable to do so. Can any one please guide
<apex:page Controller="NewJobPostings">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputField value="{!NJP.Name}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
I have below Apex class , returning Id and Name based on the given condition.(Able to see the values in Debug Log)
public class NewJobPostings
{
public static void getpostdetails()
{
NewJobPostings__c NJP = New NewJobPostings__c();
NJP = [Select id,Name from NewJobPostings__c where Job_Status__c=true];
}
}
Used this controller in VF page to display the records on VF page which are obtained from Apex class. But unable to do so. Can any one please guide
<apex:page Controller="NewJobPostings">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:outputField value="{!NJP.Name}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Modify your Controller code as below:
You are using <apex:outputField> you have to limit your query to 1. If you want more records whose Job_Status__c is true then you have to use <apex:pageBlockTable>
I hope it helps you.
Kindly let me inform if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
It's my pleasure. I’m glad I was able to help!
Kindly mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Regards,
Khan Anas