Example usage for org.apache.wicket.model IModel setObject

List of usage examples for org.apache.wicket.model IModel setObject

Introduction

In this page you can find the example usage for org.apache.wicket.model IModel setObject.

Prototype

default void setObject(final T object) 

Source Link

Document

Sets the model object.

Usage

From source file:at.ac.tuwien.ifs.tita.ui.uihelper.DateTextFieldRenderer.java

License:Apache License

/**
 * {@inheritDoc}/*from w  w w.  jav a 2s  .co  m*/
 */
@SuppressWarnings("unchecked")
@Override
public Component getRenderComponent(String id, IModel model, SelectableListItem parent, int row, int column) {
    IModel<String> newModel = model;
    newModel.setObject(GlobalUtils.DATEFORMAT.format(model.getObject()));
    return new Label(id, newModel);
}

From source file:au.org.theark.lims.web.component.global.biospecimen.form.BiospecimenListForm.java

License:Open Source License

private void initialiseDataView() {

    Subject currentUser = SecurityUtils.getSubject();
    ArkUser arkUser;/*from w w  w  .  jav a  2 s  .co  m*/
    try {
        arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString());
        ArkUserVO arkUserVo = new ArkUserVO();
        arkUserVo.setArkUserEntity(arkUser);
        studyListForUser = iArkCommonService.getStudyListForUser(arkUserVo); //getParentAndChildStudies(sessionStudyId);
    } catch (EntityNotFoundException e) {
        e.printStackTrace();
    }

    dataViewListWMC = new WebMarkupContainer("dataViewListWMC");
    dataViewListWMC.setOutputMarkupId(true);
    // Data provider to paginate resultList
    biospecimenProvider = new ArkDataProvider2<LimsVO, Biospecimen>() {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) iLimsService.getBiospecimenCount(criteriaModel.getObject());
        }

        public Iterator<Biospecimen> iterator(int first, int count) {
            List<Biospecimen> biospecimenList = new ArrayList<Biospecimen>();
            if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) {
                biospecimenList = iLimsService.searchPageableBiospecimens(criteriaModel.getObject(), first,
                        count);
            }
            return biospecimenList.iterator();
        }
    };
    // Set the criteria into the data provider's model
    biospecimenProvider.setCriteriaModel(cpModel);

    dataView = buildDataView(biospecimenProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    final IModel<String> amountModel = new Model<String>(Integer.toString(biospecimenProvider.size()));
    dataViewListWMC.add(new Label("total", amountModel) {
        private static final long serialVersionUID = 1L;

        protected void onBeforeRender() {
            amountModel.setObject(Integer.toString(biospecimenProvider.size()));
            super.onBeforeRender();
        };
    });

    AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAjaxEvent(AjaxRequestTarget target) {
            target.add(dataViewListWMC);
        }
    };
    dataViewListWMC.add(pageNavigator);
    dataViewListWMC.add(dataView);

    List<IColumn<Biospecimen>> columns = new ArrayList<IColumn<Biospecimen>>();
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("BiospecimenUID"), "biospecimenUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Study"), "study.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("SubjectUID"), "linkSubjectStudy.subjectUID"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("ParentUID"), "parentUid"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Collection"), "bioCollection.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Sample Type"), "sampleType.name"));
    columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Quantity"), "quantity"));

    DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("BiospecimenUID");
    headers.add("Study");
    headers.add("SubjectUID");
    headers.add("ParentUID");
    headers.add("Collection");
    headers.add("Sample Type");
    headers.add("Quantity");

    String filename = "biospecimens";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    dataViewListWMC.add(toolbars);
    add(dataViewListWMC);
}

From source file:au.org.theark.study.web.component.global.subject.SubjectContainerPanel.java

License:Open Source License

