You need to sign in to do that
Don't have an account?
Ravi Prabhu
Check box value not passing to controller from visualforce page
Hi,
This looks to be simple but not able to find the issue.
I have a visualforce page with a pageblock. The page block displays 2 fields. One is date and other field is name from drop down. User should select these 2 fields and then click 'Go' button which will display the records. Later user can select the records and delete it (need to select multiple records using checkbox). The 'Go' button is working and display records but delete button is not working after selecting the records.
Please help.
This looks to be simple but not able to find the issue.
I have a visualforce page with a pageblock. The page block displays 2 fields. One is date and other field is name from drop down. User should select these 2 fields and then click 'Go' button which will display the records. Later user can select the records and delete it (need to select multiple records using checkbox). The 'Go' button is working and display records but delete button is not working after selecting the records.
Please help.
Visualforce page: <apex:form id="formId" styleClass="myFormStyle" > <apex:actionRegion > <apex:pageBlock id="pgblock2" title="Summary" > <apex:pageBlockSection id="pgblocksection2"> <apex:OutputPanel > <apex:panelGrid columns="7"> <apex:outputLabel style="font-style:regular; font-weight:bold; font-size:11px; font-family:Helvetica;" >Date </apex:outputLabel> <apex:inputText id="Date" value="{!SelectedDate}" onfocus="DynamicDatePicker(this);" onchange="checkDateFormatt(this.id);" size="10" disabled="false" style="width:90px; margin-right:10px;" /> <apex:param value="{!SelectedDate}" assignTo="{!selectedDate}" name="p1"/> <apex:outputLabel style="font-style:regular; font-weight:bold; font-size:11px; font-family:Helvetica;" > Select Assigned Person </apex:outputLabel> <apex:selectList id="selectedlist" value="{!selectedUserId}" size="1" multiselect="false" > <apex:param value="{!selectedUserId}" assignTo="{!selectedUserId}" name="p2"/> <apex:selectOptions value="{!ListOfUser}" /> </apex:selectList> <apex:commandButton id="Go" action="{!getsummarylist}" value="Go" onclick="validatechk();" rerender="msgsS" /> </apex:panelGrid> </apex:OutputPanel> </apex:pageBlockSection> <apex:pageBlockButtons location="Bottom" > <apex:commandButton id="deleteit" value="Delete" action="{!delete_now}" reRender="msgsS"/> </apex:pageBlockButtons> <apex:outputPanel id="panelId"> <apex:pageBlockTable value="{!sub}" var="I" id="msgsS" > <apex:column headerValue="Select" > <apex:inputCheckbox value="{!I.checked}" /> <apex:param assignTo="{!I.checked}" value="{!I.checked}" /> </apex:column> <apex:column headervalue="Date" value="{!I.tkt.Date__c}"/> <apex:column headervalue="Ticket Number" value="{!I.tkt.Ticket_Number__c}"/> <apex:column headervalue="Division" value="{!I.tkt.Division__c}"/> <apex:column headervalue="Application" value="{!I.tkt.Application__c}"/> <apex:column headervalue="Responsible" value="{!I.tkt.Responsible__c}"/> <apex:column headervalue="Effort" value="{!I.tkt.Effort__c}"/> </apex:pageBlockTable> </apex:outputPanel> </apex:pageBlock> </apex:actionRegion> </apex:form> </apex:page> Apex controller public with sharing class TestPageBlock2Cont { public String selecteduserId {get;set;} public Date selectedDate {get;set;} List<SelectOption> selectOptions{get;set;} public List<Wrapperclass> sub {get;set;} public TestPageBlock2Cont() { tktRecord = new Ticket_Effort_Category__c(); lstwrapper = new list<wrapper>(); header = 'Date,Division\r\n'; } //after pressing 'Go' button, this method will be called public Pagereference getsummarylist(){ if(selectedDate == null){ system.debug('selectedDate 3 = ' +selectedDate); ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'Please enter date')); } else{ sub = new List<WrapperClass>(); list<ticket_effort_category__c> fetchList = new list<ticket_effort_category__c>(); fetchList = [select id, Date__c, ticket_number__c, Division__c, Application__c, Responsible__c, Effort__c from Ticket_Effort_Category__c where Responsible__c = :selectedUserId and Date__c = :selectedDate]; for(Ticket_Effort_Category__c cr : fetchlist){ sub.add(new wrapperClass (cr,false)); } } return null; } //wrapp the records and checkbox public class WrapperClass { public Ticket_effort_category__c tkt {get; set;} public Boolean checked {get; set;} public wrapperClass(Ticket_effort_category__c tkt, Boolean checked){ this.tkt=tkt; this.checked = checked; } } //delete the selected records public void delete_now(){ List<Ticket_Effort_Category__c> del = new list<Ticket_Effort_Category__c>(); for(WrapperClass cc: sub){ system.debug('tktid = ' +tktid); if(cc.checked == true){ del.add(cc.tkt); } } delete del; return null; } //show up the dropdown for user to select the name public List<SelectOption> getListOfUser(){ selectOptions = new List<SelectOption>(); selectOptions.add(new SelectOption( ' ' ,'---Select---')); Schema.DescribeFieldResult describeResult = Ticket_Effort_Category__c.Responsible__c.getDescribe(); List<Schema.PicklistEntry> pickListEntries = describeResult.getPicklistValues(); for( Schema.PicklistEntry eachEntry : pickListEntries) { selectOptions.add(new SelectOption(eachEntry.getLabel(), eachEntry.getValue())); } return selectOptions; } }
Have you tried checking if the accounts are being selected properly and if the delete button is actually working?
Please check and let us know, looking forward to your response.
Regards,
Anutej
This will work for sure.
Did you try with above solution? Does it solve your purpose?