+ Start a Discussion

Trying to pass a variable from a VF page to Apex to change the results in a component.

I have a page that will display a basket summary, this basket will be used on several pages showing different results based on a variable i am trying to send to the controller from the VF page.
VF Page
<apex:variable var="prodType" value="Cars"/>
 <c:sfoProductList />
Component - sfoProductList
<apex:component controller="sfoHCCTRL">
<apex:repeat value="{!BasketProducts}" var="p">
public String prodType{get; set;}    

public List<Order_Product__c> getBasketProducts() {
        List<Order_Product__c> prodList = [SELECT ID, Product_Name__c, Type__c FROM Order_Product__c WHERE Type__c = :prodType];
        return prodList;
The value of prodType is set to Cars on the VF page, and is sent to the component ok. When the controller returns the list the value is blank.

I have seen many solutions showing parameters being passed but that only seems to work as part of a submit, not on a page render. Is it possible to do it in this way I am trying?
William TranWilliam Tran
Hard to understand what you are doing since only snippets of code are posted.  That said, render only changes the aspect of the VF pages (like visibility) and do not trigger a call to the controller class.

Why don't you try create an inputtext and bind that with the variable prodType.  then onchange rerender the component to see if the component now take the parameter which is value of the input text