On index.gsp I have this to redirect it to list.gsp so I'm imagining is should be something like this:
${response.sendRedirect("entry/list")}
My filter is just one textField and two datePickers with drop down boxes (DD-MMM-YYYY)
and they should be by default filtered from today's date to infinity. So it should show me only the events that have not happened yet, but the old ones should still be in the database.
Here are the links to my last 3 questions for background information
http://stackoverflow.com/questions/3105021/grails-filter-data-in-a-grails-table-dynamically
http://stackoverflow.com/questions/3119559/grails-edit-and-delete-links-not-working
I think the second one is the one with most of my code.
Any help would be greatly appreciated and well rated. Thanks! :) And a again special thanks to proflux for all the help!
UPDATE
Here is the in the list.gsp
<g:each in="${entryInstanceList}" status="i" var="entryInstance">
<tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
<td><g:formatDate format="dd-MMMM-yyyy" date="${entryInstance.fechaCambio}" /></td>
<td><b>${fieldValue(bean: entryInstance, field: 'proyectoRuta')}</b></td>
<td>${fieldValue(bean: entryInstance, field: 'summary')}</td>
<td><g:formatDate format="dd-MMM-yyyy HH:mm z" date="${entryInstance.lastUpdated}" /></td>
<td>
<g:form>
<g:hiddenField name="id" value="${entryInstance?.id}" />
<span class="simple"><g:actionSubmit class="editar" action="edit" value="${message(code: 'default.button.editar.label', default: ' ')}" /></span>
<span class="simple"><g:actionSubmit class="eliminar" action="delete" value="${message(code: 'default.button.eliminar.label', default: ' ')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Esta seguro que desea Eliminar?')}');" /></span>
</g:form>
</td>
</tr>
</g:each>
UPDATE
Here is the searchResults code,
def searchResults = {
def entryCriteria = Entry.createCriteria()
def results = entryCriteria.list {
and{if(params?.fechaCambioD && params?.fechaCambioH) {
between("fechaCambio", params.fechaCambioD, params.fechaCambioH)
}
if(params?.lastUpdatedD && params?.lastUpdatedH) {
between("lastUpdated", params.lastUpdatedD, params.lastUpdatedH)
}
if(params?.proyectoRutaN) {
ilike("proyectoRuta","%${params.proyectoRutaN}%")
}
}
}
render(view:'searchResults', model:['results':results, 'proyectoRutaN':params?.proyectoRutaN, 'fechaCambioD':params?.fechaCambioD, 'fechaCambioH':params?.fechaCambioH, 'lastUpdatedD':'', 'lastUpdatedH':params?.lastUpdatedH])
}
And since I am already using results and is a list, what should I do, give it another name and at the end put it to model after results?? like:
render(view:'searchResults', model:['results':results, 'otherResults':otherResults, 'proyectoRutaN':params?.proyectoRutaN, 'fechaCambioD':params?.fechaCambioD, 'fechaCambioH':params?.fechaCambioH, 'lastUpdatedD':'', 'lastUpdatedH':params?.lastUpdatedH])
Or should I just define it inside results??
UPDATE
<table><tbody class="yui-skin-sam">
<tr class="prop">
<td valign="top" class="name"><b>Proyecto/Ruta: </b> <g:textField name="proyectoRutaN" value="${proyectoRutaN}" /></td>
<td></td>
<td valign="top" class="name"><b>Fecha de Implementación: </b></td>
<td></td>
<td valign="top" class="name"><b>Fecha de Última Modificación: </b></td>
</tr>
<tr class="prop">
<td></td>
<td valign="top">Desde:</td>
<td valign="top"><gui:datePicker name="fechaCambioD" value="${params?.fechaCambioD}" formatString="dd/MMM/yyyy"/></td>
<td valign="top">Desde:</td>
<td valign="top"><gui:datePicker name="lastUpdatedD" value="${params?.lastUpdatedD}" default="none"/></td>
</tr>
<tr class="prop">
<td></td>
<td valign="top">Hasta:</td>
<td valign="top"><gui:datePicker name="fechaCambioH" value="${params?.fechaCambioH}" formatString="dd/MMM/yyyy"/></td>
<td valign="top">Hasta:</td>
<td valign="top"><gui:datePicker name="lastUpdatedH" value="${params?.lastUpdatedH}" default="none"/></td>
</tr>
For some reason when I apply the filters then it shows me everything on the list (it does not filter) and the textFields in the filter do not save the date from when the filter was applied.
Any ideas on how I can fix this?