@SuppressWarnings("unchecked")
protected WebMarkupContainer initialiseSearchResults() {
    searchResultsPanel = new SearchResultListPanel("searchResults", arkContextMarkup, containerForm,
            arkCrudContainerVO, studyNameMarkup, studyLogoMarkup, mainTabs);

    Subject currentUser = SecurityUtils.getSubject();
    ArkUser arkUser;/*from ww w .j  a v a 2s. co  m*/
    try {
        arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString());
        ArkUserVO arkUserVo = new ArkUserVO();
        arkUserVo.setArkUserEntity(arkUser);
        studyListForUser = iArkCommonService.getStudyListForUser(arkUserVo); //getParentAndChildStudies(sessionStudyId);
    } catch (EntityNotFoundException e) {
        e.printStackTrace();
    }

    if (sessionStudyId != null) {
        LinkSubjectStudy linkSubjectStudy = new LinkSubjectStudy();
        linkSubjectStudy.setStudy(study);
        //containerForm.getModelObject().setLinkSubjectStudy(linkSubjectStudy);
    }

    // Data providor to paginate resultList
    subjectProvider = new ArkDataProvider<SubjectVO, IArkCommonService>(iArkCommonService) {

        private static final long serialVersionUID = 1L;

        public int size() {
            return (int) service.getStudySubjectCount(model.getObject());
        }

        public Iterator<SubjectVO> iterator(int first, int count) {
            List<SubjectVO> listSubjects = new ArrayList<SubjectVO>();
            if (isActionPermitted()) {
                listSubjects = iArkCommonService.searchPageableSubjects(model.getObject(), first, count);
            }
            return listSubjects.iterator();
        }
    };

    TextField<OtherID> txtFld = ((TextField<OtherID>) containerForm
            .get("searchContainer:searchComponentPanel:searchForm:otherID"));
    String otherIDSearch = txtFld != null ? txtFld.getValue() : null;
    if (otherIDSearch != null) {
        OtherID o;
        o = new OtherID();
        o.setOtherID(otherIDSearch);
        //         List<OtherID> otherIDs = new ArrayList<OtherID>();
        //         otherIDs.add(o);
        cpModel.getObject().getLinkSubjectStudy().getPerson().getOtherIDs().clear();//setOtherIDs(otherIDs);
        cpModel.getObject().getLinkSubjectStudy().getPerson().getOtherIDs().add(o);
    }

    subjectProvider.setModel(this.cpModel);

    dataView = searchResultsPanel.buildDataView(subjectProvider);
    dataView.setItemsPerPage(
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());

    if (containerForm.getModelObject().getStudyList().isEmpty()) {
        containerForm.getModelObject().setStudyList(studyListForUser);
    }
    IModel<String> amountModel = new Model<String>(Integer.toString(subjectProvider.size()));
    resultsWmc.add(new Label("total", amountModel) {
        private static final long serialVersionUID = 1L;

        protected void onBeforeRender() {
            amountModel.setObject(Integer.toString(subjectProvider.size()));
            super.onBeforeRender();
        };
    });

    PagingNavigator pageNavigator = new PagingNavigator("navigator", dataView);
    resultsWmc.add(pageNavigator);

    List<IColumn<SubjectVO>> columns = new ArrayList<IColumn<SubjectVO>>();
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("SubjectUID"), "subjectUID"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Study"), "linkSubjectStudy.study.name"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Full Name"), "subjectFullName"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Last Name History"),
            "linkSubjectStudy.person.descriptiveLastNameHistory"));
    columns.add(new ExportableDateColumn<SubjectVO>(Model.of("Date Of Birth"),
            "linkSubjectStudy.person.dateOfBirth", au.org.theark.core.Constants.DD_MM_YYYY));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Vital Status"),
            "linkSubjectStudy.person.vitalStatus.name"));
    columns.add(
            new ExportableTextColumn<SubjectVO>(Model.of("Gender"), "linkSubjectStudy.person.genderType.name"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Subject Status"),
            "linkSubjectStudy.subjectStatus.name"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Consent Status"),
            "linkSubjectStudy.consentStatus.name"));
    columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Other IDs"),
            "linkSubjectStudy.person.descriptiveOtherIDs"));

    DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(),
            iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue());
    List<String> headers = new ArrayList<String>(0);
    headers.add("SubjectUID");
    headers.add("Study");
    headers.add("Full Name");
    headers.add("Last Name History");
    headers.add("Date of Birth");
    headers.add("Vital Status");
    headers.add("Gender");
    headers.add("Subject Status");
    headers.add("Consent Status");
    headers.add("Other IDs");

    String filename = "subjects";
    RepeatingView toolbars = new RepeatingView("toolbars");
    ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename);
    toolbars.add(new Component[] { exportToolBar });
    resultsWmc.add(toolbars);

    resultsWmc.add(dataView);
    searchResultsPanel.add(resultsWmc);
    arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultsPanel);
    return arkCrudContainerVO.getSearchResultPanelContainer();
}

From source file:com.axway.ats.testexplorer.pages.model.ScenarioDescriptionColumn.java

License:Apache License

