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
anuj pathak 2anuj pathak 2 

visualforce list item

I am not able to get opportunity List in VF page , can you please suggest what i doing wrong
 
<apex:page controller="OppsearchController">
<apex:form >
<apex:pageBlock id="pb" mode="edit">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="Search String">Search String</apex:outputLabel>
<apex:panelGroup >
<apex:inputText value="{!searchString}"/>
<apex:commandButton value="GO" action="{!oppResults}" status="as" reRender="pbt"/>
<apex:actionStatus startText="Searching......." id="as"></apex:actionStatus>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="Result">
<apex:pageBlockTable value="{!OppSearchResult}" var="opp" id="pbt">
<apex:column value="{!opp.name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class OppsearchController {

	List<Opportunity> OppSearchResult;
	public String searchString { get; set; }
	
	public List<Opportunity> getOppSearchResult() {
		return OppSearchResult;
	}

	public PageReference oppResult() {
		OppSearchResult = (List<Opportunity>)[FIND :searchString RETURNING Opportunity(Name)][0];
		return null;
	}
}


 
Best Answer chosen by anuj pathak 2
mukesh guptamukesh gupta
Hi Anuj,

Please use below code
 
<apex:page controller="OppsearchController">
<apex:form >
<apex:pageBlock id="pb" mode="edit">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="Search String">Search String</apex:outputLabel>
<apex:panelGroup >
<apex:inputText value="{!searchString}"/>
<apex:commandButton value="GO" action="{!oppResult}" status="as" reRender="pbt"/>
<apex:actionStatus startText="Searching......." id="as"></apex:actionStatus>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="Result">
<apex:pageBlockTable value="{!OppSearchResult}" var="opp" id="pbt">
<apex:column value="{!opp.name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

if you need any assistanse, Please let me know!!


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

All Answers

mukesh guptamukesh gupta
Hi Anuj,

Please use below code
 
<apex:page controller="OppsearchController">
<apex:form >
<apex:pageBlock id="pb" mode="edit">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="Search String">Search String</apex:outputLabel>
<apex:panelGroup >
<apex:inputText value="{!searchString}"/>
<apex:commandButton value="GO" action="{!oppResult}" status="as" reRender="pbt"/>
<apex:actionStatus startText="Searching......." id="as"></apex:actionStatus>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection title="Result">
<apex:pageBlockTable value="{!OppSearchResult}" var="opp" id="pbt">
<apex:column value="{!opp.name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

if you need any assistanse, Please let me know!!


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
This was selected as the best answer
Suraj Tripathi 47Suraj Tripathi 47
Hi anuj,
Greetings!!

You are not letting your variable to available on the VF page because you have not applied get; set; on the  OppSearchResult list.
Please apply get; set; on the list.
    List<Opportunity> OppSearchResult {get; set;}
If this helped you please mark it as the best answer.
If there is any issue please mention it.
Thank you!

Regards,
Suraj Tripathi