I have a datatable that is showing results from a query. I wanted to, throught a rerender (or something similar), that the datatable refreshs with the parameters that I'm passing to controller. I have come to this:
VF PAGE
<apex:page>
<apex:pageBlock>
//another forms here, cuted to reduce the code size
</apex:pageBlock>
<apex:pageBlock id="pb">
<apex:form >
<apex:outputLabel value="FROM: " style="font-weight: bold"/>
<apex:inputField value="{!record.Data_Hora_Levantamento_Viatura__c}" required="true"/>
<p/>
<apex:outputLabel value="TO: " style="font-weight: bold"/>
<apex:inputField value="{!record.Data_Hora_Entrega_Viatura__c}" required="true"/>
<p/>
<apex:commandButton value="Filter">
<apex:actionSupport event="onclick" rerender="PageBlock"/>
</apex:commandbutton>
</apex:form>
<p></p>
<apex:outputPanel layout="block" style="max-height:250px; overflow:scroll" id="outP">
<apex:dataTable id="dataTable" var="e" value="{!Veiculos}" border="1" frame="hsides"
cellspacing="0" cellpadding="5" width="100%">
<apex:column >
<apex:facet name="header">Titular</apex:facet>
<apex:outputText value="{!e.Owner.Name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Matricula</apex:facet>
<apex:outputText value="{!e.Matriculas_Viaturas__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Data/Hora Levantamento</apex:facet>
<apex:outputText value="{0,date,dd-MM-yyyy hh:MM}">
<apex:param value="{!e.Data_Hora_Levantamento_Viatura__c}"/>
</apex:outputText>
</apex:column>
<apex:column >
<apex:facet name="header">Duracao Prevista</apex:facet>
<apex:outputText value="{!e.Dura_o_Prevista_horas__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Data/Hora Entrega Prevista </apex:facet>
<apex:outputText value="{0,date,dd-MM-yyyy hh:MM}">
<apex:param value="{!e.Data_Entrega_prevista__c}"/>
</apex:outputText>
</apex:column>
<apex:column >
<apex:facet name="header">Estado</apex:facet>
<apex:outputText value="{!e.Estado__c}"/>
</apex:column>
</apex:dataTable>
</apex:outputPanel>
</apex:pageBlock> </apex:page>
CONTROLLER
public with sharing class OrbC_VeiculosExtension
{
public Veiculos__c record {get;set;}
public Id currentId {get;set;}
public List<Veiculos__c> Veiculos {
get {
if (Schema.sObjectType.Veiculos__c.isAccessible())
{
system.debug(record.Data_Hora_Levantamento_Viatura__c);
system.debug(record.Data_Hora_Entrega_Viatura__c);
if (record.Data_Hora_Levantamento_Viatura__c==null && record.Data_Hora_Entrega_Viatura__c==null)
{
Veiculos = [SELECT Matriculas_Viaturas__c,Data_Hora_Levantamento_Viatura__c,Estado__c,Dura_o_Prevista_horas__c,Data_Entrega_prevista__c,Data_Hora_Entrega_Viatura__c, Owner.Name FROM Veiculos__c WHERE Data_Hora_Levantamento_Viatura__c >= TODAY ORDER BY Data_Hora_Levantamento_Viatura__c];
}
else if (record.Data_Hora_Levantamento_Viatura__c!=null && record.Data_Hora_Entrega_Viatura__c==null)
{
Veiculos = [SELECT Matriculas_Viaturas__c,Data_Hora_Levantamento_Viatura__c,Estado__c,Dura_o_Prevista_horas__c,Data_Entrega_prevista__c,Data_Hora_Entrega_Viatura__c, Owner.Name FROM Veiculos__c WHERE Data_Hora_Levantamento_Viatura__c >= :record.Data_Hora_Levantamento_Viatura__c ORDER BY Data_Hora_Levantamento_Viatura__c];
}
else if (record.Data_Hora_Levantamento_Viatura__c==null && record.Data_Hora_Entrega_Viatura__c!=null)
{
Veiculos = [SELECT Matriculas_Viaturas__c,Data_Hora_Levantamento_Viatura__c,Estado__c,Dura_o_Prevista_horas__c,Data_Entrega_prevista__c,Data_Hora_Entrega_Viatura__c, Owner.Name FROM Veiculos__c WHERE Data_Entrega_prevista__c <= :record.Data_Entrega_prevista__c ORDER BY Data_Hora_Levantamento_Viatura__c];
}
else if (record.Data_Hora_Levantamento_Viatura__c!=null && record.Data_Hora_Entrega_Viatura__c!=null)
{
Veiculos = [SELECT Matriculas_Viaturas__c,Data_Hora_Levantamento_Viatura__c,Estado__c,Dura_o_Prevista_horas__c,Data_Entrega_prevista__c,Data_Hora_Entrega_Viatura__c, Owner.Name FROM Veiculos__c WHERE Data_Hora_Levantamento_Viatura__c >= :record.Data_Hora_Levantamento_Viatura__c AND Data_Entrega_prevista__c <= :record.Data_Entrega_prevista__c ORDER BY Data_Hora_Levantamento_Viatura__c];
}
}
return Veiculos;
}
set;}
public datetime inicio {get;set;}
public datetime fim {get;set;}
public Boolean isRendered {get; set;}
public OrbC_VeiculosExtension(ApexPages.StandardController controller) {
this.record = (Veiculos__c)controller.getRecord();
this.currentId = record.Id;
isRendered = false;
system.debug(currentId);
system.debug(record);
}
When I click the "Filter" button, the pages refreshes, and the inputfields (that I cut from the code to reduce it) get the values from the "FROM" and "TO" fields, but the table refreshs like they are null. I'm out of ideas! How can I get this to work?