Foros de discusión

Default Value of an input Date

Alice ETCHEGARAY, modificado hace 9 años.

Default Value of an input Date

Junior Member Mensajes: 49 Fecha de incorporación: 23/01/14 Mensajes recientes
Hy everyone,

I'm a newbie on Liferay and I developed a portlet with the service builder.
But I have a problem : when I create a new collaborator (my entities are "collaborator", "manager", ...), the default value of the aui:input in my date is the today's date.

There is my code into my "CollaborateurPortlet" :

private Collaborateur collaborateurFromRequest(PortletRequest request) {
		ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);

		DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
		Collaborateur collaborateur = new CollaborateurImpl();

		collaborateur.setCollaborateurId(ParamUtil.getLong(request, "collaborateurId"));
		collaborateur.setNom(ParamUtil.getString(request, "nom"));
		collaborateur.setPrenom(ParamUtil.getString(request, "prenom"));
		collaborateur.setMail(ParamUtil.getString(request, "mail"));
		collaborateur.setTel(ParamUtil.getString(request, "tel"));
		collaborateur.setDateentree(ParamUtil.getDate(request,"dateentree",df));
		collaborateur.setDatesortie(ParamUtil.getDate(request,"datesortie",df));
		collaborateur.setManagerId(ParamUtil.getLong(request, "managerId"));
		collaborateur.setStatutId(ParamUtil.getLong(request, "statutId"));
		collaborateur.setSocieteId(ParamUtil.getLong(request, "societeId"));
		collaborateur.setApplicationId(ParamUtil.getLong(request, "applicationId"));
		collaborateur.setCompanyId(themeDisplay.getCompanyId());
		collaborateur.setGroupId(themeDisplay.getScopeGroupId());
		collaborateur.setUserId(themeDisplay.getUserId());

		return collaborateur;


Then into my edit.jsp :
<aui:input name="datesortie" inlineField="true" label="Date de sortie :" />


My actual result and my waiting result are into my attached documents.

Please help me, I hope I was clear in my explanations....
thumbnail
André Bunse, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 65 Fecha de incorporación: 13/02/14 Mensajes recientes
You can set default date as fourth parameter in

ParamUtil.getDate(request,"datesortie",df)


i mean default is 0 which means now (new Date()), try to set -1

ParamUtil.getDate(request,"datesortie",df, -1)


sorry, can not look in my code to find a example right now, tell me if it helps
Alice ETCHEGARAY, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 49 Fecha de incorporación: 23/01/14 Mensajes recientes
I have got an error : "The method getDate(PortletRequest, String, DateFormat, Date) in the type ParamUtil is not applicable for the arguments (PortletRequest, String, DateFormat, int)".
thumbnail
André Bunse, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 65 Fecha de incorporación: 13/02/14 Mensajes recientes
and with "null"?
Alice ETCHEGARAY, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 49 Fecha de incorporación: 23/01/14 Mensajes recientes
I tried, and it's the same...
Can we modify the code for ParamUtil.getDate ?
thumbnail
Philipp Schwarz, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 29 Fecha de incorporación: 19/10/12 Mensajes recientes
Hi Alice,

try this:

<aui:input name="datesortie" inlineField="true" label="Date de sortie :" placeholder="dd/mm/yyyy" />


Beware:
Browser support for the placeholder attribute varies and there have been issues with the liferay browser normalization scripts.

Kind regards,
Phil
Alice ETCHEGARAY, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 49 Fecha de incorporación: 23/01/14 Mensajes recientes
I have no error but this doesn't work neither...
thumbnail
André Bunse, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 65 Fecha de incorporación: 13/02/14 Mensajes recientes
Philipp Schwarz:
Beware:
Browser support for the placeholder attribute varies and there have been issues with the liferay browser normalization scripts.

A placeholder is a watermark on an input control and has nothing to do with the value inside.
thumbnail
André Bunse, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 65 Fecha de incorporación: 13/02/14 Mensajes recientes
Alice ETCHEGARAY:
I tried, and it's the same...
Can we modify the code for ParamUtil.getDate ?

That make no sense.

Have a look at the created record in database, maybe there is a default for the field defined which override the "null".
I don't think "null" will be converted to current date, only "0".
Alice ETCHEGARAY, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 49 Fecha de incorporación: 23/01/14 Mensajes recientes
I watched in my database but there is nothing which initialize the today's date...
I also tried to fix this issue using hints and "default-value", but nothing happened. I think there is something overriding the input, but I don't know what...
thumbnail
André Bunse, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 65 Fecha de incorporación: 13/02/14 Mensajes recientes
Have you look at the record and the field value in the database?

What happens if you don't set the date on insert? ( comment or remove the customer.setDate(ParamUtil.getDate .... )

What shows the value of the node (aui date input element) in the document?

Sounds really weird, but

i set null if i have no date and it works fine. ( customer.setDate(null); )
Alice ETCHEGARAY, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 49 Fecha de incorporación: 23/01/14 Mensajes recientes
When I modify and put another date into this field, the insert works correctly.
But when I do the insert without modifying the value of the field, the default value (today's date) is inserting into the database...

Even setting null (collaborateur.setDatesortie(null);), the today's date is displaying...

I don't know why this happen, maybe with this (DateFormat df = new SimpleDateFormat("dd/MM/yyyy");)...
thumbnail
Philipp Schwarz, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 29 Fecha de incorporación: 19/10/12 Mensajes recientes
Have you checked the default value for the 'datesortie' column in the database? Maybe the value gets inserted by your database?
Alice ETCHEGARAY, modificado hace 9 años.

RE: Default Value of an input Date

Junior Member Mensajes: 49 Fecha de incorporación: 23/01/14 Mensajes recientes
I checked in my database, there isn't a default value for the field. I think it's an aui property but I don't know how to resolve that.
So, what I do for the moment, it's to replace the aui input date by an aui input text. And here, there isn't a default value...