You need to sign in to do that
Don't have an account?
BHASKAR GANGULY
List values not showing in visualforce page
Hi,
I am calling a webservice through HTTP callout and trying to parsing the data and showing that in Visualforce page.
when i am debuging the list is returning value however when i am trying to show it through VF nothing is comming.Please help.
My VisualForce page :
<apex:page controller="FirstHTTP" sidebar="false">
<apex:Form >
<apex:pageBlock title="Contact Details">
<apex:PageBlockTable value="{!spp}" var="b">
<apex:column value="{!b.sconlist}" headervalue="Id"/>
<apex:column value="{!b.snamelist}" headervalue="Name"/>
</apex:PageBlockTable>
</apex:pageBlock>
</apex:Form>
</apex:page>
Controller Class :
public class FirstHTTP {
// Public Wrapper1 swrapper1;
Public FirstHTTP()
{
HTTPRequest s = New HTTPRequest();
S.setEndpoint('https://api.androidhive.info/contacts/');
s.setMethod('GET');
HTTP H1 = new HTTP();
HTTPResponse Resp =H1.send(s);
string sresponse =Resp.getBody();
// System.debug(sresponse);
// swrapper1 = new list<wrapper1>();
list<String> sid = new list<String>();
JSONParser parser = JSON.createParser(sresponse);
while (parser.nextToken() != null) {
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
(parser.getText() == 'id')) {
// Get the value.
parser.nextToken();
sid.add(parser.getText());
// Compute the grand total price for all invoices.
// system.debug(sid);
}
}
list<String> sname = new list<String>();
JSONParser parser1 = JSON.createParser(sresponse);
while (parser1.nextToken() != null) {
if ((parser1.getCurrentToken() == JSONToken.FIELD_NAME) &&
(parser1.getText() == 'name')) {
// Get the value.
parser1.nextToken();
sname.add(parser1.getText());
// Compute the grand total price for all invoices.
// system.debug(sid);
}
}
list<wrapper1> spp = new list<wrapper1>();
// system.debug(Sid.size());
for(integer i=0;i<Sid.size();i++)
{
swrapper1 = new Wrapper1();
swrapper1.sconlist = sid[i];
swrapper1.snamelist = sname[i];
spp.add(swrapper1);
// system.debug(slist);
}
// system.debug(slist);
}
public list<Wrapper1> spp{set;get;}
public Wrapper1 swrapper1{set;get;}
public class Wrapper1{
public string sconlist{set;get;}
public string snamelist{set;get;}
}
}
I am calling a webservice through HTTP callout and trying to parsing the data and showing that in Visualforce page.
when i am debuging the list is returning value however when i am trying to show it through VF nothing is comming.Please help.
My VisualForce page :
<apex:page controller="FirstHTTP" sidebar="false">
<apex:Form >
<apex:pageBlock title="Contact Details">
<apex:PageBlockTable value="{!spp}" var="b">
<apex:column value="{!b.sconlist}" headervalue="Id"/>
<apex:column value="{!b.snamelist}" headervalue="Name"/>
</apex:PageBlockTable>
</apex:pageBlock>
</apex:Form>
</apex:page>
Controller Class :
public class FirstHTTP {
// Public Wrapper1 swrapper1;
Public FirstHTTP()
{
HTTPRequest s = New HTTPRequest();
S.setEndpoint('https://api.androidhive.info/contacts/');
s.setMethod('GET');
HTTP H1 = new HTTP();
HTTPResponse Resp =H1.send(s);
string sresponse =Resp.getBody();
// System.debug(sresponse);
// swrapper1 = new list<wrapper1>();
list<String> sid = new list<String>();
JSONParser parser = JSON.createParser(sresponse);
while (parser.nextToken() != null) {
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
(parser.getText() == 'id')) {
// Get the value.
parser.nextToken();
sid.add(parser.getText());
// Compute the grand total price for all invoices.
// system.debug(sid);
}
}
list<String> sname = new list<String>();
JSONParser parser1 = JSON.createParser(sresponse);
while (parser1.nextToken() != null) {
if ((parser1.getCurrentToken() == JSONToken.FIELD_NAME) &&
(parser1.getText() == 'name')) {
// Get the value.
parser1.nextToken();
sname.add(parser1.getText());
// Compute the grand total price for all invoices.
// system.debug(sid);
}
}
list<wrapper1> spp = new list<wrapper1>();
// system.debug(Sid.size());
for(integer i=0;i<Sid.size();i++)
{
swrapper1 = new Wrapper1();
swrapper1.sconlist = sid[i];
swrapper1.snamelist = sname[i];
spp.add(swrapper1);
// system.debug(slist);
}
// system.debug(slist);
}
public list<Wrapper1> spp{set;get;}
public Wrapper1 swrapper1{set;get;}
public class Wrapper1{
public string sconlist{set;get;}
public string snamelist{set;get;}
}
}