掲示板

How to add calendar for a form input field?

15年前 に Vivek N Kapse によって更新されました。

How to add calendar for a form input field?

Junior Member 投稿: 42 参加年月日: 08/09/09 最新の投稿
Hi,

How do I add calendar for a form input field in struts portlet. I am using Crystalx-theme, is there a tld file and javascript file for calendar that can be just used to add Calendar option for a form input field?
Also where do i edit if i want the format of the date to be in yyyy-mm-dd? Also instead of drop down for the months and the year range I need just a plain text field with calendar option which would take dates in yyyy-mm-dd format.
thumbnail
14年前 に Juan Fernández によって更新されました。

RE: How to add calendar for a form input field?

Liferay Legend 投稿: 1261 参加年月日: 08/10/02 最新の投稿
Hi!:
You can add it using this:
<liferay-ui:input-field model="<%= CalEvent.class %>" field="startDate" />

You can do some research in its related files: InputFieldTag.java, liferay-ui.tld and page.jsp
Greetings
Juan Fernández
thumbnail
13年前 に Jakub Liska によって更新されました。

RE: How to add calendar for a form input field?

Regular Member 投稿: 187 参加年月日: 10/03/25 最新の投稿
Hi guys,

I can't populate the form backing bean with the Date value from these Date input fields. The field of bean that corresponds to the form field is of type Date, so that for example:

<aui:input label="Time Frame" name="timeFrame" />


taglib finds out the field has type "Date" so that it renders the Date widget with calendar, but the form backing bean never gets populated after submit. As well as here :

<liferay-ui:input-field model="<%= CalEvent.class %>" field="timeFrame" />


How can I populate a form backing object (declared in aui:model-context) with Date value from these calendars ?


Also I can't figure out what is the proper use of this one:

<liferay-ui:input-date yearrangeend="" yearrangestart="" formname=""></liferay-ui:input-date>


It's just a widget that puts its values into request like this:
{ liferay-ui:input-date:dayValue, value }


to render into particular time setting, but I can't see anything else I can do with it :-)
thumbnail
13年前 に Jakub Liska によって更新されました。

RE: How to add calendar for a form input field?

Regular Member 投稿: 187 参加年月日: 10/03/25 最新の投稿
I suppose that the only way how to get DATE type of data out of forms is this one:


		
int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth");
int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");



<aui:input name="birthdayMonth" type="hidden" value="<%= Calendar.JANUARY %>" />
<aui:input name="birthdayDay" type="hidden" value="1" />
<aui:input name="birthdayYear" type="hidden" value="1970" />


Cause all the other tags looks like they could do it, but as I was looking into the source code ... this seems as the only way...
thumbnail
13年前 に Jakub Liska によって更新されました。

RE: How to add calendar for a form input field?

Regular Member 投稿: 187 参加年月日: 10/03/25 最新の投稿
Sorry for my confusion, I was using aui:input tag without trying liferay-ui:input-date/time first...now it's everything clear to me
thumbnail
1年前 に Tanweer Ahmed . によって更新されました。

RE: How to add calendar for a form input field?

Expert 投稿: 322 参加年月日: 10/03/11 最新の投稿
Jakub Liska:
Sorry for my confusion, I was using aui:input tag without trying liferay-ui:input-date/time first...now it's everything clear to me


Hi Jakub,

Could u plz share ur learnings.
thumbnail
13年前 に Jakub Liska によって更新されました。

RE: How to add calendar for a form input field?

Regular Member 投稿: 187 参加年月日: 10/03/25 最新の投稿
Hi Tanweer,

well if you use aui:input, then the tag library recognizes (based on model-hints) what data type the field is of - Date. So that it uses liferay-ui:input-date/time under the hood. With these two tags it is obvious, you declare params of year, month, day etc., and you know what parameters in request holds the particular values of year, month, day etc. as integer values. But as I was using aui:input tag for this I thought that it populates field (Date) of bean/command object with Date value...

Take a look at this thread

Instead of getting the individual integer values, which is stupid (as the only possibility), it would be much better if it returned MDY string and programmer could use variety of classes for converting it into Date type. With Spring MVC, you wouldn't have to write anything except of one line registering editor that does this conversion.
thumbnail
1年前 に Tanweer Ahmed . によって更新されました。

RE: How to add calendar for a form input field?

Expert 投稿: 322 参加年月日: 10/03/11 最新の投稿
Thnx Jakub, for your knowledge sharing.A gr8 learning....emoticon
12年前 に Alberto Gonzalez によって更新されました。

RE: How to add calendar for a form input field?

New Member 投稿: 6 参加年月日: 11/11/03 最新の投稿
Jakub Liska:
Hi Tanweer,

well if you use aui:input, then the tag library recognizes (based on model-hints) what data type the field is of - Date. So that it uses liferay-ui:input-date/time under the hood. With these two tags it is obvious, you declare params of year, month, day etc., and you know what parameters in request holds the particular values of year, month, day etc. as integer values. But as I was using aui:input tag for this I thought that it populates field (Date) of bean/command object with Date value...

Take a look at this thread

Instead of getting the individual integer values, which is stupid (as the only possibility), it would be much better if it returned MDY string and programmer could use variety of classes for converting it into Date type. With Spring MVC, you wouldn't have to write anything except of one line registering editor that does this conversion.


How can i do this? I work with liferay 6 and spring MVC, but i can´t associate a form file with the liferay-ui:input-date