anusha(salesforce developer)

Monday, 20 March 2017

Example code for Action support?

<apex:page controller="AccountSearch">
    <apex:form >
        <apex:pageBlock >
            <apex:outputPanel >
                Enter account Name: <apex:inputtext value="{!name}"/>
                <apex:actionsupport event="onclick" action="{!search}" rerender="out"/>
            </apex:outputPanel>    
            <apex:outputPanel id="out">
                <apex:pageBlockTable value="{!conlist}" var="c">
                    <apex:column value="{!c.name}"/>
                </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>



=============

public class AccountSearch {

    public string name {get;set;}
    public List<Contact> conlist{get;set;}
    
    public void search(){
    
        conlist= new list<contact>();
        
        conlist=[select id, name,phone from contact where account.name=: name];
    }
    
}

2 comments: