+ Start a Discussion
John L.John L. 

How to join two Objects into one PageBlockTable

I have the following concept page:

<apex:page controller="UTPageBlockTable"> <apex:pageBlock > <apex:pageBlockTable value="{!join}" var="h"> <apex:column value="{!h.Name}"/> <apex:column value="{!h.oId}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>


with the controller:


public class UTPageBlockTable { public List<UTJoin> getJoin() { List<UTJoin> result = new List<UTJoin>(); UTJoin record = new UTJoin(); User one = [ SELECT Name FROM User LIMIT 1 ]; Organization two = [ SELECT Id FROM Organization LIMIT 1 ]; record.Name = one.Name; record.oId = two.Id; result.add(record); record.Name = 'MyOtherUser'; record.oId = '01p700000004hau'; result.add(0,record); return result; } }


and the Apex Class:


public class UTJoin { public String Name; public Id oId; }



When the page is displayed, I get the "none-too-descriptive" error page:



To me, this appears to be a Salesforce.com error. Customer Support directed me to this Discussion Board for guidance. 


Thanks in advance for any help you may be able to provide. 


Ron HessRon Hess

you have no getter for the member Name of the class UTJoin


therefore the message getName()



you can add getName() to the class, or declare Name as a property




public class UTJoin { public String Name {get;set;} public Id oId {get;set;} }




It looks like you need getters for the utit Member variables
John L.John L.

I was unable to use the property method (i.e. adding {get; set;} to each attribute definition) due to compiler errors, however the simple addition of getName() and getOId() methods, returning just the attribute value, did the trick.


Thanks to all who responded.

Big EarsBig Ears

It looks like you might have just answered a question I was about to have, before I had to ask it.


Thanks for the well timed posting! 


Thanks John, your question was very much helpful in my development.


And i thank others who as replied.


Veni M


Can u reproduce the same for a wrapper class and a custom object???