Foros de discusión

Datepicker with AUI / LiferayUI form (solved)

thumbnail
Laura Liparulo, modificado hace 11 años.

Datepicker with AUI / LiferayUI form (solved)

Junior Member Mensajes: 38 Fecha de incorporación: 30/06/12 Mensajes recientes
Hi! I've found a way to make the datepicker with liferay ui...It works fine... anyway I would like to make it all with AUI. Let me know if you know...

This is the jsp form

<%@include file="/init.jsp"%>
<portlet:defineobjects />

&lt;%
	List<volume> volumes = VolumeLocalServiceUtil.getAllVolumes();
	Integer i = 0;
%&gt;
<portlet:actionurl name="addCase" var="addCaseURL">
	<portlet:param name="jspPage" value="/admin/viewCase.jsp" />
</portlet:actionurl>

<portlet:renderurl var="cancelURL">
	<portlet:param name="jspPage" value="/admin/view.jsp" />
</portlet:renderurl>


<liferay-ui:error key="volume-required" message="Please choose a volume" />
<liferay-ui:error key="age-required" message="Please enter the age of the patient" />

<aui:form name="caseForm" action="<%=addCaseURL%>" method="post">
	<aui:fieldset>
		<aui:input name="caseName" label="Case Name" size="45">
			<aui:validator name="required" errorMessage="case-required" />
		</aui:input>
		<aui:select name="volumeId" label="Volume">
			<aui:option value="-1">
				<liferay-ui:message key="Choose volume" />
			</aui:option>
			&lt;%
				for (Volume volume : volumes) {
			%&gt;
			<aui:option value="<%=volume.getVolumeId()%>">
				&lt;%=volume.getVolumeName()%&gt;
			</aui:option>
			&lt;%
				}
			%&gt;
		</aui:select>
		<aui:select name="agePatient" label="Patient Age">
			<aui:option value="-1">
				<liferay-ui:message key="Choose age" />
			</aui:option>
			&lt;%
				while (i &lt; 130) {
			%&gt;
			<aui:option value="<%=i++%>">
				&lt;%=i%&gt;
			</aui:option>
			&lt;%
				}
			%&gt;
		</aui:select>
		<b>Date Case </b>
		<br>
		<liferay-ui:input-date formName="date" yearRangeStart="1970" yearRangeEnd="2100" yearValue="2010" monthValue="3" dayValue="21" dayParam="d1" monthParam="m1" yearParam="y1" />
		<br>
		<aui:input type="textarea" label="notes" rows="10" cols="30" name="notes" />
		<aui:button-row>
			<aui:button type="submit" />
			<aui:button type="cancel" value="Cancel" onClick="<%=cancelURL.toString()%>" />
		</aui:button-row>
	</aui:fieldset>
</aui:form>
</volume>


And this is the method to retrieve the form fields:

	public static CaseArchive caseArchiveFromRequest(ActionRequest request) throws ParseException {


	    CaseArchive caseC= new CaseArchiveImpl();

	    caseC.setCaseName(ParamUtil.getString(request, "caseName"));	
	    caseC.setVolumeId(ParamUtil.getInteger(request, "volumeId"));
	    caseC.setAgePatient(ParamUtil.getInteger(request, "agePatient"));
	    caseC.setNotes(ParamUtil.getString(request, "notes"));
	    
	    //handle Date
	    System.out.println("Day: "+ParamUtil.getString(request,"d1"));
	    System.out.println("Month: "+ParamUtil.getString(request,"m1"));
	    System.out.println("Year: "+ParamUtil.getString(request,"y1"));
	    
	    String date= ParamUtil.getString(request,"d1")+"/"+ParamUtil.getString(request,"m1") +"/"+ParamUtil.getString(request,"y1");
	    SimpleDateFormat formatter1 = new SimpleDateFormat("dd/MM/yyyy");
	    Date dateCase = formatter1.parse(date);
	    caseC.setDateCase(dateCase);	       
	    
	    return caseC;
	}
thumbnail
Vishal Panchal, modificado hace 11 años.

RE: Datepicker with AUI / LiferayUI form (solved)

Expert Mensajes: 289 Fecha de incorporación: 20/05/12 Mensajes recientes
Hi , Laura Liparulo ,

You can do it by using following link.
1) open the link in any browser --> http://deploy.alloyui.com/demos/datepicker/
2) right click and click "view page source".





Thanks & Regards,
Vishal R. Panchal
thumbnail
Laura Liparulo, modificado hace 11 años.

RE: Datepicker with AUI / LiferayUI form (solved)

Junior Member Mensajes: 38 Fecha de incorporación: 30/06/12 Mensajes recientes
Thanks I had found it, but it's much more code..
This is much shorter : emoticon
<b>Date Case </b>
        <br>
        <liferay-ui:input-date formName="date" yearRangeStart="1970" yearRangeEnd="2100" yearValue="2010" monthValue="3" dayValue="21" dayParam="d1" monthParam="m1" yearParam="y1" />
        <br>
thumbnail
Vishal Panchal, modificado hace 11 años.

RE: Datepicker with AUI / LiferayUI form (solved)

Expert Mensajes: 289 Fecha de incorporación: 20/05/12 Mensajes recientes
Yeah a shortest one I found ever...emoticon
Meenu R, modificado hace 10 años.

RE: Datepicker with AUI / LiferayUI form (solved)

New Member Mensajes: 18 Fecha de incorporación: 24/03/14 Mensajes recientes
hai...i this code "The method setDateCase(String) in the type dat is not applicable for the arguments (Date)" am getting this error.....help me to resolve this??
Meenu R, modificado hace 10 años.

RE: Datepicker with AUI / LiferayUI form (solved)

New Member Mensajes: 18 Fecha de incorporación: 24/03/14 Mensajes recientes
am geetting error in yearrangestart in my jsp page..help me??
Yann Mougenel, modificado hace 7 años.

RE: Datepicker with AUI / LiferayUI form (solved)

New Member Mensajes: 3 Fecha de incorporación: 8/07/16 Mensajes recientes
Hi, a good practice is to use take example from the Liferay portlets (found in tomcat/ROOT/html/portlet/...), for example the portlet-configuration.jsp uses the date picker as follow:

<liferay-ui:input-date dayParam="startDateDay" dayValue="<%= startCalendar.get(Calendar.DATE) %>" disabled="<%= false %>" firstDayOfWeek="<%= startCalendar.getFirstDayOfWeek() - 1 %>" monthParam="startDateMonth" monthValue="<%= startCalendar.get(Calendar.MONTH) %>" name="startDate" yearParam="startDateYear" yearValue="<%= startCalendar.get(Calendar.YEAR) %>" />


I hope it helps