VF page part :-

<td >
<apex:pageBlockTable value="{!doclist}" var="WrappedCustomer" cellspacing="2" columnsWidth="50" rendered="{!showpage}">      <!-- value="{!doclist}"  -->    
                    <apex:column headerValue="Select" width="5"> 
                    <apex:inputCheckbox value="{!WrappedCustomer.bSelected}"/>   <!-- value="{!WrappedCustomer.bSelected}"  -->

                    <apex:column headerValue="Document Name"   width="475" value="{!WrappedCustomer.DocType}"/>   <!-- value="{!WrappedCustomer.DocType}"  -->

                    <apex:column headerValue="Document Link"  width="475" value="{!WrappedCustomer.DocURL}" />  <!-- value="{!WrappedCustomer.DocURL}"  -->


Controller class :-

public with sharing class filenetcontroller {
String Lid ;
String Username;
String Pass;
Public Lead lead ;
Public string LeadIdTemp {get;set;} 
public Boolean showpage{get; set;}
public List<wrappeddocs> doclist{get;set;}

public filenetcontroller(ApexPages.StandardController controller) {
showpage = true;
  LeadIdTemp =Lead.Lead_Id__c;  
  System.debug('##########'+LeadIdTemp ); 



 public  static List<wrappeddocs> getiib(String LeadIdTemp ,String Username,String Pass) {
        list<string> pf = new list<string>();
        String name = 'p8admin';
        String Passrd = 'p8admin' ;         
        HttpRequest req = new HttpRequest();           
        string endPointValue ='http://192.155.245.XXX';
        String passEncoded = EncodingUtil.base64Encode(Blob.valueOf(Passrd));                            
        req.setBody('<CustInfoSearchReq><username>' + name + '</username><LeadId>' + LeadIdTemp + '</LeadId><password>' + passEncoded + '</password></CustInfoSearchReq>');                          
        system.debug('req---->' +req.getBody());                            
        Http h = new Http();           
        HttpResponse res = h.send(req); 
        //res.setHeader('Content-Type', 'application/json');  
        system.debug('res---->' +res.getBody()); 
        List<wrappeddocs> doclist = new List<wrappeddocs> ();
        Dom.Document docx = res.getBodyDocument();
        dom.XmlNode xroot = docx.getrootelement();  
        dom.XmlNode xrec = xroot.getChildElement('Documents',null);
        dom.XmlNode [] xrrec = xrec.getchildelements() ;  
      system.debug('xrrec ---->' +xrrec);       

      for(Dom.XMLNode child : xrrec){ 
           wrappeddocs a = new wrappeddocs();
           for (dom.XmlNode awr : child.getchildren()) {
                      if (awr.getname() == 'documentType') {
                            system.debug('Doc-type' + awr.gettext());

                             a.DocType = awr.gettext();
                          system.debug('DocType' + a.DocType);


                      if (awr.getname() == 'documentURL') {
                             system.debug('URL' + awr.gettext());
                             //a.DocURL = awr.gettext();
                          string b = awr.gettext();
                     a.DocURL  = EncodingUtil.urlDecode(b,'UTF-8');
                          system.debug('DocURL' + a.DocURL);
                 system.debug('Doclist' + doclist);  

    return doclist;

    public class wrappeddocs{
    public String DocType{get; set;}
    public String DocURL{get; set;}
    public Boolean bSelected{get;set;}
    public Boolean showpage{get; set;}
    public wrappeddocs(){
        showpage = true;
        bSelected = false;
        DocType = '';
        DocURL = '';                    
  • <td > <apex:pageBlockTable value="{!doclist}" var="WrappedCustomer" cellspacing="2" columnsWidth="50" rendered="{!showpage}"> <apex:column headerValue="Select" width="5"> <apex:inputCheckbox value="{!WrappedCustomer.bSelected}"/> apex:column> <apex:column headerValue="Document Name" width="475" value="{!WrappedCustomer.DocType}"/> <apex:column headerValue="Document Link" width="475" value="{!WrappedCustomer.DocURL}" /> </apex:pageBlockTable> </td> – HIMANSHU ATAL Aug 23 '15 at 13:01
  • so what's ur question ? u already hv the wrappeddocs class and u r parsing the http response into the class and binding that to the apex pageblock table. r u saying its not working ? do u get any errors ? – Vamsi Krishna Aug 23 '15 at 13:13
  • No , I am not getting any error , my wrapper list is perfect in debug logs. But it is not displaying in pageblock table. Can't we show a wrapper from htp response like this ? Is there any other way to call this webservice class to show it in vf page ? – HIMANSHU ATAL Aug 23 '15 at 13:19
  • 1
    Looks like your method that builds the list is a RemoteAction if so then you will have to parse the response in Java and get it on the page. Setting it in the RemoteAction will not work as it does not have any visibility or communication with the controller your page is using.....(Just because it happens to be in the same class does not means it can talk to the instance of the class your controller is using) – Eric Aug 23 '15 at 13:28
  • I removed @RemoteAction from above the webservice method... eventhough it is having same problem. – HIMANSHU ATAL Aug 23 '15 at 13:39

See Continuation object in Apex – Asynchronous callouts for long running request – Live Demo blog post by Jitendra Zaa where he uses the The Continuation Method with Visualforce. You'll need to modify his code to accommodate your wrapper class, but that's the essence of how to do what you're asking about.

  • That I saw... but how to do the same thing he did by using standard controller ? In standard controller case we need to call web service method from controller right ? – HIMANSHU ATAL Aug 23 '15 at 14:40
  • In his example, he's simply making the request using an action method that does the ajax call initiated via a command button instead of running it through a custom controller. He also does a rerender at the same time while another page block does a "lazy render" when the data becomes available. I see no reason you can't put that in a custom controller. It's a matter of separation of concerns between the callout and the return. – crmprogdev Aug 23 '15 at 16:54
  • I am using standard controller because I need to pass lead id from that to our web service method. Can the same thing is possible by using standard controller ? Or should I change it to custom controller ? – HIMANSHU ATAL Aug 24 '15 at 8:40
  • Not certain it matters. I think the real issue for you is separation of concerns. You want the return data to render whenever it arrives. So, how are you going to do that? One way might be to put that portion of the code in a VF component that uses its own controller. I'm certain there are others too. You need to somehow make the wrapper code execute and render to the page separately from the Http request. – crmprogdev Aug 24 '15 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.