You need to sign in to do that
Don't have an account?
Pruthvi Krishna
Output on VisualForce Page
I have this apex class and VF page:
public class OppCompare
{
public String searchText;
public List<Opportunity> results;
public String getSearchText() {
return searchText;
}
public void setSearchText(String s)
{
searchText = s;
}
public List<Opportunity> getResults() {
return results;
}
public String OppCompare { get; set; }
public String Opportunity { get; set; }
public PageReference Fetch()
{
results = [select Id, Name, Description, Amount from Opportunity where Name = 'CJMTK'];
return null;
}
}
and the VF page is :
<apex:page Controller="OppCompare">
<apex:form >
<apex:pageblock >
<apex:pageBlockSection columns="2" id="Oppcompareblock" >
<apex:inputText id="OppOriginal" value="{!searchText}"/>
<apex:inputText id="OppDup" value="{!searchText}"/>
<apex:commandButton value="Fetch" action="{!Fetch}" />
<apex:commandButton value="Fetch" action="{!Fetch}" />
<apex:inputText value="{!results[0].Id}"/>
<apex:inputText value="{!results[0].Description}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:pageBlockTable value="{!results}" var="l"
rendered="{!NOT(ISNULL(results))}">
<apex:inputText value="{!l.Id}"/>
<apex:inputText value="{!l.Description}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Results" id="results2" columns="1">
<apex:pageBlockTable value="{!results}" var="l2"
rendered="{!NOT(ISNULL(results))}">
<apex:inputText value="{!l2.Id}"/>
<apex:inputText value="{!l2.Description}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
But the l.ID and l.Description is not returning anything . The fields are blank . PLease help
public class OppCompare
{
public String searchText;
public List<Opportunity> results;
public String getSearchText() {
return searchText;
}
public void setSearchText(String s)
{
searchText = s;
}
public List<Opportunity> getResults() {
return results;
}
public String OppCompare { get; set; }
public String Opportunity { get; set; }
public PageReference Fetch()
{
results = [select Id, Name, Description, Amount from Opportunity where Name = 'CJMTK'];
return null;
}
}
and the VF page is :
<apex:page Controller="OppCompare">
<apex:form >
<apex:pageblock >
<apex:pageBlockSection columns="2" id="Oppcompareblock" >
<apex:inputText id="OppOriginal" value="{!searchText}"/>
<apex:inputText id="OppDup" value="{!searchText}"/>
<apex:commandButton value="Fetch" action="{!Fetch}" />
<apex:commandButton value="Fetch" action="{!Fetch}" />
<apex:inputText value="{!results[0].Id}"/>
<apex:inputText value="{!results[0].Description}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:pageBlockTable value="{!results}" var="l"
rendered="{!NOT(ISNULL(results))}">
<apex:inputText value="{!l.Id}"/>
<apex:inputText value="{!l.Description}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Results" id="results2" columns="1">
<apex:pageBlockTable value="{!results}" var="l2"
rendered="{!NOT(ISNULL(results))}">
<apex:inputText value="{!l2.Id}"/>
<apex:inputText value="{!l2.Description}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
But the l.ID and l.Description is not returning anything . The fields are blank . PLease help
also, you are using a custom controller which will not display column headers in the tables. Instead would suggest you to go for standard controller.
All Answers
How do you get that? I am struggling to get the output.
I tried Outputfield, but I am getting this error:
Subscript is invalid because list is empty.
But I am sure the SOQL query has some rows to return. Can you please point out the error in my code or correct it?
also, you are using a custom controller which will not display column headers in the tables. Instead would suggest you to go for standard controller.