You need to sign in to do that
Don't have an account?
Frank Carter
visualforce page: <input type="date"/>
Hello, I'm trying to create a vf page and I need some help.
VF page:
I think is not possible use an <input type="date"/> in the controller query.
How I have to do??
Thanks,
Francesco
VF page:
<apex:page controller="searchBDController" docType="html-5.0" id="pg"> <apex:form> <apex:pageBlock> <center><h1>Billing Details Search Page</h1></center> <br/> <br/> <br/> <center> Start Search: <input type="date"/> End Search: <input type="date"/> </center> <br/> <div align="center" draggable="false" > <apex:commandButton value="Reset" action="{!reset}" /> <apex:commandButton value="Search" action="{!loadData}" style="text-align:left;" /> </div> </apex:pageBlock> <apex:pageBlock id="pgblk"> <apex:pageBlockTable value="{!listBD}" var="b"> <apex:column value="{!b.Name}"/> <apex:column value="{!b.SF_Opportunity_Id__c}"/> <apex:column value="{!b.Billing_Type__c}"/> <apex:column value="{!b.Billing_Period__c}"/> <apex:column value="{!b.Monthly_Forecast__c}"/> <apex:column value="{!b.End_of_Billing__c}"/> <apex:column value="{!b.Amount__c}"/> <apex:column value="{!b.Billing_Status__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>Controller:
public class searchBDController { public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator( [Select Id,SF_Opportunity_Id__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c, Position__c from Billing_Detail__c ])); } return setCon; } set; } public List<Billing_Detail__c> listBD {get;set;} public String SelectedBdId {get;set;} public void loadData() { listBD = [Select Id,SF_Opportunity_Id__c,Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c, Position__c from Billing_Detail__c ]; } public PageReference reset(){ PageReference pg = new PageReference(System.currentPageReference().getURL()); pg.setRedirect(false); return pg; } }The target is when an user sets two dates and clicks search button the page must give him all the records with Monthly_Forecast__c included between start search and end search <input type="date"/>. These 2 fields are not in the custom object Billing_Detail__c and must not be related with Billing_Detail__c.
I think is not possible use an <input type="date"/> in the controller query.
How I have to do??
Thanks,
Francesco
The samples in the documentation of Salesforce are sometimes too short and the missing parts are important (otherwise that doesn't work).
All Answers
The samples in the documentation of Salesforce are sometimes too short and the missing parts are important (otherwise that doesn't work).
Building a Custom List Controller: should be fixed (?)
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_custom_list_controller.htm
I based my code on their sample.
<apex:page standardController="Account" recordSetVar="accounts" extensions="AccountPagination">
<apex:dataList value="{!accountPagination}" var="acct" type="1">
Their sample cannot work correctly. Many people can waste a lot of time with this kind of wrong/too short code given by Salesforce (?) and conclude that it is impossible.
Now with the range dates it's perfect.
vf:
Controller:
Now I have another problem, this is the vf page:
I have inserted a range of date.
If I go to edit a record it opens the record and I have three button:
- save;
- cancel;
- save and new.
I want that if I click save or cancel it redirect me on the previus page with the two filter date filled instead of the filetrs empties (to fill).
Is it possible?
Thanks
If you want a partial page refresh, you need to use the "rerender" attribute as far as possible with the Ajax underlying used technique by Salesforce.
I used "reRender" if you look at my posted code to keep the values of the filter dates (not emptied) and here is a detailed explaination:
https://developer.secure.force.com/cookbook/recipe/using-ajax-in-a-visualforce-page
Best regards
Alain
Thanks for answer me. I Understand but I don't think what I want is a partial refresh. If I open the record and then I click Save ord Cancel I want the previous page with the fields data range filled and the result of the query
.
Example If I go in the first result, last column edit:
I obtain the record page with the 3 butons (save, save and new, cancel).
If I clicks Save or Cancel I want the same page.
this page of the reult have to change only if I change the data range or If I close the page and Open from scratch.
Is it possible?
Thanks
The keyword static optimizes the size used for the view state by removing it from the view state but not always wanted.
public
staticDate StartDate {get;set;}public
staticDate EndDate {get;set;}I don't want a static default value I want the last data range.
So If I understand well I remove static from the initialzation of start date , end date then I use a constructor method like your to set the default value (last data range).
Is it correct? I'll try and then I'll let you know.
Thanks