-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
0Questions
-
1Replies
Help with PageblockTable and Select List
Hi!
Now i'm working on a VF page that in one column has a select list and allows the user to select a value from the list and reRender a cross-tabular report on the same page. The issue comes with the picklists, the controller only gets the last value of the pageblocktable picklist.
any help? pls!
=============================================================================================
here is the VF page:
<apex:page standardcontroller="account" extensions="mtc_TerritoryDesigner2" readOnly="true"> <script> function hi(){ return "hi"; } </script> <apex:form > <apex:SectionHeader title="MTC Overview" subtitle="MTC"/> <apex:toolbar id="toolbar" style="background-color:#EEECD1;background-image:none;" height="20px;"> <apex:toolbarGroup > <apex:commandLink value="Territory Designer"/> <apex:commandLink value="Manager Grid"/> <apex:commandLink value="SA Grid"/> <apex:commandLink value="Industry Grid" /> <apex:commandLink value="Detail Assigment"/> <apex:commandLink value="MTC Overview"/> </apex:toolbarGroup> </apex:toolbar> <apex:pageBlock > <apex:pageBlockSection > <apex:pageblocktable value="{!Accounts}" var="arr" id="accounts"> <apex:column > <apex:facet name="header"> </apex:facet> <apex:facet name="footer">Totals</apex:facet> <apex:outputText value="{!arr.UserName}" /> </apex:column> <apex:column > <apex:facet name="header"># of Customer</apex:facet> <apex:facet name="footer"><apex:outputText value="{!FinalTotalCustomers}" /></apex:facet> <apex:outputText value="{!arr.TotalCustomers}" > </apex:outputText> </apex:column> <apex:column > <apex:facet name="header"># of Non Customer</apex:facet> <apex:facet name="footer"><apex:outputText value="{!FinalTotalNonCustomers}" /></apex:facet> <apex:outputText value="{!arr.TotalNonCustomers}" /> </apex:column> <apex:column > <apex:facet name="header"># of Open Coverage</apex:facet> <apex:facet name="footer"><apex:outputText value="{!FinalTotalOpenCoverages}" /></apex:facet> <apex:outputText value="{!arr.TotalOpenCoverages}" /> </apex:column> <apex:column > <apex:facet name="header"># of MIF</apex:facet> <apex:facet name="footer"><apex:outputText value="{!FinalTotalEquipment}" /></apex:facet> <apex:outputText value="{!typeSelected}" /> </apex:column> <apex:column > <apex:facet name="header"># of Leases</apex:facet> <apex:facet name="footer"><apex:outputText value="{!FinalTotalLease}" /></apex:facet> <apex:outputText value="{!conttype}" /> </apex:column> </apex:pageblocktable> </apex:pageBlockSection> <apex:pageBlockSection title="Accounts by Zip" id="SecondSection" columns="1" > <apex:pageMessages ></apex:pageMessages> <script> j$('#dialogPopup').dialog('close'); </script> <apex:pageBlockTable value="{!AccountsByZip}" var="ar" styleClass="sortable" id="accountsbyzip"> <apex:column > <apex:facet name="header">Zip</apex:facet> <apex:outputText value="{!ar.Zip}" /> </apex:column> <apex:column > <apex:facet name="header">Owner</apex:facet> <apex:outputText value="{!ar.ownerName}" > </apex:outputText> </apex:column> <apex:column > <apex:facet name="header"># of Establishments</apex:facet> <apex:outputText value="{!ar.NumAccounts}" /> </apex:column> <apex:column > <apex:facet name="header"># of Customers</apex:facet> <apex:outputText value="{!ar.NumCustomers}" > </apex:outputText> </apex:column> <apex:column > <apex:facet name="header"># of Non Customers</apex:facet> <apex:outputText value="{!ar.NumNonCustomers}" /> </apex:column> <apex:column > <apex:facet name="header"># of Open Coverage</apex:facet> <apex:outputText value="{!ar.NumOpenCoverages}" /> </apex:column> <apex:column > <apex:facet name="header">Reassign</apex:facet> </apex:column> <apex:column > <apex:facet name="header">Type</apex:facet> <apex:selectList value="{!typeselected}" size="1"> <apex:selectOptions value="{!ar.AccTypex}"/> </apex:selectList> </apex:column> <apex:column > <apex:facet name="header">Preview</apex:facet> <apex:commandButton value="Preview" style="width: 100px;" action="{!dofetchAccounts}" rerender="accounts" > <apex:param name="contCustomers" value="{!ar.NumCustomers}" assignTo="{!contCustomers}"/> <apex:param name="contNonCustomers" value="{!ar.NumNonCustomers}" assignTo="{!contNonCustomers}"/> <apex:param name="contOpenCoverages" value="{!ar.NumCustomers}" assignTo="{!contOpenCoverages}"/> <apex:param name="contName" value="{!ar.OwnerName}" assignTo="{!contName}"/> <apex:param name="contType" value="{!ar.typeselected}" assignTo="{!contType}"/> </apex:commandButton> </apex:column> <apex:column > <apex:facet name="header">Processing</apex:facet> <apex:commandButton value="Processing"/> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageblock> </apex:form> </apex:page>
here is the controller:
public class mtc_TerritoryDesigner2 { private ApexPages.StandardController stdCtrl {get; set;} public list<AggregateResult> listAr = new list<AggregateResult>(); public list<AggregateResult> listAr2 = new list<AggregateResult>(); String CurrentUser = UserInfo.getUserId(); String currentUserRole = UserInfo.getUserRoleId(); List<UserRole> RepRole = [Select id from UserRole where parentroleid =: currentUserRole]; List<id> RepsId = new List<id>(); List<User> Users = [select name from User where isactive = true AND userroleid =: RepRole order by Name]; Integer FinalCustomers, FinalNonCustomers, FinalOpenCoverages, FinalEquipment = 0, FinalLease = 0, ReassingCustomersAcc = 0, contCustomers2; public Integer getFinalTotalCustomers() { return finalCustomers;} public Integer getFinalTotalNonCustomers() {return finalNonCustomers;} public Integer getFinalTotalOpenCoverages() { return finalOpenCoverages;} public Integer getFinalTotalEquipment() { return finalEquipment;} public Integer getFinalTotalLease() { return finalLease;} public List<accls> Accounts2 = new List<accls>(); public List<accByZip> Accounts3 = new List<accByZip>(); public List<Accls> Accounts {get{return accounts2;} set;} public List<AccByZip> AccountsByZip {get{return accounts3;} set;} //public Integer contCustomers {get; set;} public Integer ContCustomers {get;set;} public Integer ContNonCustomers {get;set;} public Integer ContOpenCoverages {get;set;} public String contName {get;set;} public String contType {get;set;} public String TypeSelected {get;set;} //public String getTypeSelected() {return this.TypeSelected;} // public void setTypeSelected(String s) {this.TypeSelected = s;} public mtc_TerritoryDesigner2(ApexPages.StandardController controller) { stdCtrl = controller; for(User u:Users) { RepsId.add(u.id); } fetchaccounts(); fetchaccountsbyZip(); } public List<SelectOption> fetchAccTypes() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('None','None')); options.add(new SelectOption('Customer','Customer')); options.add(new SelectOption('Non Customer','Non Customer')); options.add(new SelectOption('Open Coverage','Open Coverage')); options.add(new SelectOption('All','All')); return options; } private void fetchAccounts() { accounts2.clear(); listAr = [select owner.name num, type, COUNT(id) total from account where ownerid =: RepsId GROUP BY CUBE (owner.name,type) order by owner.name]; for(User u:Users){ Accls objAccls = new Accls(); for(AggregateResult ag: listAr) { if(String.valueof(ag.get('num')) != null && string.valueof(ag.get('type')) != null && String.valueof(ag.get('num')) == u.name){ if(ag.get('type') == 'customer'){ if((string)ag.get('num') == contName ) {objAccls.totalCustomers = integer.valueof(ag.get('total')) + contCustomers ;}else{objAccls.totalCustomers = integer.valueof(ag.get('total'));}} if(ag.get('type') == 'Non customer'){ objAccls.totalNonCustomers = integer.valueof(ag.get('total'));} if(ag.get('type') == 'Open Coverage'){ objAccls.TotalOpenCoverages = integer.valueof(ag.get('total'));}else{objAccls.TotalOpenCoverages = 0;} objAccls.UserName = String.valueof(ag.get('num')); //objAccls.TotalEquipment = [Select count() from asset where accountid in :[Select id from account where owner.name =: u.name and isdeleted = false ]]; //objAccls.TotalLease = [Select count() from asset where accountid in :[Select id from account where owner.name =: u.name and isdeleted = false ] AND Price_Plan__c = 'lease']; } if(ag.get('type') == 'Open Coverage' && ag.get('num') == null){ FinalOpenCoverages = integer.valueof(ag.get('total'));} if(ag.get('type') == 'Non Customer' && ag.get('num') == null){ FinalNonCustomers = integer.valueof(ag.get('total'));} if(ag.get('type') == 'Customer' && ag.get('num') == null){ if(contCustomers > 0){ FinalCustomers = integer.valueof(ag.get('total')) + contCustomers;} else{FinalCustomers = integer.valueof(ag.get('total'));}} }Accounts2.add(objAccls); } } private void fetchAccountsByZip(){ listAR2 = [SELECT owner.name num, shippingpostalcode, type, count(id) total FROM account where ownerid =:RepsId AND isdeleted=false GROUP BY shippingpostalcode,owner.name,type order by shippingpostalcode]; for(AggregateResult u:[SELECT shippingpostalcode FROM account where ownerid =:RepsId AND isdeleted=false GROUP BY shippingpostalcode order by shippingpostalcode]){ AccByZip objOppClass2 = new AccByZip(); for (AggregateResult ar: listAR2) { if(String.valueof(ar.get('num')) != null && string.valueof(ar.get('type')) != null && String.valueof(ar.get('shippingpostalcode')) == (string)u.get('shippingpostalcode')){ if(ar.get('type') == 'Customer'){ objOppClass2.NumCustomers= (ar.get('total') != '' ? (integer.valueof(ar.get('total'))) : 0);} if(ar.get('type') == 'Non Customer' && ar.get('total') != null){ objOppClass2.NumNonCustomers = (ar.get('total') != '' ? (integer.valueof(ar.get('total'))) : 0);} if(ar.get('type') == 'Open Coverage' && ar.get('total') != null){ objOppClass2.NumOpenCoverages = (ar.get('total') != '' ? (integer.valueof(ar.get('total'))) : 0 );} objOppClass2.Zip = (String)ar.get('shippingpostalcode'); objOppClass2.ownerName = (String)ar.get('num'); objOppClass2.AccTypex = fetchAccTypes(); if(ObjOppClass2.NumCustomers != null && ObjOppClass2.NumNonCustomers != null && ObjOppClass2.NumOpenCoverages != null){ objOppClass2.NumAccounts = ObjOppClass2.NumCustomers+ObjOppClass2.NumNonCustomers+ObjOppClass2.NumOpenCoverages; }else{ if(ObjOppClass2.NumCustomers != null && ObjOppClass2.NumNonCustomers != null ) { objOppClass2.NumAccounts = ObjOppClass2.NumCustomers+ObjOppClass2.NumNonCustomers; } else{ if(ObjOppClass2.NumCustomers != null && ObjOppClass2.NumOpenCoverages != null ) { objOppClass2.NumAccounts = ObjOppClass2.NumCustomers+ObjOppClass2.NumOpenCoverages; } else{ if(ObjOppClass2.NumNonCustomers != null && ObjOppClass2.NumOpenCoverages != null ) { objOppClass2.NumAccounts = ObjOppClass2.NumNonCustomers+ObjOppClass2.NumOpenCoverages; } else{ if(ObjOppClass2.NumCustomers != null && ObjOppClass2.NumNonCustomers == null && ObjOppClass2.NumOpenCoverages == null ) { objOppClass2.NumAccounts = ObjOppClass2.NumCustomers; } else{ if(ObjOppClass2.NumNonCustomers != null && ObjOppClass2.NumCustomers == null && ObjOppClass2.NumOpenCoverages == null ) { objOppClass2.NumAccounts = ObjOppClass2.NumNonCustomers; } else{ if(ObjOppClass2.NumOpenCoverages != null && ObjOppClass2.NumNonCustomers == null && ObjOppClass2.NumCustomers == null ) { objOppClass2.NumAccounts = ObjOppClass2.NumOpenCoverages; } } } } } } } } }Accounts3.add(objOppClass2); } } public PageReference dofetchAccounts() { fetchAccounts(); return null; } public class Accls { public Integer TotalAccounts {get;set;} public Integer TotalCustomers {get;set;} public Integer TotalNonCustomers {get;set;} public Integer TotalOpenCoverages {get;set;} public Integer TotalEquipment { get; set;} public Integer TotalLease { get; set;} public String UserName {get;set;} } public class AccByZip { public Integer NumAccounts{ get;set; } public String Zip{ get;set; } public String ownerName{ get;set; } public Integer NumCustomers{ get;set; } public Integer NumNonCustomers{ get;set; } public Integer NumOpenCoverages{ get;set; } public List<SelectOption> Acctypex {get;set;} public String Acctypexx {get;set;} } }
- claper
- December 09, 2011
- Like
- 0