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
hiteshwar marnihiteshwar marni 

google bookapi

Hi,
I'm not able to display my parsed json response on VF page...pls help me on this.

VF CODE
<apex:page controller="Googlebooks_Controller" showHeader="false">
  <apex:form >
      <apex:pageBlock >
          <apex:pageBlockSection >
              <apex:inputText value="{!searchText}" label="Enter Name"/>
              <apex:selectList label="Select Account" multiselect="false" size="1" value="{!selectedCtriteria}">
              
                  <apex:selectOptions value="{!lstOptions}"></apex:selectOptions>
              </apex:selectList>
          </apex:pageBlockSection>
          <apex:commandButton value="Search" action="{!getBookDetails}" reRender="pb,pbt"/>
          <apex:pageBlockSection id="pb">
          {!searchText}
          {!selectedCtriteria}<br/>
              {!jsonresponse}
          </apex:pageBlockSection>
      <apex:pageBlockTable value="{!prsr}" var="i" id="pbt">
              
          <apex:column headerValue="TTTTT" value="{!i.kind}"/>
          <apex:pageBlockTable value="{!i.items}" var="pt">
              <apex:column value="{!pt.etag}" headerValue="sss"/>
          </apex:pageBlockTable>
          </apex:pageBlockTable>
      
      </apex:pageBlock>
      <apex:pageBlock id="pb">
      {!ss}
          
      </apex:pageBlock>
      
     
  </apex:form>
</apex:page>


APEX CLASS

public class Googlebooks_Controller {
 public JSON2Apex1 prsr{get;set;}
 public list<JSON2Apex1>ss{get;set;}
//public googlebooksparser wrapper {get;set;}
public string searchText{get;set;}
public string selectedCtriteria{get;set;}
public List<Selectoption> lstOptions {get;set;}
public string jsonresponse{get;set;}
public Googlebooks_Controller (){
    lstOptions  = new List<Selectoption>();
    //lstoptions.Add(new selectOption('','====None===='));
    lstoptions.Add(new selectOption('Author','Author'));
    lstoptions.Add(new selectOption('Title','title'));
    lstoptions.Add(new selectOption('ISBN','ISBN'));
    }

public void getBookDetails(){
    Http p = new Http();
    HttpRequest request = new HttpRequest();
    request.setMethod('GET');
    //AIzaSyC2YSo6gv-XsmWSNxv3VVwW1ncsveJZoYA
    String sText = searchText;
    sText= sText.replaceAll( '\\s+', '');
    string endpoint;
    if(selectedCtriteria == 'author'){
        endpoint = 'https://www.googleapis.com/books/v1/volumes?q='+sText+'+inauthor:keyes&key=AIzaSyC2YSo6gv-XsmWSNxv3VVwW1ncsveJZoYA';
    }
   /* if(selectedCtriteria == 'Title'){
    
        endpoint = 'https://www.googleapis.com/books/v1/volumes?q='+sText+'&key=AIzaSyC2YSo6gv-XsmWSNxv3VVwW1ncsveJZoYA';
    }
    if(selectedCtriteria == 'ISBN'){
        endpoint = 'https://www.googleapis.com/books/v1/volumes?q=AnnaKeyes+inauthor:keyes&key=AIzaSyC2YSo6gv-XsmWSNxv3VVwW1ncsveJZoYA';
    }*/
    system.debug('ENDPOINT '+endpoint);
    request.setEndPoint(endpoint);
    HttpResponse response = p.send(request);
    jsonresponse = response.getbody();
    
   JSON2Apex1  prsr= (JSON2Apex1)JSON.deserialize(jsonresponse, JSON2Apex1.class);
   
   system.debug('===='+prsr.items);
   
 
}
}

PARSERCLASS

public class JSON2Apex1 {
    public String kind{get;set;}
    public Integer totalItems{get;set;}
   public  List<Items> items{get;set;} //Your existing class.
    
    
    
    public class Items {
        public String kind {get;set;} 
        public String id {get;set;} 
        public String etag {get;set;} 
        public String selfLink {get;set;} 
        public VolumeInfo volumeInfo {get;set;} 
        //public SaleInfo saleInfo {get;set;} 
        //public AccessInfo accessInfo {get;set;} 
        //public SearchInfo searchInfo {get;set;} 
        public Items( String kind,String id,String etag,String selfLink,VolumeInfo VolumeInfo ){  
                        
              this.kind=kind;
              this.id=id;
              this.etag=etag;
              this.selfLink=selfLink;
              this.VolumeInfo =VolumeInfo;
        }
    }
     public class VolumeInfo {
        public String title {get;set;} 
        public String subtitle {get;set;} 
        public List<String> authors {get;set;} 

        public VolumeInfo(String title,String subtitle,List<String> authors) {
        this.title=title;
        this.subtitle=subtitle;
        this.authors=authors;
            
        }
    }
}