There is nothing related to datepicker JS widget in this code. On Mon, May 25, 2015 at 10:13 AM, avchavan <avinash.cha...@yahoo.co.in> wrote:
> Modal Window Java code: > > package com.mycompany; > > import java.text.SimpleDateFormat; > > import org.apache.wicket.ajax.AjaxEventBehavior; > import org.apache.wicket.ajax.AjaxRequestTarget; > import org.apache.wicket.ajax.markup.html.AjaxFallbackLink; > import org.apache.wicket.markup.html.WebMarkupContainer; > import org.apache.wicket.markup.html.form.RadioChoice; > import org.apache.wicket.markup.html.form.TextField; > import org.apache.wicket.markup.html.panel.Panel; > import org.apache.wicket.model.Model; > > public class DateChangeModalWindow extends Panel{ > private static final long serialVersionUID = 1L; > private final AjaxFallbackLink cancel; > private final AjaxFallbackLink confirm; > private TextField fromDate; > private TextField toDate; > private RadioChoice<String> endDateOption; > private RadioChoice<String> untilFurtherNotice; > private WebMarkupContainer untilFurtherNoticeTD; > private final SimpleDateFormat dateFormatter = new > SimpleDateFormat("dd-MM-yyyy"); > > public DateChangeModalWindow(final String id) { > super(id); > this.setOutputMarkupPlaceholderTag(true); > this.setVisible(false); > > this.fromDate = new TextField("fromDate", Model.of("")); > this.toDate = new TextField("toDate", Model.of("")); > this.fromDate.setOutputMarkupPlaceholderTag(true); > this.toDate.setOutputMarkupPlaceholderTag(true); > this.endDateOption = new > RadioChoice<String>("endDateOption"); > this.untilFurtherNotice = new > RadioChoice<String>("untilFurtherNotice"); > this.endDateOption.setOutputMarkupPlaceholderTag(true); > > this.untilFurtherNotice.setOutputMarkupPlaceholderTag(true); > this.untilFurtherNoticeTD = new > WebMarkupContainer("untilFurtherNoticeTD"); > > this.untilFurtherNoticeTD.setOutputMarkupPlaceholderTag(true); > > this.cancel = new AjaxFallbackLink("cancel") { > @Override > public void onClick(AjaxRequestTarget target) { > this.getParent().setVisible(false); > if(target != null){ > target.add(this.getParent()); > } > } > }; > > this.confirm = new AjaxFallbackLink("confirm") { > @Override > public void onClick(AjaxRequestTarget target) { > //do something once confirmed > } > }; > > this.add(this.cancel); > this.add(this.confirm); > this.add(this.fromDate); > this.add(this.toDate); > this.add(this.endDateOption); > this.untilFurtherNoticeTD.add(this.untilFurtherNotice); > this.add(this.untilFurtherNoticeTD); > } > > public void setModelObject(final ModelObject modelObject){ > > > > this.fromDate.setDefaultModelObject(dateFormatter.format(modelObject.getBegindatum())); > if(modelObject.getEinddatum() != null){ > > > this.toDate.setDefaultModelObject(dateFormatter.format(modelObject.getEinddatum())); > } > if(modelObject.getBegindatum().before(DateUtil.getNow())){ > fromDate.setEnabled(false); > }else{ > fromDate.setEnabled(true); > } > > this.untilFurtherNotice.add(new > AjaxEventBehavior("onClick"){ > @Override > protected void onEvent(AjaxRequestTarget target) { > toDate.setDefaultModelObject(""); > toDate.setEnabled(false); > target.add(toDate); > } > }); > > if(modelObject.getEinddatum() != null){ > this.endDateOption.setVisible(false); > this.untilFurtherNoticeTD.setVisible(false); > }else{ > this.endDateOption.setVisible(true); > this.untilFurtherNoticeTD.setVisible(true); > } > > this.endDateOption.add(new AjaxEventBehavior("onClick"){ > @Override > > protected void onEvent(AjaxRequestTarget target) { > toDate.setEnabled(true); > target.add(toDate); > Here you repaint the textfield but I'd expect to have something like: $('#textFieldId').datepicker(); > } > }); > } > > } > > > Modal Window HTML Code: > > > > > Call for Modal Window: > > final DateChangeModalWindow dateChangeModalWindow = new > DateChangeModalWindow("dateChangeModalWindow", this); > add(dateChangeModalWindow); > add(new AjaxFallbackLink("modalWindow") { > > @Override > public void onClick(AjaxRequestTarget target) { > > dateChangeModalWindow.setModelObject(modelObject); > dateChangeModalWindow.setVisible(true); > if(target != null){ > target.add(dateChangeModalWindow); > } > } > > }); > > I have included the required .js files in my parent HTML. > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Loading-Javascript-for-wicket-component-tp4670871p4670875.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >