You need to sign in to do that
Don't have an account?
manjunath vivek
How does a constructor work in the following code.
apex:page standardController="Member__c" extensions="Search" >
<style type = "text/css">
.Bld { font-weight:bold;}
</style>
<apex:form >
<apex:pageblock title="Members" >
<table align = "center" width = "100%" cellspacing = "5">
<tr>
<td class = "Bld">Member Name:</td>
<td><apex:inputText value="{!memName}" /></td>
</tr>
<tr>
<td align = "center" class = "Bld" colspan = "2"><apex:commandButton value="Find" action="{!find}"/></td>
</tr>
</table>
</apex:pageblock>
<apex:pageBlock title="Search Result">
<apex:pageblockTable value="{!memList}" var="a">
<apex:column >
<apex:outputlink value="https://na12.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>
</apex:column>
<apex:column value="{!a.id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex:
public class Search
{
public String memName {get; set;}
public List<Member__c> memList {get; set;}
public Search(ApexPages.StandardController controller)
{
}
public void find()
{
String sql = 'SELECT Name,id FROM Member__c WHERE Name LIKE \'%'+memName+'%\' LIMIT 20';
memList = Database.query(sql);
}
}
Can some one explain, How does this line works in the above code .
public Search(ApexPages.StandardController controller)
{
}
<style type = "text/css">
.Bld { font-weight:bold;}
</style>
<apex:form >
<apex:pageblock title="Members" >
<table align = "center" width = "100%" cellspacing = "5">
<tr>
<td class = "Bld">Member Name:</td>
<td><apex:inputText value="{!memName}" /></td>
</tr>
<tr>
<td align = "center" class = "Bld" colspan = "2"><apex:commandButton value="Find" action="{!find}"/></td>
</tr>
</table>
</apex:pageblock>
<apex:pageBlock title="Search Result">
<apex:pageblockTable value="{!memList}" var="a">
<apex:column >
<apex:outputlink value="https://na12.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>
</apex:column>
<apex:column value="{!a.id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex:
public class Search
{
public String memName {get; set;}
public List<Member__c> memList {get; set;}
public Search(ApexPages.StandardController controller)
{
}
public void find()
{
String sql = 'SELECT Name,id FROM Member__c WHERE Name LIKE \'%'+memName+'%\' LIMIT 20';
memList = Database.query(sql);
}
}
Can some one explain, How does this line works in the above code .
public Search(ApexPages.StandardController controller)
{
}
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_extension.htm
Refer above link to deep drive .So In short an extension requires you to specify constructor and constructor is parameterized .In your case constructor has an object instance of Member__c .In fact for your case you dont need extension at all .Ideal will be custom controller
Hope below links will help you to understand the lifecycle of get and put request of page with extension.s
https://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_get_request.htm
https://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_lifecycle_example.htm
i share that link please read it that.
https://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_get_request.htm