You need to sign in to do that
Don't have an account?
ckellie
Render pageblock when item is selected
I am working on a search page where the user will search for an item, the page will return a list of results, the user will make a selection, and then a page block below will render. I have been looking at the dynamic edit example and have not been successful yet.
Here is my vf page:
<apex:page standardcontroller="Customer_Product_Line_Item__c" extensions="AddCustomerProductStage1vfhide" > <!-- Javascript function to check all rows in the table --> <script> function checkAll(cb) { var inputElem = document.getElementsByTagName("input"); for(var i=0;i<inputElem.length;i++)https://c.cs4.visual.force.com/s.gif { if(inputElem[i].id.indexOf("selectLine1")!=-1) inputElem[i].checked = cb.checked; } } </script> <!-- End of Javascript function --> <apex:form > <apex:pageblock title="Choose Customer Product"> <apex:pageBlockSection columns="1"></apex:pageBlockSection> <!-- Panel grid to display boxes o accept user input values --> <apex:panelGrid columns="2"> <apex:outputLabel style="font-weight:bold;" value="Customer Product" ></apex:outputLabel> <apex:inputText value="{!userinput}" /> </apex:panelGrid> <!-- End of panelgrid --> <!-- Div to position the commandbutton appropriately --> <div style="position:relative;left:75px;"> <apex:commandButton value="Search" action="{!cpsearch}" /> </div> <!-- Display search results --> <apex:pageblocksection columns="1" title="Customer Product Search Results" > <apex:outputpanel id="Contactlist"> <apex:pageBlockTable value="{!results}" var="cp" > <apex:column width="25px" > <apex:outputPanel > <apex:inputCheckbox value="{!cp.selected}" id="selectLine1"/> <apex:actionStatus startText="applying value..." id="status"/> </apex:outputPanel> </apex:column> <apex:column headervalue="Customer Product"> <apex:outputtext value="{!cp.con.Name}"/> </apex:column> </apex:pageBlockTable> <br/><br/> </apex:outputpanel> </apex:pageblocksection> </apex:pageblock> <apex:outputpanel > <apex:pageblock title="Attributes for {!cpsel}" id="thePageBlock" rendered="{!cpsel}>0"> <apex:pageblocksection columns="2"> <apex:inputfield value="{!Customer_Product_Line_Item__c.Condition_1__c}" required="false"/> <apex:inputfield value="{!Customer_Product_Line_Item__c.Condition_2__c}" required="False"/> <apex:inputHidden /> <apex:inputfield value="{!Customer_Product_Line_Item__c.Condition_3__c}" required="false"/> <apex:inputfield value="{!Customer_Product_Line_Item__c.Shape_1__c}" required="false"/> <apex:inputfield value="{!Customer_Product_Line_Item__c.Shape_2__c}" required="False"/> <apex:inputfield value="{!Customer_Product_Line_Item__c.Capacity__c}" required="false"/> <apex:inputHidden /> <apex:inputfield value="{!Customer_Product_Line_Item__c.Size__c}" required="false"/> <apex:inputHidden /> <apex:inputfield value="{!Customer_Product_Line_Item__c.Additional_Information__c}" required="false"/> <apex:inputHidden /> </apex:pageblocksection> </apex:pageBlock> </apex:outputpanel> </apex:form> </apex:page>
Apex class:
public class AddCustomerProductStage1vfhide{ /* Constructor Function. The CustomerProduct id is captured in this function */ public Customer_Product_Line_Item__c cpl {get;set;} public Opportunity o; public AddCustomerProductStage1vfhide(ApexPages.StandardController c) { o = [select id from Opportunity where id = :ApexPages.currentPage().getParameters().get('oppid')]; } public Opportunity getOpportunity() { return o; } /* Variable declarations */ public List<cCustomer> cpList {get; set;} // Wrapper class which stores customer product data and a boolean flag. public List<cCustomer> cpsel{get; set;} public ID oid {get; set;} public String userinput ='' ; // cp Name public String userinp; pageReference test(){ return null; } Public List<Customer_Product__c> results = new List<Customer_Product__c>(); // Customer_Product__c search results. Public List<Customer_Product__c> selproduct = new List<Customer_Product__c>(); // Customer_Product__c selectedproduct. /* End of Variable declarations */ /* Getter and setter methods for getting the user input ie. Customer_Product__c name from the UI */ public String getuserinput(){return userinput;} public void setuserinput(String userinp1) { this.userinput=userinp1; system.debug('*****SFDC-TEST-1**********'+userinput+'='+userinp); } public String getselproduct(){return null;} /*End of Getter and Setter methods */ /* Method to Search the Customer_Product__c database to return the query results */ public List<Customer_Product__c> cpsearch() { cpList = new List<cCustomer>(); for(Customer_Product__c c : [select id, name from Customer_Product__c where Name like :userinput+'%' order by Name asc]) { cCustomer c1=new cCustomer(c); c1.Selected=false; // cpList.add(new cCustomer(c)); cpList.add(c1); } system.debug('*****SFDC-TEST-2**********'+cpList); if(Test.isRunningTest()) { getuserinput(); getopportunity(); getselproduct(); } return null; } /* End of method */ /* Method for returning the Customer Product search results to the UI */ public List<cCustomer> getresults() { if(Test.isRunningTest()) { cpsearch(); } System.debug('$$$$$$$$'+cpList); return cpList; } public PageReference processSelected() { //We create a new list of Customer Products that we be populated only with Customer Products if they are selected List<Customer_Product__c> selectedProduct = new List<Customer_Product__c>(); System.debug('%%%%%%%%%%%%'+getresults()); //We will cycle through our list of cCustomer and will check to see if the selected property is set to true, //if it is we add the Customer Product to the selectedProduct list for(cCustomer cCon : getresults()) { System.debug('#####'+cCon.selected); if(cCon.selected == true) { selectedProduct.add(cCon.con); } } if(test.isRunningTest()){ getresults(); } system.debug('*****SFDC-TEST-3**********'+selectedProduct); // Now we have our list of selected products and can perform any type of logic we want System.debug('These are the selected Products...'); for(Customer_Product__c cCon : SelectedProduct ) { system.debug(cCon); selproduct.add(cCon); } system.debug('*****SFDC-TEST-4**********'+selproduct.size()); cpsel = new List<cCustomer>(); for(Customer_Product__c p : [select name from Customer_Product__c where id =:selproduct]) { system.debug('*****SFDC-TEST-p**********'+p.name); cpsel.add(new cCustomer(p)); }return null; } /* Wrapper class to contain customer product record and a boolean flag */ public class cCustomer{ public Customer_Product__c con {get; set;} public Boolean selected {get; set;} public cCustomer (Customer_Product__c c) { con = c; selected = false; } } /* end of Wrapper class */ }
Thank you
Hi,
Please try having an id for the outputpanel and rerender the output panel in your action status. This should solve your probem.
Thanks,
Aravind
All Answers
Hi,
I think "rendered" is different
Thank you for the suggestion, but when I tried this, it did not work.
Hi,
Please try having an id for the outputpanel and rerender the output panel in your action status. This should solve your probem.
Thanks,
Aravind