You need to sign in to do that
Don't have an account?
hylim12
Display field result in Visualforce
Hi all, i would need some help to display a list of result in list view (pageBlockTable)
i have a very simple VF page just to display result (retrieve from webservive in format [aaa;bbb;ccc;ddd;eee]) in list view after clicking a button.
this is my VF code:
<apex:page standardController="Contact" extensions="SalesforceDB" recordSetVar="contacts"> <apex:sectionHeader title="External DB Conn" subtitle="Getting data from Local DB"/> <apex:form > <apex:pageBlock title="Policy Listing"> <apex:pageBlockButtons > <apex:commandButton value="Confirm" action="{!getDBInfo}" /> <apex:pageBlockTable value = "??" var = "c"> </apex:pageBlockTable> </apex:pageBlockButtons> <apex:pageblocksection > <!--apex:pageBlockSectionItem --> <!--apex:outputlabel value="{!'Label'}"></apex:outputlabel--> <!--apex:inputText /--> <!--/apex:pageBlockSectionItem--> </apex:pageblocksection> </apex:pageBlock> </apex:form> </apex:page>
this is my extensions class:
public class SalesforceDB{ private final Contact conc; private List <String> result; public SalesforceDB(ApexPages.StandardSetController stdcontroller) { this.conc = (Contact)stdcontroller.getRecord(); } public List<String> getDBInfo() { string MyReturn; salesforceconLocalConDB.Contactdetails stub = new salesforceconLocalConDB.Contactdetails(); stub.timeout_x = 120000 ; result = stub.getname(conc.Policy_No__c); System.debug('* Result:' + result); MyReturn = result[0]; System.debug('* MyRetrun:' + MyReturn); return result; } }
what should i put to display the result in list view??
Hi,
It looks as the "result" list is empty.and u are trying to get the 0th element from that list
String spl_value = result[0];
That's why it gives error.Why r u not using System.Debug to check whether the list has value or not and u need to use NUll check in each places.
Please let me know if u have any problem on same and if this post hepls u please throw KUDOS by click on star at left.
All Answers
You can use your list in
Assuming that the list is your object list.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
i've changed my VF to:
and my controller extensions to:
but when i click on Search button, i still didnt see my result return.
my result return from Wenservice is [aaa;bbb;ccc;ddd]. any help pls?
HI,
Please change your code as:
public void search(){
result2 = new List<String>();
salesforceconDB.Contactdetails stub = new salesforceconDB.Contactdetails();
stub.timeout_x = 120000 ;
result = stub.getname(conc.Policy_No__c);
for(Integer a = 0; a <= result.size(); a++){
String spl_value = result[0];
result2.addAll( spl_value.split(';'));
}
}
And remove
public List <String> result2() {
return result;
}
Please let me know if u have any problem on same if this post helps u please throw KUDOS by click on star at left.
there is one part i do not understand. My return result from my webservice is something like [2013-10-01;1200001;AAA;BBB;CCC]
when i want to display a list view in my contact page, with this line of code
<apex:pageBlockTable value="{!result2}" var="c" >
<apex:column value="{!c}" headerValue="Key" />
<apex:column value="{!c}" headerValue="Name" />
</apex:pageBlockTable>
how it determine that column 1 is Date, 2 is Ref_No and so on?
Thanks!
I modify my apexcode to:
However, i keep getting error
'System.NullPointerException: Attempt to de-reference a null object
Class.SalesforceDB.search: line 43, column 1'
What am i missing?
Hi,
It looks as the "result" list is empty.and u are trying to get the 0th element from that list
String spl_value = result[0];
That's why it gives error.Why r u not using System.Debug to check whether the list has value or not and u need to use NUll check in each places.
Please let me know if u have any problem on same and if this post hepls u please throw KUDOS by click on star at left.
Yes you are right. System.Debug helps me found my problem.
Thanks alot! You save my day =)