Reputation: 516
I am having problems tring to use a alloy ui datepiker in liferay.
my code:
<%
Campagna campagna = (Campagna) request.getAttribute(WebKeys.CAMPAGNA);
long campagnaId = 0;
if (campagna != null) {
campagnaId = campagna.getCampagnaId();
}
//campagna.getDate()
%>
<input type="text" name="dataFine" id="<portlet:namespace />dataFine" size="30" />
<aui:script>
AUI().use('aui-datepicker', function(A) {
var dataInizioDatepicker = new A.DatePicker({
trigger: '#<portlet:namespace />dataInizio',
calendar: {
dateFormat: '%d/%m/%y'
}
}).render('##<portlet:namespace />dataInizioPicker');
});
</aui:script>
What I am tring to do is set the campagna.getDate() value to the datepiker, but I can't find a way.
The second problem is the date format.
I want the the date format of the datepiket is based on the current language of liferay.
There is a way to do this?
Thanks Marco
Upvotes: 1
Views: 4845
Reputation: 887
You can use 'dates' attribute for setting date
AUI().use('aui-datepicker', function(A) {
var dataInizioDatepicker = new A.DatePicker({
trigger: '#<portlet:namespace />dataInizio',
calendar: {
dates: [ '${campagna.date}' ],
dateFormat: '%m/%d/%Y'
}
}).render('##<portlet:namespace />dataInizioPicker');
Upvotes: 1