You need to sign in to do that
Don't have an account?
SFmaverick
Call to controller to increment a variable
Basically throughout my visualforce page, I'd like to take a variable that's been set, and I'd like to increment it by 1 several different times. I'm sure there's an easy way to make a call like this that I'm just not considering. Here's the current code:
Page Code - It's simply taking in a text value called BegDate and outputting a Date value called DayDate
<apex:page showHeader="false" standardStyleSheets="false" controller="TestViewController"> <apex:form > <apex:inputText value="{!BegDate}"/> <apex:outputText value="{!DayDate}"/> <!-- This is where I'd like to output DayDate a second time, but incremented by 1> <apex:outputText value="{!DayDate}"/> </apex:form> </apex:page>
Controller Code: It's taking the user input and converting it from text to a date format. I'd like to somehow make call to the controller from the visualforce page to increment DayDate by 1.
public class TestViewController { public String BegDate { get; set; } // Turns the User's string input into a date public Date getDayDate(){ if (BegDate==null) { return null; } else { return stringToDate(BegDate); } } //Converts a string from mm/dd/yyyy to a date public Date stringToDate(String s){ //Input Date String is in the format mm/dd/yyyy if(s.length()== 0) { return NULL; } else{ String[] stringDate = s.split('/'); Integer m = Integer.valueOf(stringDate[0]); Integer d = Integer.valueOf(stringDate[1]); Integer y = Integer.valueOf(stringDate[2]); return date.newInstance(y,m,d); } } }
You can make use of actionpoller tag to call an function from controller recursively
I don't want to increment based on time: I want to tell it when to increment. I need it to increment at 6 different points, all before the page is rendered and displayed.
Hi,
If it is exactly six different places where you need to place this date increemented, you can create an inner class having six variables each of which is increemented by one day. Then refere to the variables of instance of this inner class.
Assuming I did create a class that had this Date incremented six different times; that would also require that I had 6 seperate constructors for my list each called with a different variable to filter by date. I don't think that's an easy solution, it's going to make the code much longer and harder to maintain.
Hi,
I think you misunderstood me/ you are not posting all of whatever you want. Let me repost your code with modifications
The problem behind your question first posted is that, if you dont have a iterator vf tags, then you need to buid some inner classes like this for displaying array of values. You cannot refer to the list item to be displayed merely by referring to each item. (eg: <apex:outputText value="listDates[0]"/>)
In case your requirement is more complex than simply showing increemented dates at 6 different places, then probably the approach has to be changed.