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
nimbusprojectnimbusproject 

Displaying instances of an sObject using repeat

I want to display a list of instances of an sObject that I have created and saved using repeat or the like.

 

They are indexed by a "Report Number" (autonumber).  

 

<apex:pageBlock title="Past Reports">
<apex:repeat value="{!report__c}" var="report">
<script type="text/javascript">
document.write('{!report.reportName__c}');
</script>

</apex:repeat>

 

This sort of formation isn't working...thoughts?

prageethprageeth

Why do you use JS here? You can print your values as below.

 

<apex:pageBlock title="Past Reports">

<apex:repeat value="{!report__c}" var="report">

{!report.reportName__c} <br/>

</apex:repeat>

</apex:pageBlock> 

 

nimbusprojectnimbusproject

Great! That worked! Well sort of, ideally I want to be able to list all instances of the object, but it looks like it's only showing the instances I've created with the most recent save.

 

Here is a look at my controller:

 

 

public class reportExt{

ApexPages.StandardController controller;

public report__c q {get;set;}

public reportExt(ApexPages.StandardController c) {
controller = c;
q = (report__c) c.getRecord();


}

public PageReference save() {
PageReference p = controller.save();


id qid = controller.getId();


return p;

}

 This is an adaptation of a "quote2pdf" example I found that saves a "quote" based on an opportunity. I'm just not sure if I am successfully saving an intance of the report?!

prageethprageeth

Hello nimbusproject;

I am not very much clear about your problem(even when I post the previous reply) .

However in order to print a list in a VF page with the use of a repeat tag, you need to pass a list to the repeat tag.

In your case you have to pass a list of "report__c" objects. 

 

In page: 

<apex:repeat value="{!reportList}" var="report"> 

 

In Controller:

public List<report__c> getReportList() { //This method should return a List of "report__c" objects.}

nimbusprojectnimbusproject

My problem is very generally:

 

I want to save the values entered into the fields for the custom object and also be able to print of list of my instances of that custom object that have already been saved by the name given when the object was created.

prageethprageeth

Hello nimbusproject ;

Im so sorry, however I can't exactly understand how do you enter data and where do you need to display data etc. 

I think your controller is similar to what you posted before. I cant understand whether you are using one VF page or two pages. If you can post a simplified code of your pages(the page you enter data and the page you display data list) I would be able to help you.