function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
swapna9swapna9 

Not able to call static list from static method to non static method

Hi,

 

I am working on soap integration.In one method I am calling webservice method and adding all the values into one list then displayed list in visualforce page.Upto this its working fine.After this I am trying to call the same list in another method.In debug log i am getting null.

 

can anyone suggest me how to call static webservice method data(list) to other method.

 

here is the code:

global class WebserviceCall1 {

public static List<QlitemDetail> QlitemDetailList {get;set;}

public WebserviceCall1(ApexPages.StandardController controller) {
}
public WebserviceCall1() {
}
@future (callout=true)
WebService static void getPin() {
//Here Authentication code I written.
QlitemDetailList = new List<QlitemDetail>();
XmlStreamReader xsr = new XmlStreamReader(getRes.GetInfoResult);
while(xsr.hasNext()) {
if(xsr.getEventType()==XmlTag.START_DOCUMENT)
{
xsr.next();
xsr.next();
while(xsr.getEventType()!=XmlTag.END_DOCUMENT)
{
String PNumber ='';
if(xsr.getLocalName() == 'PNUMBER')
{
system.debug(xsr.getLocalName());
xsr.next();
system.debug(xsr.getEventType());
if (xsr.getEventType() == XmlTag.CHARACTERS)
{
PNumber = xsr.getText();
xsr.next();
}
}
QlitemDetail q = new QlitemDetail();
q.Number = PNumber;
QlitemDetailList.add(q);
xsr.next();
system.debug('------------------'+QlitemDetailList);
}
}
}
}
public void Sendpin1() {
system.debug('-------Sendpin-----------'+QlitemDetailList);
//here QlitemDetailList is displaying null
}
public class QlitemDetail {
public String PNumber {get;set;}
}
}

 

Thanks in advance,

 

SammyComesHereSammyComesHere

As per salesforce, If Static remains static only for that single request. If your request is breaking , you would always get that list as null.

 

Please check if you are making a post back or something . If yes then static list is not passed as part of view state hence lost.

swapna9swapna9

Thanks for you reply,

 

Actually I am dispalying list of data on visualforce page with check boxes.Once I click on submit button all the selected rows should get save in the backend.when I click on submit method again I am trying to access the webservice list data (QlitemDetailList) and trying to save the selected record.

 

 

 

 

 

SammyComesHereSammyComesHere

Make use of normal action button and Store the List not as a static resource as static List is not transferred as part of View State.

 

You can Make a wrapper and have a Boolean Flag that would correspond to the values for the checkboxes.

 

During postBack you can get the selected Records based on this boolean Flag and pass it directly to your method.

 

 

Have a look it would help surely 

 

http://wiki.developerforce.com/page/Wrapper_Class