I have a very simple search page that I want to display the data in the two column but I'm unable to do unless if I have apex:pageblockTable is that possible to do without pageblocktable?

Visualforce page:

<apex:page controller="RetUrlSearchController">
  <apex:form >
    <apex:pageBlock >
      <apex:pageBlockSection title="Criteria">
      <apex:outputLabel value="Enter Name Snippet"/>
      <apex:inputText value="{!nameQuery}"/>
      <apex:commandButton action="{!executeSearch}" value="Search"/>

   <apex:pageBlockTable value="{!accounts}" var="acc">
      <apex:column headerValue="Name">
         <apex:outputLink value="/{!acc.id}/e?retURL={!URLENCODE('/apex/RetUrlSearchPage?query='+nameQuery)}">{!acc.Name}</apex:outputLink>
      <apex:column value="{!acc.BillingStreet}"/>


public class RetUrlSearchController 
 public String nameQuery {get; set;}
 public List<Account> accounts {get; set;}

 public PageReference executeSearch()
  String queryStr='%' + nameQuery + '%';
  accounts=[select id, Name, BillingStreet 
            from Account 
            where name like :queryStr];

  return null;

 public RetUrlSearchController()
  // if query appears in URL, execute it
  String urlQuery=ApexPages.currentPage().getParameters().get('query');

  if ( (null!=urlQuery) && (0!=urlQuery.length()) )

Here is what I want the format to be:

<apex:pageBlockSection title="General Information" columns="2">
        <apex:outputField value="{!accounts.Id}"/>
        <apex:outputField value="{!accounts.Name}"/>
        <apex:outputField value="{!accounts.BillingStreet}"/>


the error i'm getting if i use that in above format:

Error: Could not resolve the entity from value binding '{!accounts.id}'.

  • So what's wrong with using columns="2"?
    – Adrian Larson
    Jul 16, 2016 at 0:24
  • its not rendering, if i use the <apex:pageBlockSection title="General Information" columns="2"> let me update my question with the error message i'm getting
    – Nick
    Jul 16, 2016 at 0:33
  • all what i have seen the sample code is used apex:pageBlockTable but in my case i do not want to use apex:pageBlockTable
    – Nick
    Jul 16, 2016 at 0:42

1 Answer 1


Just like with pageBlockTable, you need to iterate over the collection. When you do:

<apex:pageBlockTable value="{!accounts}" var="acc">

You create a local variable inside of that tag named acc. The accounts property is just a list and doesn't have any properties like id. The acc records have those properties, so to create that reference you can instead do an apex:repeat.

    <apex:repeat value="{!accounts}" var="acc">
            <apex:outputLink value="{!URLFOR($Action.Account.Edit, acc.id, [retURL=URLENCODE('/apex/RetUrlSearchPage?query='+nameQuery)}">
            <apex:outputField value="{!acc.BillingStreet}" />
  • awesome as always :) 1+
    – Nick
    Jul 16, 2016 at 20:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .