0

Apex Class

public class Controllertest {

public Ms numbers{get; set;}

public class Ms {
        public List<MsisdnList> msisdnList;
        
        }
        public class MsisdnList {
        public String msisdn;
        }
    public void NumberList(){
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://demo9888763.mockable.io/getnumbers/');
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        system.debug('number list---'+response.getStatusCode());

        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200) {
            system.debug('response--'+response.getbody());
            String res = response.getbody();
            system.debug('body----->' + response.getBody());
            numbers = (Ms)JSON.deserialize(response.getbody(),Ms.class);
            system.debug('numbers---->'+ numbers);
            
            //system.debug('number list---'+numlist);            
        }
        
        displayPopup1 = true; 
        
    }
public void showPopup1(){
        NumberList();
        displayPopup1 = true; 
        
    }
public void selectNumber()
    {
        displayPopup1 = false;  
    }
public void closePopup1() {        
        displayPopup1 = false;    
    }

}

JASON Response Body

{
    "msisdnList": [{
        "msisdn": "5409866259"
    }, {
        "msisdn": "5409866260"
    }, {
        "msisdn": "5409866265"
    }, {
        "msisdn": "5409866267"
    }, {
        "msisdn": "5409866299"
    }]
}

VF Page

<apex:outputPanel >
            <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
            <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
                <apex:pageBlock title="Configure Product">
                    <apex:pageblockTable value="{!prodPriceList}" var="accWrap">
                        
                        <apex:column headerValue="Associate Device">
                            <apex:outputLabel style="width:10px" value="Device Quantity">&nbsp;&nbsp;&nbsp;&nbsp;
                                <apex:inputText value="{!accWrap.DeviceQuantity}" />
                            </apex:outputLabel>
                        </apex:column>
                        <br/><br/><br/>
                    </apex:pageblockTable>
                    
                    <apex:pageblockSection columns="2"> 
                        <apex:commandButton value="Submit" action="{!sumbitDevice}"/>
                        
                        
                        <apex:commandButton value="Close" action="{!closePopup}"  style="margin-left:80%;"/>
                    </apex:pageblockSection> 
                </apex:pageBlock>
                <apex:outputPanel id="Error">
                    <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayError}"/>
                    <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayError}">
                        <apex:pageBlock >
                            <apex:pageblockSection columns="1">
                                <apex:outputText value="{!ErrorMessage}"/>
                            </apex:pageblockSection>
                            <div align="center" draggable="false" >
                                <apex:commandButton value="OK" action="{!closeError}"/>
                            </div>
                            
                            
                        </apex:pageBlock>
                        
                        
                    </apex:outputPanel>
                </apex:outputPanel>
               
        </apex:outputPanel>
            <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopup1}">
                <apex:pageBlock title="Availabe Numbers">
                    <apex:pageBlockTable value="{!numbers}" var="nList" >
                    
                        <apex:column headerValue="AvailableNumber">
                            <apex:inputText value="{!nList.msisdnList.msisdn}" />
                        </apex:column>
                    </apex:pageBlockTable>
                    
                    <apex:pageblockSection columns="2"> 
                        <apex:commandButton value="Submit" action="{!selectNumber}"/> 
                        <apex:commandButton value="Close" action="{!closePopup1}"  style="margin-left:80%;"/>
                    </apex:pageblockSection> 
                </apex:pageBlock>
                <apex:outputPanel id="Error1">
                    <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayError}"/>
                    <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayError}">
                        <apex:pageBlock >
                            <apex:pageblockSection columns="1">
                                <apex:outputText value="{!ErrorMessage}"/>
                            </apex:pageblockSection>
                            <div align="center" draggable="false" >
                                <apex:commandButton value="OK" action="{!closeError}"/>
                            </div>              
                        </apex:pageBlock>
                        
                        
                    </apex:outputPanel>
                </apex:outputPanel>
  </apex:outputPanel>

The above is outputpanel section in vf page with page controller "Controllertest" Below is the error

"AddProductController.Ms.msisdnList"

can any one help in fixing this error.

1 Answer 1

2

First, it's JSON, not JASON.

Second, the main cause of the problem, is that Visualforce requires a getter (at minimum) to display a property of a class. That means you need to change your code to:

public Ms numbers { get; set; }
public class Ms {
    public List<MsisdnList> msisdnList { get; set; }
}
public class MsisdnList {
    public String msisdn { get; set; }
}

I've fixed your brackets in this example; as far as I'm aware, you can't have nested inner classes, so they need to be "side-by-side" like this in order to compile.

2
  • Thank you @sfdcfox. I still get a error "Unknown property 'VisualforceArrayList.msisdn" in my VF page and I not able to save it. <apex:pageBlockTable value="{!numbers}" var="nListObj"> <apex:column headerValue="AvailableNumber"> <apex:inputText value="{!nListObj.msisdnList.msisdn}"/> </apex:column> </apex:pageBlockTable> I need to display all "msisdn" numbers in VF page, so that user can select on of the numbers. Dec 21, 2020 at 2:12
  • <apex:pageBlockTable value="{!numbers.MsisdnList }" var="nListObj"> <apex:column headerValue="AvailableNumber"> <apex:inputText value="{!nListObj.msisdn}"/> </apex:column> the above code solved the issue. Thank you . Dec 21, 2020 at 4:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .