0

Apex Controller:

 public with sharing class FirstWrapperClass {

    public string w { get; set; }

   //----------Datatypes--------------
   public list<FirstWrapperExample>wrp {get;set;}
   list<FirstWrapperExample> wrp_old = new list<FirstWrapperExample>();
   //------------------DefaultConstructor------------
    Public FirstWrapperClass(){
          wrp = new list<FirstWrapperExample>();
          wrp = getAccounts_in_wrp();
      wrp_old = new list<FirstWrapperExample>();
      wrp_old = getAccounts_in_wrp();
    }

    public list<FirstWrapperExample> getAccounts_in_wrp()
     {
      list<FirstWrapperExample> tempwrp = new list<FirstWrapperExample>();

      list<Account> tempaccountlist = new list<Account>([Select id,name,type,active__c,
       (select id,name,Address_line_2__c,country__c,Landmark__c,pin__c,state__c from Address__r where primary__c=true)from Account
        where Active__c='yes']);
        for(Account accobj:tempaccountlist)
        {
           //create the address instance
           Address__c addrss = new Address__c();
            for(address__c addrssobj : accobj.address__r)
                      addrss = addrssobj;
                      if(accobj.address__r.size()>0)
                      {
                       tempwrp.add(new FirstWrapperExample(accobj,addrss));
                      }
        }
        return tempwrp;
     }
     //----------WrapperClass------------
    Public class FirstWrapperExample{
      public Account account{get;set;}
      public Address__c Add {get;set;}
     //---------------Wrapper Parameterized Constructor--------------------- 
     public FirstWrapperExample(Account a,Address__c ad){

             this.account=a;
             this.Add=ad;
     }

   }

}

VF PAGE:

<apex:page controller="FirstWrapperClass">
 <apex:form >
 <apex:pageblock >
  <style>
    table.fixed {table-layout:fixed;}
    #td_wp
    {
      font-size:1 em;
      text-align:center;
      padding-top:5px;
      padding-bottom:4px;
      padding:3px 7px 2px 7px;
      background-color:#CECEF6;
      color:black;
      border:1px solid #CECEF6;
      }
      #td_row
      {
      font-size:lem;
      border:1px solid #Eoe3e5;
      padding-top:5px;
      padding:3px 7px 2px 7px;
      background-color:#cecef6;
      text-align:center
      }
  </style>

    <div style="font-size:1 em;text-align:left;padding-top:5px;padding-bottom:4px; background-color:#E0E3E5; color:black;border:1px solid #E0E3E5;">
    <table border="0" class="fixed" style="border-collapse:collapse;width:100%;font-family:rebuchet MS,Arial,Helvetica,sans-serif;">

    <tbody style="display:table-row-group;vertical-align:middle;">
    <tr>
     <td id="td_wp">
       <b>name</b>
       </td>
          <td id="td_wp">
       <b>Active</b>
       </td>
        <td id="td_wp">
       <b>state</b>
       </td>
        <td id="td_wp">
       <b>pin</b>
       </td>
        <td id="td_wp">
       <b>country</b>
       </td>
       </tr>
        <apex:repeat value="{!wrp}" var="W">
        <tr>
        <td id="td_row">
        <apex:outputLink value="/{!w.account.id}">{!w.account.name}</apex:outputLink>
        </td>
        </tr>
        </apex:repeat>


       </tbody>
       </table>
    </div>
    </apex:pageblock>
 </apex:form>
</apex:page>

Error:

Error: Unknown property 'String.account'

  • welcome to SFSE, please see How to Ask on getting the most from the Community. In particular, for your post, reduce the size of the code/markup to only the essential bits. For example, the css is irrelevant. You can use the edit link to modify your question – cropredy Dec 30 '16 at 18:16
4

You have a public String property named w declared in the apex class which is not used in the class but conflicting with the apex:repeat loop variable which is also named w.

So either change the loop variable name to something else, or remove the property w defined in the class.

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.