1

Can you please me to identify what is wrong in the below code :

VF page :

<apex:page standardController="Case" extensions="relevant">
    <apex:form>
        <apex:pageBlock id="block" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockSection title="Recommended Resolution" id="cases" columns="1">
                <apex:pageBlockTable value="{!consolewrapperlist}" var="acc" width="100%">
                    <apex:column headerValue="Select">
                        <input type="radio" name="<strong>selectRadio</strong>" id="radio">
                        <br/>
                        <apex:actionSupport event="onclick" action="{!getSelected}" status="buttonStatus" reRender="cntblock">
                            <apex:param name="accid" value="{!acc.id}" />
                        </apex:actionSupport>
                        </input>
                    </apex:column>
                    <apex:column>
                        <apex:commandLink value="{!acc.Name}" /> </apex:column>

                </apex:pageBlockTable>

            </apex:pageBlockSection>

        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:

public with sharing class relevant {
public List<consolewrap> ConsoleWrapperList{get;set;}
 public string selectedAccountId{get; set;}
public relevant(ApexPages.StandardController controller) {
    getperformcallout();
 }
    public List<consolewrap> getperformcallout(){

ConsoleWrapperList = new List<consolewrap>();
HttpRequest req = new HttpRequest();

HttpResponse res = new HttpResponse();

Http http = new Http();

req.setEndpoint('https://raw.githubusercontent.com/parthiban019/samplejson/master/student.json');

req.setMethod('GET');
system.debug('req '+req);

res = http.send(req);
system.debug('res'+res);
system.debug('resbody'+res.getbody());
if(res.getstatusCode() == 200 && res.getbody() != null){

ConsoleWrapperList=(List<consolewrap>)json.deserialize(res.getbody(),List<consolewrap>.class);

}

return consolewrapperlist;

}
public PageReference getSelected()
    {
        System.debug('Entered account selection block');
        selectedAccountId = ApexPages.currentPage().getParameters().get('accid');
       system.debug(selectedAccountId );
        return null;
    }

}

ConsoleWrap :

public class consolewrap {

public String Name{get;set;}

public String AccNumber{get;set;}

public String Source{get;set;}

public String Site{get;set;}

public String Email{get;set;}

}
  • consolewrap.id is not being used in the page you pasted. Is it the correct one? – Raul Aug 29 '17 at 11:20
1

The below statement your trying access acc is of type consolewrap Class.

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

In consolewrap class you don't have any property named with id.

I guess you misplace id instead of AccNumber

Below code make sense according to your wrapper class

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

  • welcome........ – NITHESH K Aug 30 '17 at 11:59
-1

try to check whether your response is deserialized with ID.

you can do a JSON2Apex for your res.getbody() and check the class and its respective instance variables. Once you check that, include those variables mentioned in the JSON2Apex in your wrapper.

You can convert your res.getBody() json String to APEX here

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.