I have just started making this , its a small e commerce website, its just the basic at the moment i am just trying to learn.
I have the products list page below which is to display all the products available for sale. And then there is the controller for it
VF Page
<apex:page controller="productslistpage" showHeader="false">
<Apex:form >
<apex:outputText value="{!usermode} {!Name}" style="float:right;font-weight:bold;color:black;font-size:16px;text-align:left;" />
<br/><p style="font-size:19px;font-weight:bold;"> Products available today </p><br/>
<apex:CommandLink action="{!prod1button}" ><br/>
<apex:image url="{!$Resource.Testprod1}" width="100" height="180"/><br/>
<h3>Logo Shirt (Gray)</h3>
</apex:commandlink>
<p>$20.00</p>
</apex:form>
</apex:page>
Controller
public Class productslistpage{
public list<inventory__c> prodlist{get; set;}
public string PID{get; set;}
public string name{get; set;}
public string usermode{get; set;}
public productslistpage(){
this.name = ApexPages.currentPage().getParameters().get('Name');
this.usermode = ApexPages.currentPage().getParameters().get('usermode');
prodlist = [Select ButtonName__c,Name, Price__c, Stocks__c,productid__c from Inventory__c];
}
PageReference pg = new PageReference('/apex/testprodpage');
public pagereference prod1button(){
PID = '10004';
pg.getParameters().put('PID', PID);
return pg;
}
}
in both , I have a prodbutton
method for product 1[Product 1 as in the VF page] in controller .
Now the mess is I don't want to make button method for each product as well as each hard coded code for the product in VF page.