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
GonzalosrGonzalosr 

Help with pageblocks

Hi,

   i am trying to make something, but i can't. I want to create a visualforce page where i will have a pageblock for each object, each object is in a list.
   for example, i have a List<Account>, and i want to show a page block for each Account

[pageBlock Account 1]
[pageBloc Account 2 ]
..
..
[pageBlock Account n ]

  where n is the size of my list, and pageblock i show the detail of the i element of the list.

thanks

CarcajouCarcajou

Hi,

 

this should work with a repeat tag : <apex:repeat value="{!accountList}" var="acc">. 

You can then embed your pageBlock inside this tag. 

I didn't try, but it should work. 

 

Kind Regards, 

Catherin. 

GonzalosrGonzalosr
Thanks catherin, i am near of the solution, but i have a new problem, each time, i have to call a method of my controller, but i don´t how to do that.

   <apex:repeat valuea={!list} var = "element">
        <call controller method >

somebody can help me?

Really thanks
CarcajouCarcajou
Hi, i do not really understand what you want to do and why you need to call a method. Could you give some more details about what you would like to do ? Kind Regards, Catherin.
GonzalosrGonzalosr

in the page, i have a list of forms , and each form have a list of items, so i need to do the next :

  <apex:repeat  value= "{!Forms}" var = "form" >

     <apex:pageblock headerValue = {!form.name } >
        <apex:pageBlockTable value="{!items}" var="item">
          <apex:column headervalue = "Item Name" value = "{!item.Name__C}" />

         </apex:pageBlockTable>
      </apex:pageblock>
  </apex:repeat>

where items have to return the list of items to the current form. so i create an index, and i do the next

i = 0; // in the constructor

// more code

currentFormID = listOfForms.get(i).id;

listOfitems = (select items where form.id = : currentFormID);


and now i have to increment the index, so invoke a fuction "incIndex"

how can i do that?

thanks.

CarcajouCarcajou

for me, there is no need to have an index. your page should look like this :

 

<apex:repeat value= "{!Forms}" var = "form" > <apex:pageblock headerValue = {!form.name } > <apex:pageBlockTable value="{!form.items}" var="item"> <apex:column headervalue = "Item Name" value = "{!item.Name__C}" /> </apex:pageBlockTable> </apex:pageblock> </apex:repeat>

 

 

 In your controller, you must build the form so that it is a list which contains a field name and a list of items :

 

 

public form{ String name {get; set;} Object items {get; set;} public form(){ //form constructor .... } } public List<form> formList = new List<form>(); public List<form> getForms(){ .... return formList;

}

 

I hope it helps.

Kind Regards,

Catherin.

GonzalosrGonzalosr
Thanks Carcajau,
    i made an auxiliary object, where i made  a relationship with the two objects

class Objects {

  Form form;

  List<items> items; // items of the form

 public getForm();
 public getItems();

}

 the Object have worked perfectly, thanks!