All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.premiumminds.webapp.wicket.bootstrap.BootstrapTemporalDatepicker Maven / Gradle / Ivy

/**
 * Copyright (C) 2016 Premium Minds.
 *
 * This file is part of pm-wicket-utils.
 *
 * pm-wicket-utils is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * pm-wicket-utils is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with pm-wicket-utils. If not, see .
 */
package com.premiumminds.webapp.wicket.bootstrap;

import java.time.temporal.Temporal;
import java.util.Collection;

import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.util.visit.IVisit;
import org.apache.wicket.util.visit.IVisitor;

import com.premiumminds.webapp.wicket.TemporalTextField;
import com.premiumminds.webapp.wicket.bootstrap.datepicker.BootstrapDatePickerBehaviour;

public class BootstrapTemporalDatepicker extends WebMarkupContainer {
	private static final long serialVersionUID = -117683073963817461L;

	private TemporalTextField dateField;
	
	public BootstrapTemporalDatepicker(String id) {
		super(id);
		add(new BootstrapDatePickerBehaviour() {
			private static final long serialVersionUID = 1L;

			@Override
			public Collection getSpecialDates() {
				return BootstrapTemporalDatepicker.this.getSpecialDates();
			}
		});
	}

	@Override
	protected void onConfigure() {
		super.onConfigure();

		dateField = visitChildren(TemporalTextField.class, new IVisitor, TemporalTextField>() {
			@Override
			public void component(TemporalTextField arg0, IVisit> arg1) {
				arg1.stop(arg0);
			}
		});
	}
	
	@Override
	protected void onComponentTag(ComponentTag tag) {
		super.onComponentTag(tag);
		
		if(dateField!=null){
			tag.put("data-date-format", dateField.getTextFormat().toLowerCase());
		}
	}
	
	public Collection getSpecialDates() {
		return null;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy