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
rao venkyrao venky 

unknown property string.name

hello,
Here's the error message I'm getting when trying to save my page:
Error:Error: Unknown property 'String.name'      Can  any one help me
VF code:
<apex:page controller="Accountonclickconlist" sidebar="false" id="pcc">
<apex:form >
  <apex:pageBlock id="pgbl">
   <apex:pageBlockSection title="Accounts" id="pgbs">
     <apex:pageblockTable value="{!Accounts}" var="account" id="pgbtable">
      <apex:column headerValue="account name"/>
       <apex:commandLink value="{!account.name}" reRender="Contactblock">
        <apex:actionSupport event="onclick" action="{!getrelatedcontactlist}" reRender="contactbl">
          <apex:param name="accountid" assignTo="{!accountid}" value="{!account.id}">
          </apex:param>
          </apex:actionsupport>
          </apex:commandlink>   
     </apex:pageblockTable>
   </apex:pageBlockSection> 
  </apex:pageBlock>
    <apex:pageBlock id="contactbl">
     <apex:pageBlockSection title=" Contacts">
      <apex:pageBlockTable value="{!contacts}" var="contact">
        <apex:column headerValue="firstname" value="{!contact.firstname}"/>
        <apex:column headerValue="Lastname" value="{!contact.lastname}"/>  
      </apex:pageBlockTable>
     </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form> 
</apex:page>

Class:
public with sharing class Accountonclickconlist 
{
 public list<account>accountlist{set;get;}
 public list<contact>contactlist{set;get;}
 public id accountid{set;get;}
   public Accountonclickconlist()
   {
    accountlist=new list<account>();
    contactlist=new list<contact>();
     accountlist=[select id,name from account limit 50];
     }
    public void getrelatedcontactlist()
    {
       contactlist=[select id, Lastname, Firstname from contact WHERE Accountid=:Accountid limit 50];
       }

}

 
surasura
I am not sure you have posted your exact code because it had some major bug , but I got this working please replace your page with code below
<apex:page controller="Accountonclickconlist" sidebar="false" id="pcc">
<apex:form >
  <apex:pageBlock id="pgbl">
   <apex:pageBlockSection title="Accounts" id="pgbs">
     <apex:pageblockTable value="{!accountlist}" var="account" id="pgbtable">
      <apex:column headerValue="account name">
       <apex:commandLink value="{!account.name}" reRender="Contactblock">
        <apex:actionSupport event="onclick" action="{!getrelatedcontactlist}" reRender="contactbl">
          <apex:param name="accountid" assignTo="{!accountid}" value="{!account.id}">
          </apex:param>
          </apex:actionsupport>
          </apex:commandlink>
        </apex:column>     
     </apex:pageblockTable>
   </apex:pageBlockSection> 
  </apex:pageBlock>
    <apex:pageBlock id="contactbl">
     <apex:pageBlockSection title=" Contacts">
      <apex:pageBlockTable value="{!contactlist}" var="contact">
        <apex:column headerValue="firstname" value="{!contact.firstname}"/>
        <apex:column headerValue="Lastname" value="{!contact.lastname}"/>  
      </apex:pageBlockTable>
     </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form> 
</apex:page>

 
Amit Chaudhary 8Amit Chaudhary 8
I fixed your issue. Please try below code :-
Page:-
<apex:page Controller="Accountonclickconlist" tabstyle="Case">
<apex:form id="frm">
  <apex:pageBlock id="pgbl">
 
   <apex:pageBlockSection title="Accounts" id="pgbs">
     <apex:pageblockTable value="{!accountlist}" var="account" id="pgbtable">
       <apex:column headerValue="account name">
        <apex:commandLink value="{!account.name}" reRender="Contactblock">
          <apex:actionSupport event="onclick" action="{!getrelatedcontactlist}" reRender="contactbl,frm">
             <apex:param name="accountid" assignTo="{!accountid}" value="{!account.id}"/>
          </apex:actionsupport>
        </apex:commandlink>   
       </apex:column>
     </apex:pageblockTable>
   </apex:pageBlockSection> 
  </apex:pageBlock>

    <apex:pageBlock id="contactbl">
     <apex:pageBlockSection title=" Contacts">
      <apex:pageBlockTable value="{!contactlist}" var="contact">
        <apex:column headerValue="firstname" value="{!contact.firstname}"/>
        <apex:column headerValue="Lastname" value="{!contact.lastname}"/>  
      </apex:pageBlockTable>
     </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form> 
</apex:page>
Classes :-
public with sharing class Accountonclickconlist{

 public list<account> accountlist{set;get;}
 public list<contact> contactlist{set;get;}
 public id accountid{set;get;}
 
   public Accountonclickconlist()
   {
        accountlist=new list<account>();
        contactlist=new list<contact>();
         accountlist=[select id,name from account  limit 10];
   }
    public void getrelatedcontactlist()
    {
       contactlist=[select id, Lastname, Firstname from contact WHERE Accountid=:Accountid limit 50];
    }

}
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help

Thanks
Amit Chaudhary