Java Code Examples for org.apache.wicket.model.IModel#detach()
The following examples show how to use
org.apache.wicket.model.IModel#detach() .
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: BeanContext.java From onedev with MIT License | 6 votes |
public IModel<Serializable> wrapAsSelfUpdating(final IModel<Serializable> model) { return new IModel<Serializable>() { @Override public void detach() { model.detach(); } @Override public Serializable getObject() { return model.getObject(); } @Override public void setObject(Serializable object) { descriptor.copyProperties(object, getObject()); } }; }
Example 2
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 3
Source File: BinaryViewPanel.java From Orienteer with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public BinaryViewPanel(String id, final IModel<ODocument> docModel, final IModel<OProperty> propModel, IModel<V> valueModel) { super(id, valueModel); nameModel = new LoadableDetachableModel<String>() { @Override protected String load() { String filename = docModel.getObject().field(propModel.getObject().getName()+BinaryEditPanel.FILENAME_SUFFIX, String.class); if(Strings.isEmpty(filename)){ filename = oClassIntrospector.getDocumentName(docModel.getObject()); filename += "."+propModel.getObject().getName()+".bin"; } return filename; } @Override public void detach() { super.detach(); docModel.detach(); propModel.detach(); } }; initialize(); }
Example 4
Source File: SavePrototypeCommand.java From Orienteer with Apache License 2.0 | 6 votes |
@Override public void onClick(Optional<AjaxRequestTarget> targetOptional) { IModel<T> model = getModel(); T object = model!=null?model.getObject():null; if(object instanceof IPrototype) { boolean isActiveTransaction = getDatabase().getTransaction().isActive(); if(isActiveTransaction) getDatabase().commit(); try { ((IPrototype<?>)object).realizePrototype(); model.detach(); } finally { if(isActiveTransaction) getDatabase().begin(); } } super.onClick(targetOptional); }
Example 5
Source File: OQueryModel.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override public void detach() { for (IModel<?> model : params.values()) { model.detach(); } super.detach(); size=null; }
Example 6
Source File: AddWidgetPanel.java From nextreports-server with Apache License 2.0 | 5 votes |
protected boolean isSelected(Entity entity) { IModel<Entity> model = treeProvider.model(entity); try { return (selected != null) && selected.equals(model) && !(selected.getObject() instanceof ro.nextreports.server.domain.Folder); } finally { model.detach(); } }
Example 7
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()); }
Example 8
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 4 votes |
private void interupt(ODatabaseDocument db, IModel<?> model) { model.detach(); db.commit(); db.getLocalCache().clear(); db.begin(); }
Example 9
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 4 votes |
public static void assertModelObjectEquals(Object expected, IModel<?> model) { assertEquals(expected, model.getObject()); model.detach(); assertEquals(expected, model.getObject()); }