• Balakrishna Mandula
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies

When I run the following code i got error like 

 

"controllercls2 Compile Error: Illegal assignment from LIST<Account> to LIST<Account> at line 9 column5" 

 

And

 

When i insert out side of constructor " lst=[select id,name,phone from Account]; "

I got Error lik this

 

 

"Error: controllercls2 Compile Error: unexpected token: '=' at line 11 column 3 "

 

 

<apex:page controller="controllercls2" id="page">
<apex:form id="form">

<apex:outputlabel >Enter Text to search</apex:outputlabel>
<apex:inputtext />
<apex:commandButton value="Search" />
<apex:pageblock id="pb">
<apex:pageblocktable value="{!lst}" var="c">
<apex:column value="{!c.name}"/>
<apex:column value="{!c.phone}"/>
</apex:pageblocktable>


</apex:pageblock>
</apex:form>
</apex:page>

 

------------------------------------------

 

public with sharing class controllercls2 {

public List<Account> lst { get; set; }


public controllercls2()
{

lst=[select id,name,phone from Account];
}


}

 

I have requirement, which is as follows..

When a user selects a particular Agent Id , all the details of that particular Agent Id should get populated on the visual force page.... I am not able to capture the selected picklist value and pass it to the Apex Controller ... Please help me..

Please guide as to where am I going wrong...

 

Class

 

public class AgentandOrderController{
Agent__c Agent;
string searchText;
List<Agent__c> result;
Integer selected;
Integer AgentId;

public String getAgent() {
        return null;
    }

 public List<Agent__c> getresult() {
      return result;
   }

public Integer getAgentId() {
return selected;
}

public void  setAgentId(Integer val) {
selected=val;
 }
 
public List<SelectOption> getItems() {
     List<SelectOption> options = new List<SelectOption>();
     options.add(new selectOption('001', '001'));
     options.add(new selectOption('002', '002'));
     options.add(new selectOption('003', '003'));
     options.add(new selectOption('004', '004'));
    
     return options;
}

public PageReference search() {
result=[select Agent_Address__c from Agent__c where Name=: ApexPages.currentPage().getParameters().get('options')];
System.debug('options : '+options);
return null;
}

}

 

 

 

Page

 

<apex:page controller="AgentandOrderController" >
 <apex:form >
<b>Agent Information</b>
  <apex:pageblock >
   <apex:pageBlockSection id="section1">
    <apex:pageBlockSectionItem >
     <apex:panelGrid columns="2">
     <apex:actionRegion >     
     <apex:outputLabel value="Agent Id" for="agentId"/>
      <apex:selectList value="{!agentId}" multiselect="false" size="1" onchange="search()" >
      <apex:selectOptions value="{!items}" />
      </apex:selectList>
     </apex:actionRegion>        
</apex:panelGrid>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageblock>

<b>Order Information</b>
<apex:pageBlock >
<apex:pageBlockSection id="section2">
<apex:pageBlockSectionItem >
<apex:panelGrid columns="2">
</apex:panelGrid>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

Thank You

  • April 05, 2012
  • Like
  • 0

Hi  All,

 

I trying to set a date value for Apex date field in javascript. How to do that?

Hi,
 
I want to create a lookup field as below using Visualforce. How can i acheive this?

 
Any help on this will be appreciated.
 
Thanks,
OnDemand