I deleted the previous code that I had on this post.
I modified my code again:
Now I am getting this error If I press the Search Button from VF page:
Return type of an Apex action method must be a PageReference. Found: core.apexpages.el.adapters.ApexListELAdapter
public class WrapperDemoController2{
public String sfprn { get; set; }
public String searchPatients { get; set; }
public String mrn {get;set;}
public class TableRow2{
public String sfprn {get;set;}
public String mrn {get;set;}
public Decimal SurveySelection {get;set;}
}
public List<TableRow2> RowList {get; set;}
public List<TableRow2> searchPatients(){
RowList = new List<TableRow2>();
TableRow2 tr;
for(Patient__c con : [SELECT sfprn__c,
mrn__c,
(select SurveySelection__c.SurveySelection__c from SurveySelections__r)
FROM Patient__c
where mrn__c =:mrn
]){
tr = new TableRow2();
tr.sfprn = con.sfprn__c;
tr.mrn = con.mrn__c;
tr.SurveySelection = con.SurveySelections__r.isEmpty() ? null : con.SurveySelections__r[0].SurveySelection__c;
RowList.add(tr);
}
return RowList;
}
}
<apex:page Controller="WrapperDemoController2">
<apex:form >
<apex:pageBlock >
<!-- Serarch button-->
<apex:pageBlockButtons location="top">
<apex:commandButton value="Search" action="{!searchPatients}" reRender="contact-table"/>
</apex:pageBlockButtons>
<apex:pageBlockSection id="contact-table" columns="1">
<!-- Input -->
<apex:pageBlockSectionItem >
<apex:outputLabel value="MRN" />
<apex:inputText value="{!mrn}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<!-- Output --->
<apex:pageBlockTable value="{!RowList}" var="c">
<apex:column value="{!c.mrn}"/>
<apex:column value="{!c.sfprn}"/>
<apex:column value="{!c.SurveySelection}"/>
</apex:pageBlockTable>
</apex:pageBlock>