@Override
public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) {

    final Scenario scenario = (Scenario) rowModel.getObject();
    String description = scenario.description;
    if (description == null) {
        description = "";
    }//from  www  .  j a  va 2 s . c om
    IModel<String> labelModel = new Model<String>(description);
    Label label = new Label(componentId, labelModel);
    if (description.length() > 0 && description.contains("://")) {

        description = description.replace("<", "&lt;").replace(">", "&gt;");

        // search for links with wiki syntax eg. [Link text|http://some.rul.com/test.html]
        StringBuffer sb = new StringBuffer(description.length());
        Matcher wikiUrlMatcher = wikiUrlPattern.matcher(description);
        while (wikiUrlMatcher.find()) {
            wikiUrlMatcher.appendReplacement(sb, "<a href=\"$2\" class=\"linkInTable\">$1</a>");
        }
        wikiUrlMatcher.appendTail(sb);
        description = sb.toString();

        // search for quoted links eg. "http://some.rul.com/read me/test spaces.html"
        sb = new StringBuffer(description.length());
        Matcher quotedUrlMatcher = quotedUrlPattern.matcher(description);
        while (quotedUrlMatcher.find()) {
            quotedUrlMatcher.appendReplacement(sb, "<a href=\"$1\" class=\"linkInTable\">$1</a>");
        }
        quotedUrlMatcher.appendTail(sb);
        description = sb.toString();

        // search for regular links(without spaces) eg. http://some.rul.com/read_me.txt
        sb = new StringBuffer(description.length());
        Matcher withoutSpaceMatcher = withoutSpaceUrlPattern.matcher(description);
        while (withoutSpaceMatcher.find()) {
            withoutSpaceMatcher.appendReplacement(sb, "<a href=\"$1\" class=\"linkInTable\">$1</a>");
        }
        withoutSpaceMatcher.appendTail(sb);

        labelModel.setObject(sb.toString());
        label.setEscapeModelStrings(false);
    }

    return label;
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.StatisticsPanel.java

License:Apache License

/**
 * @return ListView containing all diagrams
 *///from  w ww .j a v  a 2 s . co  m
private ListView<DbStatisticDescription> addChartGroupListView() {

    ListView<DbStatisticDescription> listViewChartGroup = new ListView<DbStatisticDescription>("chartGroupRows",
            listViewContent) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<DbStatisticDescription> item) {

            DbStatisticDescription statElement = listViewContent.get(item.getIndex());

            if (statElement.name.equals("HEADER")) { // add the header row for the diagram table
                item.add(AttributeModifier.replace("class", "chartGroupHeader"));
                Label removeIcon = new Label("removeIcon");
                removeIcon.add(AttributeModifier.append("style", ";display:none;"));
                item.add(removeIcon);
                item.add(addDiagramHeaderName("statName", "Name"));

                IModel<String> aliasModel = new Model<String>();
                aliasModel.setObject("Alias");
                TextField<String> alias = new TextField<String>("alias", aliasModel);
                alias.setOutputMarkupId(true);
                alias.add(AttributeModifier.append("style",
                        ";background-color:transparent;border:0px;pointer-events:none;text-align: center;font-family:\"Times New Roman\",Times,serif;"));
                alias.add(AttributeModifier.replace("class", "chartGroupHeader"));
                item.add(alias);
                item.add(addDiagramHeaderName("startDate", "Start Time"));
                item.add(addDiagramHeaderName("run", "Run"));
                item.add(addDiagramHeaderName("suite", "Suite"));
                item.add(addDiagramHeaderName("scenario", "Scenario"));
                item.add(addDiagramHeaderName("testcase", "Testcase"));

            } else if (statElement.unit == null) { // add diagram name row

                final AjaxButton deleteAllButton = new AjaxButton("removeIcon") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onSubmit(AjaxRequestTarget target, Form<?> form) {

                        String diagramName = listViewContent.get(item.getIndex()).name;
                        getTESession().getDiagramContainer().remove(diagramName);
                        updateDiagramTableContent();

                        target.add(statsForm);
                    }
                };
                deleteAllButton
                        .add(AttributeModifier.replace("class", "fixGroupTableColumn removeAllItemsIcon"));
                item.add(deleteAllButton);
                item.add(AttributeModifier.replace("class", "chartGroup"));

                item.add(new Label("statName", "").setEscapeModelStrings(false));
                Label alias = new Label("alias", "");
                // disable and change CSS of the input tag
                alias.add(AttributeModifier.append("style",
                        ";background-color:transparent;border:0px;pointer-events:none"));
                item.add(alias);
                item.add(new Label("startDate", statElement.name).setEscapeModelStrings(false));
                item.add(new Label("run", "").setEscapeModelStrings(false));
                item.add(new Label("suite", "").setEscapeModelStrings(false));
                item.add(new Label("scenario", "").setEscapeModelStrings(false));
                item.add(new Label("testcase", "").setEscapeModelStrings(false));

            } else { // add diagram content
                List<String> statNavigationTokens = getStatisticNavigation(statElement);
                final AjaxButton deleteButton = new AjaxButton("removeIcon") {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onSubmit(AjaxRequestTarget target, Form<?> form) {

                        deleteSingleRowFromDiagramList(item);
                        updateDiagramTableContent();

                        target.add(statsForm);
                    }
                };
                item.add(deleteButton);
                item.add(new Label("statName", statElement.name).setEscapeModelStrings(false));
                IModel<String> aliasModel = null;
                DbStatisticDescription currentElement = listViewContent.get(item.getIndex());
                String currentElementKey = null;
                if (currentElement.getStatisticId() != 0 && currentElement.machineId != 0) {
                    currentElementKey = getDiagramName(item.getIndex()) + "_" + currentElement.testcaseStarttime
                            + "_" + currentElement.getStatisticId() + "_" + currentElement.machineId;
                } else {
                    currentElementKey = getDiagramName(item.getIndex()) + "_" + currentElement.testcaseStarttime
                            + "_" + currentElement.getName() + "_" + currentElement.getParentName();
                }
                // using diagramName+testcaseStartTime+statisticTypeId+machineId or testcaseStartTime+name+queueName for key
                IModel<String> alias = getTESession().getStatisticsAliasModels().get(currentElementKey);
                if (alias != null && alias.getObject() != null) {
                    aliasModel = alias;
                } else {
                    aliasModel = new Model<String>();
                }
                getTESession().getStatisticsAliasModels().put(currentElementKey, aliasModel);
                item.add(new TextField<String>("alias", aliasModel).setOutputMarkupId(true));
                item.add(new Label("startDate", statNavigationTokens.get(4)).setEscapeModelStrings(false));
                item.add(new Label("run", statNavigationTokens.get(0)).setEscapeModelStrings(false));
                item.add(new Label("suite", statNavigationTokens.get(1)).setEscapeModelStrings(false));
                item.add(new Label("scenario", statNavigationTokens.get(2)).setEscapeModelStrings(false));
                item.add(new Label("testcase", statNavigationTokens.get(3)).setEscapeModelStrings(false));
            }
        };
    };
    listViewChartGroup.setOutputMarkupId(true);

    return listViewChartGroup;
}

