dateselect.xhtml 2.01 KB
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:composite="http://java.sun.com/jsf/composite" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools">


<composite:interface>

	<composite:attribute name="datefield" required="true" />
	<composite:attribute name="submitaction" required="true" method-signature="java.lang.String action()" />
</composite:interface>

<composite:implementation>

	<h:outputScript target="head" library="script" name="jquery.min.js" />
	<h:outputScript target="head" library="script" name="date.js" />
	<h:outputStylesheet library="style" name="datePicker.css" />
	<h:outputScript target="head" library="script" name="jquery.datePicker.js" />
	<h:outputScript target="head" library="script" name="date_fi.js" />

	<h:outputScript target="head">
			Date.format = 'dd/mm/yyyy';
			
			$(function()
			{
			
			$('#currdatePick').datePicker({inline:true#{sessionHandler.hasPermission('CALENDAR_MANAGE')?', startDate: \'01/01/1970\'':''}})
					.dpSetSelected($('#dselect\\:dateform\\:dateField').val())
					.bind('dateSelected',
						function(e, selectedDate, $td)
						{
							var formatted = selectedDate.asString()
							$('#dselect\\:dateform\\:dateField').val(formatted);
							var subbutt = $('#dselect\\:dateform\\:sub');
							subbutt.click();
						}
					);
			
			
			});
			
			
		</h:outputScript>

	<div id="currdatePick" />
	<h:form id="dateform">
		<h:inputHidden id="dateField" value="#{cc.attrs.datefield.time}">
			<!-- date format Fixed for dateselector! -->
			<f:convertDateTime pattern="dd/MM/yyyy" />
		</h:inputHidden>
		<h:commandButton style="display: none" id="sub" action="#{cc.attrs.submitaction}" value="foobar" />

	</h:form>

</composite:implementation>
</html>