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 '16 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 Kahn
    Jul 16 '16 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 Kahn
    Jul 16 '16 at 0:42

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 Kahn
    Jul 16 '16 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.