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
waylonatcimwaylonatcim 

repeat tags and css fun

I'm trying to put some code in repeat tags and it seems as if the css is getting messed up as a result.  For example, if I have the folliwng page and controller:

 

 

<apex:page controller="testrepeat" >
   <apex:form>
   <apex:pageBlock>
   <apex:pageBlockSection columns="1">
       <apex:pageBlockSectionItem >
           <apex:outputLabel for="field1" value="{!showOne.Name}" />
           <apex:inputField value="{!showOne.id}" id="field"/>
       </apex:pageBlockSectionItem >
       <apex:repeat value="{!showSome}" var="s" >
           <apex:pageBlockSectionItem >
               <apex:outputLabel for="field" value="{!s.name}" />
               <apex:inputField value="{!s.id}" id="field"/>
           </apex:pageBlockSectionItem >
       </apex:repeat>
   </apex:pageBlockSection>
   </apex:pageBlock>
   </apex:form>
</apex:page>

 

public class testrepeat {
    public List<Account> showSome{get{
        if(showSome == null){
            showSome = [select Name, Id from Account limit 3];
        }
        return showSome;
        }set;
    }
            
    public Account showOne{get{
        return showSome[0];
        }
        set;
    }
}

 

the account from showOne has a particular formatting going on, but the accounts from showSome doesn't seem to have any style at all. 

 

I'm just wondering if this is expected behavior because I would expect that showSome should have the same look as showOne.

 

Best Answer chosen by Admin (Salesforce Developers) 
waylonatcimwaylonatcim

figured it out.  Needed to throw the pageBlockSection in the repeat tag and it worked out fine.  Thanks for being my outlet to talk it out.

All Answers

waylonatcimwaylonatcim

Ok, after reading the following in the component guide

"Note that if used within a pageBlockSection or panelGrid component, all content generated by a child repeat component is placed in a single pageBlockSection or panelGrid cell."

 

I tried separating things by pageBlockSections

 

 

<apex:repeat value="{!showSome}" var="s" >
       <apex:pageBlock>
       <apex:pageBlockSection >
           <apex:pageBlockSectionItem >
               <apex:outputLabel for="field" value="{!s.name}" />
               <apex:inputField value="{!s.id}" id="field"/>
           </apex:pageBlockSectionItem >
           </apex:pageBlockSection >
       </apex:pageBlock>
       </apex:repeat>

 

Which does the formatting correctly, but with each account separated by a pageBlock separator.  So now I'm wondering how to get the correct formatting but without the section separators.

 

waylonatcimwaylonatcim

figured it out.  Needed to throw the pageBlockSection in the repeat tag and it worked out fine.  Thanks for being my outlet to talk it out.

This was selected as the best answer
ahab1372ahab1372

thanks for sharing!