You need to sign in to do that
Don't have an account?
Sunil Kumar 841
Challenging!! I cant able to display my result in VF Page. Unknown Property I got a success response from API call.
I am getting a success response from OMDB API and having a issue in my VF Page. Can any one find out where I have gone wrong. Any help would be appreciated. Thank you in anticipated!!
My error -----> Unknown property 'moviesWrap.Search.Title'
My error -----> Unknown property 'moviesWrap.Search.Title'
movieCallout.apxc --------------------------------------------------------------------------------------- public class movieCallout { public String result {get;set;} public List<Object> movies {get;set;} public String element {set;get;} public list<string> title {set;get;} public list<moviesWrap.Search> finalmovies {get;set;} public movieCallout(){ finalmovies = new list<moviesWrap.Search>(); } public Object makeGetCallout() { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('http://www.omdbapi.com/?s='+element+'&apikey=ebe6fdf2'); request.setMethod('GET'); HttpResponse response = http.send(request); if (response.getStatusCode() == 200) { this.result = response.getBody(); moviesWrap mv = moviesWrap.parse(response.getBody()); finalmovies = mv.Search; System.debug(mv.Search); } return null; } } moviesWrap.apxc ----------------------------------------------------------------------------------- public class moviesWrap { public List<Search> Search; public String totalResults; public String Response; public class Search { public String Title; public String Year; public String imdbID; public String Type; public String Poster; } public static moviesWrap parse(String json) { return (moviesWrap) System.JSON.deserialize(json, moviesWrap.class); } } eazzymovie.vfp ..................................................................... <apex:page controller="movieCallout" lightningStyleSheets="true"> <head> <apex:slds /> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous"/> </head> <apex:form > <center><h1 style="font-size:20px"> Eazzymovie </h1></center> <!-- Search bar and Button --> <div class="container mt-3"> <apex:inputText id="theTextInput" value="{!element}" html-placeholder="Search Movie With..." /> <apex:commandButton value="Search" action="{!makeGetCallout}" id="theButton"/> </div> <!-- Results --> <div class="container"> <div class="row"> <apex:repeat var="abc" value="{!finalmovies}"> <div class="col-3 p-3"> <div class="card" style="width: 18rem;"> <div class="card-body"> <h4 class="card-title mt-1">Movie Name : <b>{!abc.Title}</b></h4> <center> <a href="#" class="btn btn-primary">Book Now</a> </center> </div> </div> </div> </apex:repeat> </div> </div> </apex:form> <!-- <apex:form > <center><h1 style="font-size:20px"> Eazzymovie </h1></center> <div class="container mt-3"> <apex:inputText id="theTextInput" value="{!searchKey}" html-placeholder="Search Movie With..." /> <apex:commandButton value="Search" action="{!search}" id="theButton"/> </div> <div class="container"> <div class="row"> <apex:repeat var="a" value="{!movie}"> <div class="col-3 p-3"> <div class="card" style="width: 18rem;"> <div class="card-body"> <img id="theImage" src="https://m.media-amazon.com/images/M/MV5BNjM0NTc0NzItM2FlYS00YzEwLWE0YmUtNTA2ZWIzODc2OTgxXkEyXkFqcGdeQXVyNTgwNzIyNzg@._V1_SX300.jpg" width="220" height="55" alt="Description of image here"/> <h4 class="card-title mt-1">Movie Name : <b>{!a.Name}</b></h4> <p class="card-text">Genre : {!a.Genre__c}</p> <center> <a href="#" class="btn btn-primary">Book Now</a> </center> </div> </div> </div> </apex:repeat> </div> </div> </apex:form> --> </apex:page>
Add get;set; to Title property in wrapper class. Like Below:
Thanks,
Maharajan.C