==============Vfpage=================
<apex:page controller=" DynamicAutoSearch1" sidebar="false" showHeader="false" applyHtmlTag="true" applyBodyTag="true" >
<apex:form >
<apex:messages />
<apex:pageBlock title="Search Detials" >
<apex:pageBlockSection >
<apex:pageBlockSection columns="2">
<apex:outputLabel >First Name:</apex:outputLabel>
<apex:inputText value="{!fname}">
<apex:actionSupport event="onkeyup" action="{!LoadData}" reRender="pbtable"/>
</apex:inputText>
<apex:outputLabel >Last Name:</apex:outputLabel>
<apex:inputText value="{!lname}">
<apex:actionSupport event="onkeyup" action="{!LoadData}" reRender="pbtable"/>
</apex:inputText>
<apex:outputLabel >City:</apex:outputLabel>
<apex:inputText value="{!city}">
<apex:actionSupport event="onkeyup" action="{!LoadData}" reRender="pbtable"/>
</apex:inputText>
<apex:outputLabel >State:</apex:outputLabel>
<apex:inputText value="{!state}">
<apex:actionSupport event="onkeyup" action="{!LoadData}" reRender="pbtable"/>
</apex:inputText>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!Candidates}" var="c" id="pbtable" style="bgcolor:yellow">
<apex:column value="{!c.First_Name__c}" />
<apex:column value="{!c.Last_Name__c}" />
<apex:column value="{!c.City__c}" />
<apex:column value="{!c.State_Province__c}" />
<apex:column value="{!c.Country__c}" />
</apex:pageblocktable>
</apex:pageBlockSection>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
============================== =========
public with sharing class DynamicAutoSearch1 {
public DynamicAutoSearch1 (){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c];
}
public List<Candidate__c> Can{ get; set; }
public String state { get; set; }
public String city { get; set; }
public String lname { get; set; }
public String fname { get; set; }
public List<Candidate__c> getCandidates (){
return can;
}
public PageReference LoadData() {
if(fname != null && lname == '' && city == '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where first_name__c Like:(fname+'%')];
}
else if(fname != null && lname != '' && city == '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where Last_Name__c Like:(lname +'%') AND first_name__c Like:(fname+'%') ];
}
else if(fname != null && lname == '' && city != '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where first_Name__c Like:(fname +'%') AND city__c Like:(city+'%')];
}
else if(fname != null && lname == '' && city == '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where first_Name__c Like:(fname +'%') AND State_Province__c Like:(state+'%')];
}
else if(fname != null && lname != '' && city != '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where first_Name__c Like:(fname +'%') AND Last_Name__c Like:(lname+'%') AND city__c Like:(city+'%')];
}
else if(fname != null && lname != '' && city == '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where first_Name__c Like:(fname +'%') AND Last_Name__c Like:(lname+'%') AND State_Province__c Like:(state+'%')];
}
else if(fname == null && lname != '' && city == '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where Last_name__c Like:(lname+'%')];
}
else if(fname == null && lname != '' && city != '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where Last_name__c Like:(lname+'%') AND city__c Like:(city+'%')];
}
else if(fname == null && lname != '' && city == '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where Last_name__c Like:(lname+'%') AND State_Province__c Like:(state+'%')];
}
else if(fname == null && lname != '' && city != '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where Last_name__c Like:(lname+'%') AND State_Province__c Like:(state+'%') AND city__c Like:(city+'%')];
}
else if(fname == null && lname == '' && city != '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where city__c Like:(city+'%')];
}
else if(fname == null && lname == '' && city != '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where city__c Like:(city+'%') AND State_Province__c Like:(state+'%')];
}
else if(fname == null && lname == '' && city == '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where State_Province__c Like:(state+'%')];
}
else if(fname != null && lname != '' && city != '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where first_Name__c Like:(fname +'%') AND Last_Name__c Like:(lname+'%') AND State_Province__c Like:(state+'%') AND city__c Like:(city+'%')];
}
else if(fname == null && lname == '' && city == '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c ];
}
/* else if(fname == '' && lname != null){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where Last_Name__c Like:(lname +'%')];
}
else if(fname != null && lname != null){
can =[select id,First_Name__c,Last_Name__c, State_Province__c,City__c, Country__c From Candidate__c where Last_Name__c Like:(lname +'%') AND first_name__c Like:(fname+'%') ];
}*/
/* else
Apexpages.addmessage(new apexpages.message(apexpages. severity.Error,'Not matching Record'));*/
return null;
}
}
<apex:page controller="
<apex:form >
<apex:messages />
<apex:pageBlock title="Search Detials" >
<apex:pageBlockSection >
<apex:pageBlockSection columns="2">
<apex:outputLabel >First Name:</apex:outputLabel>
<apex:inputText value="{!fname}">
<apex:actionSupport event="onkeyup" action="{!LoadData}" reRender="pbtable"/>
</apex:inputText>
<apex:outputLabel >Last Name:</apex:outputLabel>
<apex:inputText value="{!lname}">
<apex:actionSupport event="onkeyup" action="{!LoadData}" reRender="pbtable"/>
</apex:inputText>
<apex:outputLabel >City:</apex:outputLabel>
<apex:inputText value="{!city}">
<apex:actionSupport event="onkeyup" action="{!LoadData}" reRender="pbtable"/>
</apex:inputText>
<apex:outputLabel >State:</apex:outputLabel>
<apex:inputText value="{!state}">
<apex:actionSupport event="onkeyup" action="{!LoadData}" reRender="pbtable"/>
</apex:inputText>
</apex:pageBlockSection>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!Candidates}" var="c" id="pbtable" style="bgcolor:yellow">
<apex:column value="{!c.First_Name__c}" />
<apex:column value="{!c.Last_Name__c}" />
<apex:column value="{!c.City__c}" />
<apex:column value="{!c.State_Province__c}"
<apex:column value="{!c.Country__c}" />
</apex:pageblocktable>
</apex:pageBlockSection>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
==============================
public with sharing class DynamicAutoSearch1 {
public DynamicAutoSearch1 (){
can =[select id,First_Name__c,Last_Name__c,
}
public List<Candidate__c> Can{ get; set; }
public String state { get; set; }
public String city { get; set; }
public String lname { get; set; }
public String fname { get; set; }
public List<Candidate__c> getCandidates (){
return can;
}
public PageReference LoadData() {
if(fname != null && lname == '' && city == '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname != null && lname != '' && city == '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname != null && lname == '' && city != '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname != null && lname == '' && city == '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname != null && lname != '' && city != '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname != null && lname != '' && city == '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname == null && lname != '' && city == '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname == null && lname != '' && city != '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname == null && lname != '' && city == '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname == null && lname != '' && city != '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname == null && lname == '' && city != '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname == null && lname == '' && city != '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname == null && lname == '' && city == '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname != null && lname != '' && city != '' && state != '' ){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname == null && lname == '' && city == '' && state == '' ){
can =[select id,First_Name__c,Last_Name__c,
}
/* else if(fname == '' && lname != null){
can =[select id,First_Name__c,Last_Name__c,
}
else if(fname != null && lname != null){
can =[select id,First_Name__c,Last_Name__c,
}*/
/* else
Apexpages.addmessage(new apexpages.message(apexpages.
return null;
}
}
No comments:
Post a Comment