From source file:com.doculibre.constellio.wicket.panels.admin.resultPanels.AddEditResultClassPanel.java

License:Open Source License

public AddEditResultClassPanel(String id, ConnectorInstance connector) {
    super(id, true);
    this.connectorModel = new ReloadableEntityModel<ConnectorInstance>(connector);

    String defaultConnectorTypeClass = connector.getConnectorType().getSearchResultPanelClassName();

    IModel customClassModel = new Model();

    final IModel choice = new Model();
    if (connector.getSearchResultPanelClassName() != null) {
        choice.setObject(CUSTOM_CLASS);
        customClassModel.setObject(connector.getSearchResultPanelClassName());
    } else if (defaultConnectorTypeClass != null) {
        choice.setObject(DEFAULT_CONNECTOR_TYPE_CLASS);
    } else {//from  ww w  . j a v  a  2  s.  com
        choice.setObject(DEFAULT_CLASS);
    }

    List<String> choices = new ArrayList<String>();
    String defaultClass = DefaultSearchResultPanel.class.getCanonicalName();
    if (defaultConnectorTypeClass != null) {
        defaultClass = defaultConnectorTypeClass;
        choices.add(DEFAULT_CONNECTOR_TYPE_CLASS);
    } else {
        choices.add(DEFAULT_CLASS);
    }
    choices.add(CUSTOM_CLASS);

    final Form form = getForm();

    // Remplacer les composantes directement par ajax cre des problmes
    // Remplacer le panel au complet cre un autre problme avec firefox
    final WebMarkupContainer container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);

    this.customClassTextField = new TextField("customClass", customClassModel) {
        @Override
        public boolean isVisible() {
            boolean visible = CUSTOM_CLASS.equals((String) choice.getObject());
            return visible;
        }
    };

    this.defaultClassLabel = new Label("defaultClass", defaultClass) {
        @Override
        public boolean isVisible() {
            return !CUSTOM_CLASS.equals((String) choice.getObject());
        }
    };

    this.defaultOrCustomDropDown = new DropDownChoice("defaultClassRadio", choice, choices,
            new StringResourceChoiceRenderer(this));
    this.defaultOrCustomDropDown.add(new OnChangeAjaxBehavior() {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.addComponent(container);
        }
    });

    form.add(defaultOrCustomDropDown);
    form.add(container);
    container.add(customClassTextField);
    container.add(defaultClassLabel);
}

