Forums

Home » Alloy UI » English

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Adam Victor Nazareth Brandizzi
Configuring <aui:input> for date
November 22, 2011 11:02 AM
Answer

Adam Victor Nazareth Brandizzi

Rank: Junior Member

Posts: 67

Join Date: April 30, 2010

Recent Posts

Hello, all!

Suppose I have a model class generated by service builder from this entity:

1    <entity name="Person" local-service="true" remote-service="false">
2        <column name="personId" type="long" primary="true" />
3        <column name="birthday" type="Date" />
4    </entity>


Now, suppose I have such a JSP:

1<%
2    Person person = PersonLocalServiceUtil.getPerson(personId);
3%>
4
5<aui:model-context bean="<%= person %>" model="<%= Person.class %>" />
6<%-- ... --%>
7<aui:input value="birthday" />


The JSP below will generate a datepicker to the <aui:input>, right? This datepicker will also have fields for submitting hour, minutes etc.

My questions are:

  1. How could I remove the fields for time input from the datepicker, leaving only the fields for date input?
  2. How could I make <aui:input> to have the same behavior without using an entity generated by service builder? For example, how can I make <aui:input> to present the datepicker to pick just some standalone date object?


Thanks in advance!

PS: I am not sure this is a question for this forum. If this should be put in the development forum for Liferay itself, let me know.
Tarkan Corak
RE: Configuring <aui:input> for date
December 14, 2011 1:18 AM
Answer

Tarkan Corak

Rank: Regular Member

Posts: 142

Join Date: October 7, 2008

Recent Posts

Hi Adam,

First you have to modify your portlet-model-hints.xml, so that it looks similar to this:

1
2<field name="birthday" type="Date">
3    <hint name="year-range-delta">120</hint>
4    <hint name="year-range-future">false</hint>
5    <hint name="show-time">false</hint>
6</field>


This will remove the time from your view.

Then create a Calendar object:

1
2<%
3    Calendar bd= CalendarFactoryUtil.getCalendar();
4    if(person.getBirthday() != null)
5        bd.setTime(person.getBirthday());
6%>


and at least the form field:

1
2<aui:input name="birthday" value="<%= bd%>" />


Tarkan
Vishnudas Lokhande
RE: Configuring <aui:input> for date
January 31, 2014 2:12 AM
Answer

Vishnudas Lokhande

Rank: Regular Member

Posts: 147

Join Date: May 27, 2013

Recent Posts

i have changed portlet-model-hints.xml...

<field name="birthday" type="Date">
<hint name="year-range-delta">120</hint>
<hint name="year-range-future">false</hint>
<hint name="show-time">false</hint>
</field>


and build service......

but not removing the time from view...
Sushil Patidar
RE: Configuring <aui:input> for date
January 31, 2014 2:32 AM
Answer

Sushil Patidar

Rank: Expert

Posts: 323

Join Date: October 30, 2011

Recent Posts

Vishnudas D. Lokhande:
i have changed portlet-model-hints.xml...

<field name="birthday" type="Date">
<hint name="year-range-delta">120</hint>
<hint name="year-range-future">false</hint>
<hint name="show-time">false</hint>
</field>


and build service......

but not removing the time from view...


Hi VishnuDas,
It should work as per you have mentioned ,but if you are facing problem than you can use following liferay tag directly.
 1
 2                    <liferay-ui:input-date
 3                cssClass="<%= cssClass %>"
 4                dayNullable="<%= dayNullable %>"
 5                dayParam='<%= fieldParam + "Day" %>'
 6                dayValue="<%= day %>"
 7                disabled="<%= disabled %>"
 8                firstDayOfWeek="<%= firstDayOfWeek %>"
 9                formName="<%= formName %>"
10                imageInputId='<%= fieldParam + "ImageInputId" %>'
11                monthNullable="<%= monthNullable %>"
12                monthParam='<%= fieldParam + "Month" %>'
13                monthValue="<%= month %>"
14                yearNullable="<%= yearNullable %>"
15                yearParam='<%= fieldParam + "Year" %>'
16                yearRangeEnd="<%= yearRangeEnd %>"
17                yearRangeStart="<%= yearRangeStart %>"
18                yearValue="<%= year %>"
19            />
Vishnudas Lokhande
RE: Configuring <aui:input> for date
January 31, 2014 3:22 AM
Answer

Vishnudas Lokhande

Rank: Regular Member

Posts: 147

Join Date: May 27, 2013

Recent Posts

thanks..it's working....
Robin Nagpal
RE: Configuring <aui:input> for date
December 9, 2014 6:08 AM
Answer

Robin Nagpal

Rank: Junior Member

Posts: 43

Join Date: November 18, 2014

Recent Posts

Sushil Patidar:
Vishnudas D. Lokhande:

<liferay-ui:input-date
cssClass="<%= cssClass %>"
dayNullable="<%= dayNullable %>"
dayParam='<%= fieldParam + "Day" %>'
dayValue="<%= day %>"
disabled="<%= disabled %>"
firstDayOfWeek="<%= firstDayOfWeek %>"
formName="<%= formName %>"
imageInputId='<%= fieldParam + "ImageInputId" %>'
monthNullable="<%= monthNullable %>"
monthParam='<%= fieldParam + "Month" %>'
monthValue="<%= month %>"
yearNullable="<%= yearNullable %>"
yearParam='<%= fieldParam + "Year" %>'
yearRangeEnd="<%= yearRangeEnd %>"
yearRangeStart="<%= yearRangeStart %>"
yearValue="<%= year %>"
/>



I dont see all of these attributes in 6.2.x liferay:ui tld https://github.com/liferay/liferay-portal/blob/6.2.x/util-taglib/src/META-INF/liferay-ui.tld

Can you please let me know how can we render the date selector. I dont want to use AUI as it doesn't allow year to be selected in a drop down. Since I am using the input for Date of Birth, I need to provide a convenient way to select month and year