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

Having trouble making an APEX call from my VF page.
Hi devs!
VF page uses
<apex:repeat value="{!optionRows}" var="opRow">
To display info. To be honest I am not sure what/where/how this opRow object is populated.
Nevertheless the opRow var here contains a field that is the same as a Product name.
I am trying to return a feild off of the Product record that is related to the opRow var by product name(as you can see in the SOQL in the apex).
Here are some code snippets showing how I tried to do this. The code below is most defiantly not correct and may or may not be helpful. Please let me know if any additonal info is required in order to help me.
The person who provides an answer will be eligible for a 0.01 BTC reward if you are interested :)
<APEX CODE>
public OptionRow2 OpRow{get;set;}
public Product2 getProductFromOpRow()
{
if(OpRow.dropdownname == null)
{
myProduct = [select Product_Image_URL__c from Product2 where name = :OpRow.CheckBoxName];
}
if(OpRow.CheckBoxName == null)
{
myProduct = [select Product_Image_URL__c from Product2 where name = :OpRow.dropdownname];
}
return myProduct;
}
</APEX CODE>
<VF CODE>
<div class="image"> <apex:repeat value="{!ProductFromOpRow}" var="opRowP">
<apex:image url="!opRowP.Product_Image_URL__c " rendered=
"{! if(opRowP.Product_Image_URL__c != null && opRow.isDropDown == false,true,false)}" /> </apex:repeat> </div>
</VF CODE>
Hi Beretta,
There are some glitches in your VF page:
- apex:repeat value attribute takes a collection of object, but your getProductFromOpRow() doesn't return a collection.
- there is no SRC attribute in apex:image, you should use Value attribute instead of SRC
- you can't use apex syntax in VF page, use functions instead.
Some references:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_repeat.htm
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_image.htm
http://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_functions.htm
Regards,
Hengky
OK I agree with all of your suggestions. Thanks!
I am getting an error now right after I call the apex. I don't think I am passing my OpRow object to the apex from the VF because the error occurs at the very first reference to the OpRow object in my Apex method.
Thanks