You need to sign in to do that
Don't have an account?
Alex Sasha
<apex: param> doesn't work
I' m passing parametrs ro controller from 2 palaces
first look like:
<apex:dataTable id="tableCategories" value="{!products}" var="prod" styleClass="table table-striped"> ....... <apex:column > <apex:form > <apex:commandButton action="{!makevisibleProduct}" value="View details" styleClass="btn-success"> <apex:param name="product" value="{!prod.name}"/> </apex:commandButton> </apex:form> </apex:column>
controller:
public with sharing class HomeController { private String ProdName; public PageReference makevisibleProduct(){ productVisibility=true; ProdName = ApexPages.currentPage().getParameters().get('product'); return null; } public Boolean getisVisibleProduct(){ return productVisibility; }
Then I want to render particualr product detail with name= Prodname;
Public Product__c getProduct(){ List<Product__c> products =[Select name, description__c, quantity__c,price__c from Product__c WHERE name =: ProdName ]; return products[0]; }
Table that should displays products:
<apex:pageBlock id ="tableProduct" rendered="{!isVisibleProduct}" mode="maindetail"> <vs:panel title="Demo Panel Primary" type="primary"> <table class="table table-condensed" > <tr> <td class="active">{!product.name} </td> </tr> ....
Whe clicking the button output is:
Visualforce Error
Help for this Page
System.ListException: List index out of bounds: 0
Class.HomeController.getProduct: line 57, column 1
this line:
return products[0];
But strangely thing that a has nearly the same button in another place of code which works fine:
<apex:form > <apex:repeat value="{!categories}" var="cat" id="theRepeat"> <apex:commandButton reRender="tableCategories" style="margin:4px" value="{!cat.name}" styleClass="btn-success"> <apex:param name="category" value="{!cat.name}"/> </apex:commandButton> </apex:repeat> </apex:form>
<apex:dataTable id="tableCategories" value="{!products}" var="prod" styleClass="table table-striped"> <apex:facet name="header">Products</apex:facet> <apex:column value="{!prod.Category__r.name}" headerValue="Category name"/> <apex:column value="{!prod.name}" headerValue="Product name"/> .....
controller side
public List<Product__c> getProducts(){ String CategoryName = ApexPages.currentPage().getParameters().get('category'); List<Category__c> categs = [SELECT(select id, name, Category__r.name,Maker__r.name, description__c from product__r) from Category__c WHERE name = :CategoryName]; ... products = categs[0].product__r; return products;
If the above doesn't work, do let me know if it would be possible for you to share your credentials.
I might have to debug your page.
All Answers
Something like below
reRender tag is required for apex:param to get working. As you can see in your second code, the command button has a reRender attribute.
Ok, but now i'm getting another problem, when i'm clicking my button, nothing happens, so/ it seems like rendered state is not being switched
Unfortunately it didnt' help. I dont't know What else can I do except show all pages and controller. Help me please it's very important
Whole page
Controller
If the above doesn't work, do let me know if it would be possible for you to share your credentials.
I might have to debug your page.
If my suggestion(s) helped you, do mark it as the "Best Answer" right under the comment.
This will help the rest of the community should they have a similar issue in the future.
Thank you..
I mean why it works only in such a way and neither <apex:outputPanel id="tableProduct" rendered="{!productVisibility}" > no
<apex:pageBlock id= "tableProduct" rendered="{!productVisibility}">
I hope this explains your query.