Java Code Examples for org.apache.wicket.model.IModel#setObject()
The following examples show how to use
org.apache.wicket.model.IModel#setObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParameterRuntimePanel.java From nextreports-server with Apache License 2.0 | 6 votes |
private AjaxFormComponentUpdatingBehavior createAjax(final QueryParameter parameter, final IModel model, final Component component, final String time) { return new AjaxFormComponentUpdatingBehavior("onchange") { @SuppressWarnings("unchecked") @Override protected void onUpdate(AjaxRequestTarget target) { // @todo wicket 1.5 does not update model for DateField and DateTimeField // https://issues.apache.org/jira/browse/WICKET-4496 // use this as an workaround if ((model == null) || (model.getObject() == null)) { return; } Date date = (Date)model.getObject(); if ("hours".equals(time)) { date = DateUtil.setHours(date, (Integer)component.getDefaultModelObject()); } else if ("minutes".equals(time)) { date = DateUtil.setMinutes(date, (Integer)component.getDefaultModelObject()); } model.setObject(date); populateDependentParameters(parameter, target, false); } }; }
Example 2
Source File: ParameterRuntimePanel.java From nextreports-server with Apache License 2.0 | 6 votes |
private AjaxFormComponentUpdatingBehavior createAjax(final QueryParameter parameter, final IModel model, final DateTextField dateField) { return new AjaxFormComponentUpdatingBehavior("onchange") { @SuppressWarnings("unchecked") @Override protected void onUpdate(AjaxRequestTarget target) { // @todo wicket 1.5 does not update model for DateField and DateTimeField // https://issues.apache.org/jira/browse/WICKET-4496 // use this as an workaround model.setObject(dateField.getDefaultModelObject()); populateDependentParameters(parameter, target, false); } }; }
Example 3
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 6 votes |
@Test public void testListModels() { IModel<String> classNameModel = Model.of(); IModel<OClass> classModel = new OClassModel(classNameModel); IModel<List<OProperty>> propertiesModel = new ListOPropertiesModel(classModel, null); IModel<List<OIndex<?>>> indexesModel = new ListOIndexesModel(classModel, null); List<OProperty> properties = propertiesModel.getObject(); List<OIndex<?>> indexes = indexesModel.getObject(); assertNotNull(properties); assertNotNull(indexes); assertTrue(properties.isEmpty()); assertTrue(indexes.isEmpty()); classModel.detach(); propertiesModel.detach(); indexesModel.detach(); classNameModel.setObject("OUser"); properties = propertiesModel.getObject(); indexes = indexesModel.getObject(); assertNotNull(properties); assertNotNull(indexes); assertFalse(properties.isEmpty()); assertFalse(indexes.isEmpty()); }
Example 4
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 6 votes |
@Test public void testOQueryModelSimple() { IModel<String> nameModel = Model.of(); OQueryModel<ODocument> queryModel = new OQueryModel<ODocument>("select from ClassA where name = :name"); queryModel.setParameter("name", nameModel); nameModel.setObject("doc1"); assertEquals(1, queryModel.size()); assertEquals("doc1", queryModel.getObject().get(0).field("name")); queryModel.detach(); nameModel.setObject("doc2"); assertEquals(1, queryModel.size()); assertEquals("doc2", queryModel.getObject().get(0).field("name")); queryModel.detach(); nameModel.setObject("doc3"); assertEquals(1, queryModel.size()); assertEquals("doc3", queryModel.getObject().get(0).field("name")); queryModel.detach(); }
Example 5
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 6 votes |
@Test public void testOQueryModelContextVariables() { IModel<String> nameModel = Model.of(); OQueryModel<ODocument> queryModel = new OQueryModel<ODocument>("select from ClassA where name = $name"); queryModel.setContextVariable("name", nameModel); nameModel.setObject("doc1"); assertEquals(1, queryModel.size()); assertEquals("doc1", queryModel.getObject().get(0).field("name")); queryModel.detach(); nameModel.setObject("doc2"); assertEquals(1, queryModel.size()); assertEquals("doc2", queryModel.getObject().get(0).field("name")); queryModel.detach(); nameModel.setObject("doc3"); assertEquals(1, queryModel.size()); assertEquals("doc3", queryModel.getObject().get(0).field("name")); queryModel.detach(); }
Example 6
Source File: ODocumentsPage.java From Orienteer with Apache License 2.0 | 6 votes |
@Override protected IModel<List<ODocument>> resolveByPageParameters(PageParameters params) { String docs = params.get("docs").toOptionalString(); IModel<List<ODocument>> result = new ListModel<>(); if (!Strings.isNullOrEmpty(docs)) { List<ODocument> docsList = new LinkedList<>(); result.setObject(docsList); if (docs.contains(",")) { String [] rids = docs.split(","); for (String rid : rids) { docsList.add(new ORecordId(rid).getRecord()); } } else { docsList.add(new ORecordId(docs).getRecord()); } } return result; }
Example 7
Source File: DefaultRestorePasswordPage.java From Orienteer with Apache License 2.0 | 6 votes |
/** * Creates restore panel * @param id component id * @return restore password panel */ protected GenericPanel<OrienteerUser> createRestorePasswordPanel(String id) { return new DefaultRestorePasswordPanel(id, getModel()) { @Override protected void onConfigure() { super.onConfigure(); setVisible(DBClosure.sudo(db -> getModelObject()) != null); } @Override protected void onRestore(AjaxRequestTarget target, IModel<OrienteerUser> model) { model.setObject(null); target.add(container); } }; }
Example 8
Source File: KnowledgeBaseIriPanel.java From inception with Apache License 2.0 | 6 votes |
private ComboBox<String> buildComboBox(String id, IModel<IRI> model, List<IRI> iris) { // Only set model object if it has not been initialized yet if (model.getObject() == null) { model.setObject(iris.get(0)); } List<String> choices = iris.stream().map(IRI::stringValue).collect(Collectors.toList()); IModel<String> adapter = new LambdaModelAdapter<String>( () -> { return model.getObject() != null ? model.getObject().stringValue() : null; }, str -> model.setObject(str != null ? SimpleValueFactory.getInstance().createIRI(str) : null) ); ComboBox<String> comboBox = new ComboBox<>(id, adapter, choices); comboBox.add(enabledWhen(() -> CUSTOMSCHEMA.equals(selectedSchemaProfile.getObject()))); comboBox.setOutputMarkupId(true); comboBox.setRequired(true); comboBox.add(IRI_VALIDATOR); // Do nothing just update the model values comboBox.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); return comboBox; }
Example 9
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testOClassNamingModel() { IModel<String> classNameModel = Model.of("OUser"); IModel<OClass> oClassModel = new OClassModel(classNameModel); OClassNamingModel model = new OClassNamingModel(oClassModel); assertModelObjectEquals("OUser", model); model.detach(); classNameModel.setObject("ORole"); assertModelObjectEquals("SuperRole", model); }
Example 10
Source File: SkillSelectPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public SkillSelectPanel(final FieldsetPanel fieldsetPanel, final IModel<SkillDO> model, final ISelectCallerPage caller, final String selectProperty) { super(fieldsetPanel.newChildId(), model, caller, selectProperty); this.fieldsetPanel = fieldsetPanel; fieldsetPanel.getFieldset().setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true); SkillDO skill = model.getObject(); if (Hibernate.isInitialized(skill) == false) { skill = getSkillTree().getSkillById(skill.getId()); model.setObject(skill); } divContainer = new WebMarkupContainer("div") { private static final long serialVersionUID = -8150112323444983335L; /** * @see org.apache.wicket.Component#isVisible() */ @Override public boolean isVisible() { // display only, if we are not in ajax skill select mode return ajaxSkillSelectMode == false; } }; divContainer.setOutputMarkupId(true); divContainer.setOutputMarkupPlaceholderTag(true); add(divContainer); ajaxSkillSelectMode = false; }
Example 11
Source File: TaskSelectPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public TaskSelectPanel(final FieldsetPanel fieldsetPanel, final IModel<TaskDO> model, final ISelectCallerPage caller, final String selectProperty) { super(fieldsetPanel.newChildId(), model, caller, selectProperty); this.fieldsetPanel = fieldsetPanel; fieldsetPanel.getFieldset().setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true); TaskDO task = model.getObject(); if (Hibernate.isInitialized(task) == false) { task = taskTree.getTaskById(task.getId()); model.setObject(task); } divContainer = new WebMarkupContainer("div") { private static final long serialVersionUID = -8150112323444983335L; /** * @see org.apache.wicket.Component#isVisible() */ @Override public boolean isVisible() { // display only, if we are not in ajax task select mode return ajaxTaskSelectMode == false; } }; divContainer.setOutputMarkupId(true); divContainer.setOutputMarkupPlaceholderTag(true); add(divContainer); ajaxTaskSelectMode = false; }
Example 12
Source File: TestFilters.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testFilterCriteriaManager() { IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(STRING_FIELD)); assertFalse(manager.isFilterApply()); manager.addFilterCriteria(manager.createEqualsFilterCriteria(Model.of(NUM_VALUE_1), Model.of(true))); assertTrue(manager.isFilterApply()); manager.clearFilterCriterias(); assertFalse(manager.isFilterApply()); IModel<Integer> model = Model.of(NUM_VALUE_1); manager.addFilterCriteria(manager.createEqualsFilterCriteria(model, Model.of(true))); assertTrue(manager.isFilterApply()); model.setObject(null); assertFalse(manager.isFilterApply()); }
Example 13
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testOPropertyNamingModel() { IModel<String> classNameModel = Model.of("OUser"); IModel<OClass> oClassModel = new OClassModel(classNameModel); IModel<OProperty> propertyModel = new OPropertyModel(oClassModel, "name"); OPropertyNamingModel model = new OPropertyNamingModel(propertyModel); assertModelObjectEquals("Name", model); model.detach(); classNameModel.setObject("ORole"); assertModelObjectEquals("Role Name", model); }
Example 14
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testNamingModel() { IModel<String> keyModel = Model.of("myobject.thisIsMyObject"); SimpleNamingModel<String> namingModel = new SimpleNamingModel<String>(keyModel); assertModelObjectEquals("This is my object", namingModel); keyModel.setObject("myobject.thatIsMyObject"); assertModelObjectEquals("That Is My Object", namingModel); namingModel.detach(); assertModelObjectEquals("That Is My Object", namingModel); }
Example 15
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testOQueryModelExpandEmpty() { IModel<String> nameModel = Model.of(); OQueryModel<ODocument> queryModel = new OQueryModel<ODocument>("select expand(empty) from ClassA where name = :name"); queryModel.setParameter("name", nameModel); nameModel.setObject("doc1"); assertEquals(0, queryModel.size()); queryModel = new OQueryModel<ODocument>("select expand(empty) from ClassA"); assertEquals(0, queryModel.size()); }
Example 16
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testOQueryModelExpandNotEmpty() { IModel<String> nameModel = Model.of(); OQueryModel<ODocument> queryModel = new OQueryModel<ODocument>("select expand(other) from ClassA where name = :name"); queryModel.setParameter("name", nameModel); nameModel.setObject("doc1"); assertEquals(2, queryModel.size()); queryModel = new OQueryModel<ODocument>("select expand(other) from ClassA"); assertEquals(6, queryModel.size()); }
Example 17
Source File: GeneralSettingsPanel.java From inception with Apache License 2.0 | 5 votes |
private ComboBox<String> languageComboBox(String id, IModel<String> aModel) { // Only set kbModel object if it has not been initialized yet if (aModel.getObject() == null && !languages.isEmpty()) { aModel.setObject(languages.get(0)); } ComboBox<String> comboBox = new ComboBox<String>(id, aModel, languages); comboBox.setOutputMarkupId(true); comboBox.setRequired(true); // Do nothing just update the kbModel values comboBox.add(new LambdaAjaxFormComponentUpdatingBehavior("change")); return comboBox; }
Example 18
Source File: RootConceptsPanel.java From inception with Apache License 2.0 | 5 votes |
private TextField<String> buildTextField(String id, IModel<IRI> model) { IModel<String> adapter = new LambdaModelAdapter<String>( () -> model.getObject().stringValue(), str -> model.setObject(SimpleValueFactory.getInstance().createIRI(str))); TextField<String> iriTextfield = new TextField<>(id, adapter); iriTextfield.setOutputMarkupId(true); iriTextfield.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> { // Do nothing just update the model values })); iriTextfield.setEnabled(false); return iriTextfield; }
Example 19
Source File: MappingPurposePanel.java From syncope with Apache License 2.0 | 4 votes |
public MappingPurposePanel(final String componentId, final IModel<MappingPurpose> model, final WebMarkupContainer container) { super(componentId, model); propagation = new AjaxLink<Void>("propagationPurposeLink") { private static final long serialVersionUID = -6957616042924610305L; @Override public void onClick(final AjaxRequestTarget target) { model.setObject(MappingPurpose.PROPAGATION); setOpacity(MappingPurpose.PROPAGATION); target.add(container); } }; pull = new AjaxLink<Void>("pullPurposeLink") { private static final long serialVersionUID = -6957616042924610305L; @Override public void onClick(final AjaxRequestTarget target) { model.setObject(MappingPurpose.PULL); setOpacity(MappingPurpose.PULL); target.add(container); } }; both = new AjaxLink<Void>("bothPurposeLink") { private static final long serialVersionUID = -6957616042924610305L; @Override public void onClick(final AjaxRequestTarget target) { model.setObject(MappingPurpose.BOTH); setOpacity(MappingPurpose.BOTH); target.add(container); } }; none = new AjaxLink<Void>("nonePurposeLink") { private static final long serialVersionUID = -6957616042924610305L; @Override public void onClick(final AjaxRequestTarget target) { model.setObject(MappingPurpose.NONE); setOpacity(MappingPurpose.NONE); target.add(container); } }; add(propagation); add(pull); add(both); add(none); setOpacity(model.getObject()); }
Example 20
Source File: RevisionDiffPanel.java From onedev with MIT License | 4 votes |
public RevisionDiffPanel(String id, IModel<Project> projectModel, IModel<PullRequest> requestModel, String oldRev, String newRev, IModel<String> pathFilterModel, IModel<WhitespaceOption> whitespaceOptionModel, @Nullable IModel<String> blameModel, @Nullable CommentSupport commentSupport) { super(id); this.projectModel = projectModel; this.requestModel = requestModel; this.oldRev = oldRev; this.newRev = newRev; this.pathFilterModel = pathFilterModel; this.blameModel = new IModel<String>() { @Override public void detach() { blameModel.detach(); } @Override public String getObject() { return blameModel.getObject(); } @Override public void setObject(String object) { AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class); String prevBlameFile = blameModel.getObject(); blameModel.setObject(object); if (prevBlameFile != null && object != null && !prevBlameFile.equals(object)) { SourceAware sourceAware = getSourceAware(prevBlameFile); sourceAware.onUnblame(target); } target.appendJavaScript("onedev.server.revisionDiff.reposition();"); } }; this.whitespaceOptionModel = whitespaceOptionModel; this.commentSupport = commentSupport; WebRequest request = (WebRequest) RequestCycle.get().getRequest(); Cookie cookie = request.getCookie(COOKIE_VIEW_MODE); if (cookie == null) diffMode = DiffViewMode.UNIFIED; else diffMode = DiffViewMode.valueOf(cookie.getValue()); }