From source file:com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteItemDefinitionPanel.java

License:Apache License

private void initLayout(final IModel<ItemDefinition<?>> model) {
    final Model<String> itemDefinitionAsStringModel = new Model<>(null);
    AutoCompleteTextField<String> input = new AutoCompleteTextField<String>(ID_INPUT,
            itemDefinitionAsStringModel, String.class, createAutoCompleteSettings()) {

        private static final long serialVersionUID = 1L;

        @Override// w w w  .  j a  v a  2s  . c  om
        protected Iterator<String> getChoices(String input) {
            List<String> defsAsString = new ArrayList<>();
            for (ItemDefinition<?> def : listChoices(input).values()) {
                defsAsString.add(def.getName().getLocalPart());
            }
            return defsAsString.iterator();

        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            itemDefinitionAsStringModel.setObject(null);
        }

    };

    input.add(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            String newValue = itemDefinitionAsStringModel.getObject();
            if (StringUtils.isNotBlank(newValue)) {
                ItemDefinition<?> def = listChoices("").get(newValue);
                if (def != null) {
                    model.setObject(def);
                }
            }
        }
    });

    add(input);
}

From source file:com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteQNamePanel.java

License:Apache License

private void initLayout(final IModel<QName> model) {
    setOutputMarkupId(true);//from   w  w  w  . j  a v  a2s .  com

    AutoCompleteSettings autoCompleteSettings = createAutoCompleteSettings();
    final IModel<String> stringModel = new Model<String>() {

        @Override
        public void setObject(String object) {
            super.setObject(object);
            model.setObject(convertToQname(object));
        }

    };

    // The inner autocomplete field is always String. Non-string auto-complete fields are problematic
    final AutoCompleteTextField<String> input = new AutoCompleteTextField<String>(ID_INPUT, stringModel,
            String.class, autoCompleteSettings) {
        private static final long serialVersionUID = 1L;

        @Override
        protected Iterator<String> getChoices(String input) {
            return getIterator(input);
        }

    };
    input.add(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            String inputString = stringModel.getObject();
            if (StringUtils.isBlank(inputString)) {
                QName modelObject = model.getObject();
                if (modelObject != null) {
                    model.setObject(null);
                    AutoCompleteQNamePanel.this.onChange(target);
                }
            } else {
                QName inputQName = convertToQname(stringModel.getObject());
                if (inputQName == null) {
                    // We have some input, but it does not match any QName. Just do nothing.
                } else {
                    QName modelObject = model.getObject();
                    if (inputQName.equals(modelObject)) {
                        model.setObject(inputQName);
                        AutoCompleteQNamePanel.this.onChange(target);
                    }
                }
            }
        }
    });
    add(input);
}

From source file:com.evolveum.midpoint.gui.api.component.password.PasswordPanel.java

License:Apache License

private void onRemovePassword(IModel<ProtectedStringType> model, AjaxRequestTarget target) {
    get(ID_LINK_CONTAINER).get(ID_PASSWORD_SET).setVisible(false);
    get(ID_LINK_CONTAINER).get(ID_PASSWORD_REMOVE).setVisible(true);
    passwordInputVisble = false;//from w w  w  .  j  av  a 2 s  . c om
    target.add(this);
    model.setObject(null);
}

From source file:com.evolveum.midpoint.web.component.assignment.AssignmentEditorPanel.java

License:Apache License

private IModel<Date> createDateModel(final IModel<XMLGregorianCalendar> model) {
    return new Model<Date>() {

        @Override/*from  w  w  w . ja v a  2 s .co  m*/
        public Date getObject() {
            XMLGregorianCalendar calendar = model.getObject();
            if (calendar == null) {
                return null;
            }
            return MiscUtil.asDate(calendar);
        }

        @Override
        public void setObject(Date object) {
            if (object == null) {
                model.setObject(null);
            } else {
                model.setObject(MiscUtil.asXMLGregorianCalendar(object));
            }
        }
    };
}