You need to sign in to do that
Don't have an account?
Ritesh__
PageBlock Button not rendering on the bottom
i am creating a visualforce page . i am using dynamic component in it. my visual force page code is
<apex:page title="Opportunity Display" controller="MyPageController1" showHeader="true" sidebar="false" readOnly="true" cache="false"> <apex:sectionHeader subtitle="SOQL Offset Example w/Dynamic Page Buttons" title="Opportunity Display Table"/> <apex:form > <apex:pageBlock > <apex:dynamicComponent componentValue="{!myCommandButtons}"/> <apex:actionFunction action="{!refreshGrid}" name="queryByPage" reRender="myPanel,myButtons" > <apex:param name="firstParam" assignTo="{!selectedPage}" value="" /> </apex:actionFunction> <apex:pageBlockSection title="Opportunity Display (Total List Size: {!total_size})" collapsible="false"> <apex:outputPanel id="myPanel"> <apex:pageMessages id="theMessages" /> <apex:pageBlockTable value="{!opportunity}" var="n" align="center"> <apex:column ><apex:inputCheckbox value="{!n.checked}"/></apex:column> <apex:column value="{!n.cat.Id}" /> <apex:column value="{!n.cat.Name}" /> <apex:facet name="footer">Showing Page # {!pageNumber} of {!totalPages}</apex:facet> </apex:pageBlockTable> </apex:outputPanel> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
and the code segment from where i am retrieving dynamic component is
public Component.Apex.pageBlockButtons getMyCommandButtons() { //the reRender attribute is a set NOT a string Set<string> theSet = new Set<string>(); theSet.add('myPanel'); theSet.add('myButtons'); integer totalPages; if (math.mod(total_size, list_size) > 0) { totalPages = total_size/list_size + 1; } else { totalPages = (total_size/list_size); } integer currentPage; if (selectedPage == '0') { currentPage = counter/list_size + 1; } else { currentPage = integer.valueOf(selectedPage); } Component.Apex.pageBlockButtons pbButtons = new Component.Apex.pageBlockButtons(); pbButtons.location = 'both' ; pbButtons.id = 'myPBButtons'; Component.Apex.outputPanel opPanel = new Component.Apex.outputPanel(); opPanel.id = 'myButtons'; //the Previous button will alway be displayed Component.Apex.commandButton b1 = new Component.Apex.commandButton(); b1.expressions.action = '{!Previous}'; b1.title = 'Previous'; b1.value = 'Previous'; b1.expressions.disabled = '{!disablePrevious}'; b1.reRender = theSet; opPanel.childComponents.add(b1); for (integer i=0;i<totalPages;i++) { Component.Apex.commandButton btn = new Component.Apex.commandButton(); if (i+1==1) { btn.title = 'First Page'; btn.value = 'First Page'; btn.rendered = true; } else if (i+1==totalPages) { btn.title = 'Last Page'; btn.value = 'Last Page'; btn.rendered = true; } else { btn.title = 'Page ' + string.valueOf(i+1) + ' '; btn.value = ' ' + string.valueOf(i+1) + ' '; btn.rendered = false; } if ( (i+1 <= 5 && currentPage < 5) || (i+1 >= totalPages-4 && currentPage > totalPages-4) || (i+1 >= currentPage-2 && i+1 <= currentPage+2)) { btn.rendered = true; } if (i+1==currentPage) { btn.disabled = true; btn.style = 'color:blue;'; } btn.onclick = 'queryByPage(\''+string.valueOf(i+1)+'\');return false;'; opPanel.childComponents.add(btn); if (i+1 == 1 || i+1 == totalPages-1) { //put text after page 1 and before last page Component.Apex.outputText text = new Component.Apex.outputText(); text.value = '...'; opPanel.childComponents.add(text); } } //the Next button will alway be displayed Component.Apex.commandButton b2 = new Component.Apex.commandButton(); b2.expressions.action = '{!Next}'; b2.title = 'Next'; b2.value = 'Next'; b2.expressions.disabled = '{!disableNext}'; b2.reRender = theSet; opPanel.childComponents.add(b2); //add all buttons as children of the outputPanel pbButtons.childComponents.add(opPanel); return pbButtons; } at this line i am setting pbButtons.location = 'both' ;
so it will render bottom and top but button is rendering only at top not at bottom and when i set this line to pbButtons.location='bottom' then there is no pageblock button in the page .can any one please tell why its not rendering at the bottom??