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
anu123anu123 

placing event object search functionality in vf page

Hi all,

   i wrote Vf page for displying events and search functonality in vf page.it works in vf page .But this same page is placed in sites.in that site from ,to dates are not displayed.How to display these fields in ssites.

 

Controller is

 

public class eventpage{public string fromdate1{set;get;}public string location{set;get;}public string category{set;get;}public boolean cat{set;get;}event edate=new event();
public void setedate(event ed){edate=ed;
}public event getedate(){return edate;}public list<Event> elist=new list<Event>();
public void findevents(){if(location!=''&& category==''&& edate.StartDateTime==null && edate.EndDateTime==null){string s=location+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where location like:s]) { elist.add(e); system.debug('+++++++'+elist); }}else if(category!=''&&location==''&& edate.StartDateTime==null && edate.EndDateTime==null){string s1=category+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where category__C like:s1]) { elist.add(e);  }}else if(location!=''&&category!=''&& edate.StartDateTime==null && edate.EndDateTime==null){string s=location+'%';string s1=category+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where category__C like:s1 and Location like:s]) { elist.add(e);  }}else if(location==''&&category=='' && edate.StartDateTime!=null && edate.EndDateTime!=null  ){DateTime s2=edate.StartDateTime;DateTime s3=edate.EndDateTime;
for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where StartDateTime >=:s2 AND EndDateTime<=:s3]) { elist.add(e); System.debug('++++++++======'+elist);  }}

else if(location==''&&category=='' && edate.StartDateTime!=null && edate.EndDateTime==null  ){DateTime s2=edate.StartDateTime;
for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where StartDateTime >=:s2 ]) { elist.add(e); System.debug('++++++++======'+elist);  }}
else if(location==''&&category=='' && edate.StartDateTime==null && edate.EndDateTime!=null  ){
DateTime s3=edate.EndDateTime;
for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where EndDateTime <=:s3 ]) { elist.add(e); System.debug('++++++++======'+elist);  }}

else if(edate.StartDateTime!=null && edate.EndDateTime!=null&&location!=''&&category==''){DateTime s2=edate.StartDateTime;DateTime s3=edate.EndDateTime;String s4=location+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where StartDateTime >=:s2 AND EndDateTime<=:s3 AND location like:s4]) { elist.add(e);  }}else if(edate.StartDateTime!=null && edate.EndDateTime==null&&location!=''&&category==''){DateTime s2=edate.StartDateTime;//DateTime s3=edate.EndDateTime;String s4=location+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where StartDateTime >=:s2  AND location like:s4]) { elist.add(e);  }}else if(edate.StartDateTime==null && edate.EndDateTime!=null&&location!=''&&category==''){//DateTime s2=edate.StartDateTime;DateTime s3=edate.EndDateTime;String s4=location+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where  EndDateTime<=:s3 AND location like:s4]) { elist.add(e);  }}


else if(edate.StartDateTime!=null && edate.EndDateTime!=null&&location==''&&category!=''){DateTime s2=edate.StartDateTime;DateTime s3=edate.EndDateTime;
String s4=category+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where StartDateTime >=:s2 AND EndDateTime<=:s3 AND category__c like:s4]) { elist.add(e);  }}else if(edate.StartDateTime!=null && edate.EndDateTime==null&&location==''&&category!=''){DateTime s2=edate.StartDateTime;//DateTime s3=edate.EndDateTime;
String s4=category+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where StartDateTime >=:s2  AND category__c like:s4]) { elist.add(e);  }}else if(edate.StartDateTime==null && edate.EndDateTime!=null&&location==''&&category!=''){//DateTime s2=edate.StartDateTime;DateTime s3=edate.EndDateTime;
String s4=category+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where  EndDateTime<=:s3 AND category__c like:s4]) { elist.add(e);  }}



elseif(edate.StartDateTime!=null &&edate.EndDateTime!=null&&location!=''&&category!=''){DateTime s2=edate.StartDateTime;DateTime s3=edate.EndDateTime;
String s4=category+'%';String s5=location+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where StartDateTime >=:s2 AND EndDateTime<=:s3 AND category__c like:s4 AND location like:s5]) { elist.add(e);  }}
elseif(edate.StartDateTime!=null &&edate.EndDateTime==null&&location!=''&&category!=''){DateTime s2=edate.StartDateTime;//DateTime s3=edate.EndDateTime;
String s4=category+'%';String s5=location+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where StartDateTime >=:s2  AND category__c like:s4 AND location like:s5]) { elist.add(e);  }}

elseif(edate.StartDateTime==null &&edate.EndDateTime!=null&&location!=''&&category!=''){//DateTime s2=edate.StartDateTime;DateTime s3=edate.EndDateTime;
String s4=category+'%';String s5=location+'%';for(event e:[select id,whoid,StartDateTime,EndDateTime,Location,Category__C from Event where  EndDateTime<=:s3 AND category__c like:s4 AND location like:s5]) { elist.add(e);  }}}public list<event> getevents(){cat=true;return elist;}}

 

page is:

 

<apex:page Controller="eventpage"  sidebar="false">  <apex:form ><apex:pageBlock title="Search for an event">

Location:<apex:inputText value="{!location}"/><br/>Category:<apex:inputText value="{!Category}"/><br/><br/><b>Daterange:</b><br/><br/>From:<apex:inputField value="{!edate.StartDateTime}"/><br/>To: <apex:inputField value="{!edate.EndDateTime}"/><br/><br/>
<apex:commandButton value="Find Events" action="{!findevents}"/><apex:outputPanel rendered="{!cat}">  <apex:pageBlock >  <apex:pageBlockTable value="{!events}" var="acc">  <apex:column headerValue="Event name" value="{!acc.Whoid}"/>  <apex:column headerValue="Location" value="{!acc.Location}"/>  <apex:column headerValue="FromDate" value="{!acc.StartDateTime}"/>  <apex:column headerValue="ToDate" value="{!acc.EndDateTime}"/>  <apex:column headerValue="Category" value="{!acc.Category__c}"/></apex:pageBlockTable></apex:pageBlock>  </apex:outputPanel>      </apex:pageBlock>     </apex:form>     </apex:page>

 

Any one can u help me.

 

thanks in advance

anu