We had the same problem. It probably can be solved in a better way (but that would require a RFE and changes to Wicket), but we used a quick and easy solution (tm).
Instead of actually setting isVisible() on the Date Picker, we just hide it using CSS. I don't know if this is applicable in your use case with wicket:enclosure. @Override public void onRendered(Component component) { if (!isReadOnly()) { super.onRendered(component); } else { Response response = component.getResponse(); response.write("\n<div style=\"display:none;\">"); super.onRendered(component); response.write("\n</div>"); } } }); We're using isReadOnly() (non-standard Wicket method) to determine if DatePicker should be visible or not. You probably could be using setVisible() isVisible() using overrides and some tweaks. >Hi, >I have date picker added to a date field. >DateTextField field = new DateTextField("field", "yyyy-MM-dd"); >field1.add(new DatePicker()); >If the section the date picker is in is visible there is no problem. If the >section is not visible using wicket:enclosure, I get an error: > http://localhost:8080/resources/org.apache.wicket.extensions.yui.YuiLib/calendar/calendar.jsUncaught >TypeError: Cannot read property 'id' of null