You need to sign in to do that
Don't have an account?

Data not displaying
Hi,
I Have created a custom object and inserted data into it. I have written a VisualForce Page and an Apex Controller to search the data. I could see the count in logs, but the data is not displaying on the VF Page. Below is my Code
VisualForce Page
<apex:page controller="ItemController">
<style>
.activeTab {background-color: #236FBD; color:white;
background-image:none}
.inactiveTab { background-color: lightgrey; color:black;
background-image:none}
</style>
<apex:tabPanel title="Panel1" inactiveTabClass="inactiveTab" switchType="client" selectedTab="addItem" activeTabClass="activeTab">
<apex:tab label="Add Items" name="Master1" id="addItem">
<apex:outputText >You Can add/Remove Items Details Here</apex:outputText>
<apex:form >
<!-- <apex:commandButton value="Add Item" reRender="details"/>-->
<apex:pageBlock title="details">
<apex:pageBlockSection title="ADD ITEMS">
<p> Item Name:<apex:inputText value="{!Name}"/></p>
<p> Item Desc:<apex:inputTextarea value="{!Name}" rows="3"/></p>
<p> Item Price:<apex:inputText value="{!Name}"/></p>
<p> Added By:<apex:inputText value="{!Name}"/></p>
<p> Added On:<apex:inputText value="{!Name}"/></p>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:tab>
<apex:tab label="Search Items" id="Master2">
<APEX:OUTputLabel >You Can Search For Items Here</APEX:OUTputLabel>
<apex:form >
<apex:outputLabel >Enter Item:</apex:outputLabel>
<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Search" action="{!searchItem}" rerender="Results" status="status">
</apex:commandButton>
<apex:pageBlock >
<apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:pageBlockTable value="{!itemDetails}" var="items" rendered="{!NOT(ISNULL(itemDetails))}">
<apex:column value="{!items.Price__c}" headerValue="Price"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:tab>
<apex:tab label="View Sales" id="viewSales">
<apex:outputText >You can view the Sales Report Here</apex:outputText>
</apex:tab>
<apex:tab label="Buy Items" id="butItems">
<apex:outputText >You Can Buy Items here</apex:outputText>
</apex:tab>
</apex:tabPanel>
<apex:toolbar >
</apex:toolbar>
</apex:page>
Apex Controller
-------------------------
public class ItemController {
public String results { get; set; }
public List<ShopItem__c> itemDetails {get;set;}
public PageReference searchItem() {
String qry = 'select Price__c from ShopItem__c where ItemName__c =:searchText order By Price__c';
system.debug('Query:'+qry);
itemDetails = Database.query(qry);
// itemDetails = (List<ShopItem__c>)[select ItemName__c from ShopItem__c];
system.Debug('itemDetailssize***:'+itemDetails.size());
return null;
}
public String searchText { get; set; }
public String Name { get; set; }
public String ShopItem { get; set; }
public PageReference saveItem() {
return null;
}
}
Kindly Please help
Regards
Venkat
Hi
try this code
<apex:page controller="ItemController">
<style>
.activeTab {background-color: #236FBD; color:white;
background-image:none}
.inactiveTab { background-color: lightgrey; color:black;
background-image:none}
</style>
<apex:tabPanel title="Panel1" inactiveTabClass="inactiveTab" switchType="client" selectedTab="addItem" activeTabClass="activeTab">
<apex:tab label="Add Items" name="Master1" id="addItem">
<apex:outputText >You Can add/Remove Items Details Here</apex:outputText>
<apex:form >
<!-- <apex:commandButton value="Add Item" reRender="details"/>-->
<apex:pageBlock title="details">
<apex:pageBlockSection title="ADD ITEMS">
<p> Item Name:<apex:inputText value="{!Name}"/></p>
<p> Item Desc:<apex:inputTextarea value="{!Name}" rows="3"/></p>
<p> Item Price:<apex:inputText value="{!Name}"/></p>
<p> Added By:<apex:inputText value="{!Name}"/></p>
<p> Added On:<apex:inputText value="{!Name}"/></p>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:tab>
<apex:tab label="Search Items" id="Master2">
<APEX:OUTputLabel >You Can Search For Items Here</APEX:OUTputLabel>
<apex:form >
<apex:outputLabel >Enter Item:</apex:outputLabel>
<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Search" action="{!searchItem}" rerender="re" status="status">
</apex:commandButton>
<apex:pageBlock >
<apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:ouputpanel id="re">
<apex:pageBlockTable value="{!itemDetails}" var="items" rendered="{!NOT(ISNULL(itemDetails))}">
<apex:column value="{!items.Price__c}" headerValue="Price"/>
</apex:pageBlockTable>
</apex:outputpanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:tab>
<apex:tab label="View Sales" id="viewSales">
<apex:outputText >You can view the Sales Report Here</apex:outputText>
</apex:tab>
<apex:tab label="Buy Items" id="butItems">
<apex:outputText >You Can Buy Items here</apex:outputText>
</apex:tab>
</apex:tabPanel>
<apex:toolbar >
</apex:toolbar>
</apex:page>
If it is not working please let me know
All Answers
Hi
try this code
<apex:page controller="ItemController">
<style>
.activeTab {background-color: #236FBD; color:white;
background-image:none}
.inactiveTab { background-color: lightgrey; color:black;
background-image:none}
</style>
<apex:tabPanel title="Panel1" inactiveTabClass="inactiveTab" switchType="client" selectedTab="addItem" activeTabClass="activeTab">
<apex:tab label="Add Items" name="Master1" id="addItem">
<apex:outputText >You Can add/Remove Items Details Here</apex:outputText>
<apex:form >
<!-- <apex:commandButton value="Add Item" reRender="details"/>-->
<apex:pageBlock title="details">
<apex:pageBlockSection title="ADD ITEMS">
<p> Item Name:<apex:inputText value="{!Name}"/></p>
<p> Item Desc:<apex:inputTextarea value="{!Name}" rows="3"/></p>
<p> Item Price:<apex:inputText value="{!Name}"/></p>
<p> Added By:<apex:inputText value="{!Name}"/></p>
<p> Added On:<apex:inputText value="{!Name}"/></p>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:tab>
<apex:tab label="Search Items" id="Master2">
<APEX:OUTputLabel >You Can Search For Items Here</APEX:OUTputLabel>
<apex:form >
<apex:outputLabel >Enter Item:</apex:outputLabel>
<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Search" action="{!searchItem}" rerender="re" status="status">
</apex:commandButton>
<apex:pageBlock >
<apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:ouputpanel id="re">
<apex:pageBlockTable value="{!itemDetails}" var="items" rendered="{!NOT(ISNULL(itemDetails))}">
<apex:column value="{!items.Price__c}" headerValue="Price"/>
</apex:pageBlockTable>
</apex:outputpanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:tab>
<apex:tab label="View Sales" id="viewSales">
<apex:outputText >You can view the Sales Report Here</apex:outputText>
</apex:tab>
<apex:tab label="Buy Items" id="butItems">
<apex:outputText >You Can Buy Items here</apex:outputText>
</apex:tab>
</apex:tabPanel>
<apex:toolbar >
</apex:toolbar>
</apex:page>
If it is not working please let me know
Hi,
Thank you for the solution.
Can you please let me know where i went wrong. so that i will take care the next time.
Thank You
Venkat
hey nothing is there
the page is not reredering just i have added <apex:ouputpanel> with id and that id i have given in <apex:commandbutton>
if you gave pageblock id value in rerender some tiems the page won't be rerender better to use <apex:outpanel>
<apex:commandButton value="Search" action="{!searchItem}" rerender="re" status="status">
<apex:ouputpanel id="re">
<apex:pageBlockTable value="{!itemDetails}" var="items" rendered="{!NOT(ISNULL(itemDetails))}">
<apex:column value="{!items.Price__c}" headerValue="Price"/>
</apex:pageBlockTable>
</apex:outputpanel>