You need to sign in to do that
Don't have an account?

How to retrieve an array List of String inside a dataTable and also its index?
Hi, I have a input text box and a button 'Add' beside the text box. As soon as I enter anything in the textbox and click on Add it should get displayed as a list below the textbox. First time I enter a value only 1 value will appear below the text box, second time I enter 2 values will appear and so on.
Logic: I have used an Array List of String and as soon as I click on 'Add' button, the add the value in the textbox to the arraylist and in my page I iterate through the List to display the values in the table. I also have a checkbox next to the value in the table. I am not being able to get any of the values. Neither the checkbox nor any entered value is visible in the table. Also how do I get to know which checkbox gets selected once I have them in the table. Here is the piece of code Can anyone please help me resolve this issue?
Thanks, Jina
Logic: I have used an Array List of String and as soon as I click on 'Add' button, the add the value in the textbox to the arraylist and in my page I iterate through the List to display the values in the table. I also have a checkbox next to the value in the table. I am not being able to get any of the values. Neither the checkbox nor any entered value is visible in the table. Also how do I get to know which checkbox gets selected once I have them in the table. Here is the piece of code
Code:
<apex:page controller="Wizard_Step4c_Controller"> <apex:form > <apex:pageBlock title="Section 1"> <p> Is the EDC Rate adjustable— </p> <p> <apex:commandButton action="{!showSection2}" value="Yes" styleClass="btn"></apex:commandButton> <apex:commandButton action="{!nextPage}" value="No" styleClass="btn"></apex:commandButton></p> </apex:pageBlock> <apex:pageBlock title="Section 2" rendered="{!showSecondSection}"> <p>Enter criteria for EDC rate adjustment : </p> <p><apex:inputTextArea style="height:50px;width:200px;overflow-y:scroll" id="rateCriteria"></apex:inputTextArea> </p><br/> <p>Enter effective date(s) for EDC rate adjustment : <apex:inputText id="effectDates"></apex:inputText><span style="padding:10px;"/> <apex:commandButton action="{!addDates}" value="Add" styleClass="btn"></apex:commandButton></p> <apex:dataTable value="{!dates}" var="effDate" width="50%" rows="5" rendered="true"> <apex:column> <apex:inputCheckbox id="checkb"></apex:inputCheckbox> </apex:column> <apex:column> {!effDate} </apex:column> </apex:dataTable> <p><apex:commandButton action="{!nextPage}" value="Continue" styleClass="btn"></apex:commandButton></p> </apex:pageBlock> </apex:form> </apex:page> public class Wizard_Step4c_Controller { Boolean secondSection = false; CONTRACT_TERMS__c contract_terms= null; Boolean showSection = false; List<String> dates = new List<String>(); public Boolean getShowSecondSection() { return this.secondSection ; } public void setSecondSection(Boolean secondSection) { this.secondSection= secondSection; } public PageReference nextPage() { if(getShowSecondSection() == true) { update contract_terms; } PageReference pr= Page.Wizard_Step4d; pr.getParameters().put('contractTermsId', System.currentPageReference().getParameters().get('contractTermsId')); pr.getParameters().put('contractId', System.currentPageReference().getParameters().get('contractId')); pr.getParameters().put('questNum', System.currentPageReference().getParameters().get('questNum')); pr.setredirect(true); return pr; } public PageReference showSection2() { setSecondSection(true); return null; } public CONTRACT_TERMS__c getContractTerms() { Id contractTermsId= System.currentPageReference().getParameters().get('contractTermsId'); if(contractTermsId != null) { contract_terms = [select id,ADJ_RT_CRITERIA__c from CONTRACT_TERMS__c where id=:contractTermsId]; } return contract_terms; } public pageReference addDates() { String newDate = System.currentPageReference().getParameters().get('effectDates'); setShowTable(true); dates.add(newDate); return null; } public List<String> getDates() { return this.dates; } public void setShowTable(Boolean showSection) { this.showSection = showSection; } public Boolean getShowTable() { return this.showSection; } }
Thanks, Jina
i think you need value="{!effDates}" so:
then in your controller, provide a getter and setter for this getEffDates(), setEffDates()
for the checkbox, rather than return a list of string to iterate over, include the checkbox in a list, then iterate over that.
so:
List dates = new List();
would be
class dateandcheckbox { string date;boolean checkb;
//... getter and setter here...
}
list dates = new list();
you will have to construct and add to this list, but then you will have the checkbox value for each item in the list.
I have a Text Box, where I enter Date and as soon as I click on Add it gets added to the list and displays below. Now when I am trying to remove the date from the list I am unable to do it. I have used a wrapper class to set the value of the checkbox.
Here is the code - Term_Dates__c is my custom Object having a lookup relationship with Contract_Term__c and I have created a wrapper for Term_Dates__c custom object. As soon as I click on Add, I create a new Term_Dates__c and it gets added to the list but when I am tring to remove it, it is not happening. It is working in my develoiper org but not in sandbox.
I have only pasted a part of the code that is applicable -
Code:
You may need the rerender specified
Message Edited by Ron Hess on 05-29-2008 12:42 PM