Thursday, 19 December 2013

Searching In Google Search from Visua lforce page

Here in this example we just use "Search" custom object which can hold searchable things what we want to have in the vf page for searching we have sample tool bar with different links to navigate.

When we click on "Search Google" link in a particular row then it shows the search result of that record which we  displayed in vf page.

Class:
====
public with sharing class acccon2 {
    List<SearchObject__c> acc;
        public acccon2(ApexPages.StandardController controller) {

    }
    public String accid{get; set;}
   
    public List<SearchObject__c> getlstaccounts()
    {
    acc=[Select id,name, Search__c from SearchObject__c];
    return acc;
    }
   
    public pagereference ref()
    {
    pagereference ref= new pagereference('/'+accid);
    ref.setredirect(true);
    return ref;
    }
   
}

Page:
=====
<apex:page standardController="SearchObject__c" extensions="acccon2" showHeader="false" >

 <apex:toolbar >
 <apex:toolbarGroup itemSeparator="line" >
 <apex:outputLink value="http://mail.appshark.com" target="_blank" ><font color="white"  >AppsharkMail</font></apex:outputLink>
  <apex:outputLink value="http://www.gmail.com" target="_blank"><font color="white">Gmail</font></apex:outputLink>
  <apex:outputLink value="http://www.linkedin.com" target="_blank"><font color="white">LinkedIn</font></apex:outputLink>
  <apex:outputLink value="http://www.mypptsearch.com" target="_blank"><font color="white">MypptSearch</font></apex:outputLink>
   <apex:outputLink value="http://wiki.developerforce.com" target="_blank"><font color="white">WikiDeveloperforce</font></apex:outputLink>
    <apex:outputLink value="http://login.salesforce.com" target="_blank"><font color="white">SalesForcelogin</font></apex:outputLink>
  </apex:toolbarGroup>
  </apex:toolbar>




 <apex:form >
 <apex:pageBlock title="Search the following Things Here Itself" >
 <apex:pageBlockTable value="{!lstaccounts}" var="acc">

 <apex:column >
 <apex:commandLink value="{!acc.name}" action="{!ref}">
 <apex:param value="{!acc.Id}" name="accid" assignTo="{!accid}" />
 </apex:commandLink>
 </apex:column>
 <apex:column HeaderValue="Clickon Search Google">
 <apex:outputLink value="http://google.com/search" target="_blank">

        Search Google

        <apex:param name="q" value="{!acc.name}"/>

    </apex:outputLink>
 </apex:column>
  </apex:pageBlockTable>
 </apex:pageBlock>
 </apex:form>
</apex:page>

Outtput:
======




No comments:

Post a Comment