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
GobbledigookGobbledigook 

PageBlockTable with Webservice call?

Hey all,

 

I've had this problem that's been bothering me for a few days here.  I'm trying to fill a call from a webservice into a pageblocktable, and I'm getting absolutely nowhere.  I've completed a workaround by instantiating a new datatable for each column I want to display, but I was wondering if there were any way to display this all in one table. 

 

Right now I have:

 

public class PageBlockTest
{
   public class TestThis
    {
        public List<Decimal> Line {get;set;}
        public List<String> INum {get;set;}
    }
    
    public List<TestThis> testMe = new List<TestThis> ();

    public List<TestThis> getTestData()
    {
        testMe = new List<TestThis>();
        TestThis tt = new TestThis();
        
        //The LineNumList and the ItemNumList are filled with the data from the webservice call.
        tt.Line = LineNumList;
        tt.INum = ItemNumList;
        
        testMe.add(tt);
        return testMe;
                
     }
}

 

And my visualforce code:

 

<apex:pageblock id = "myTest">
<apex:pageBlockTable value = "{!TestData}" var = "d">
<apex:column> 
    {!d.Line}
</apex:column>
<apex:column>
    {!d.INum}
</apex:column>
</apex:pageBlockTable>
</apex:pageblock>

 

And I get the entire contents of the list in one field row.  How do I make them display like a table should?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
JPClark3JPClark3

You currently have an object holding two lists. But what you need it a list of objects containing two values.
Your TestThis class should only hold one value for Line and one value for INUM, instead of a list for each one.

 

public class TestThis
{
	public Decimal Line {get;set;}
         public String INum {get;set;}
}

 

Then filling in this data will need to be in a loop:

 

public List<TestThis> getTestData()
{
	testMe = new List<TestThis>();
        
	//The LineNumList and the ItemNumList are filled with the data from the webservice call.
	
	// Assuming both lists are equal size
	for {integer i = 0; i < LineNumList.Size(); i++)
	{
		TestThis tt = new TestThis();
		tt.Line = LineNumList[i];
		tt.INum = ItemNumList[i];
		testMe.add(tt);
	}

	return testMe;
                
}

 

 

 

All Answers

JPClark3JPClark3

You currently have an object holding two lists. But what you need it a list of objects containing two values.
Your TestThis class should only hold one value for Line and one value for INUM, instead of a list for each one.

 

public class TestThis
{
	public Decimal Line {get;set;}
         public String INum {get;set;}
}

 

Then filling in this data will need to be in a loop:

 

public List<TestThis> getTestData()
{
	testMe = new List<TestThis>();
        
	//The LineNumList and the ItemNumList are filled with the data from the webservice call.
	
	// Assuming both lists are equal size
	for {integer i = 0; i < LineNumList.Size(); i++)
	{
		TestThis tt = new TestThis();
		tt.Line = LineNumList[i];
		tt.INum = ItemNumList[i];
		testMe.add(tt);
	}

	return testMe;
                
}

 

 

 

This was selected as the best answer
GobbledigookGobbledigook

You sir are a lifesaver.  Thank you!