Retrieving the submit button value
Hi, i'm trying to migrate my application wicket 1.4 to 6.13 and my earlier code has this code snippet to get the button value. frm.getRootForm().findSubmittingButton().getInputName(); but this is not possible with 6.13. is there a way to get the submit buttons value for comparison. Thanks in advance. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Retrieving-the-submit-button-value-tp4664137.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
Re: Retrieving the submit button value
Cast frm.getRootForm().findSubmittingButton() to FormComponent Martin Grigorov Wicket Training and Consulting On Mon, Feb 3, 2014 at 9:35 AM, chathuraka.waas chathuraka.w...@gmail.comwrote: Hi, i'm trying to migrate my application wicket 1.4 to 6.13 and my earlier code has this code snippet to get the button value. frm.getRootForm().findSubmittingButton().getInputName(); but this is not possible with 6.13. is there a way to get the submit buttons value for comparison. Thanks in advance. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Retrieving-the-submit-button-value-tp4664137.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
Re: Retrieving the submit button value
Thanks martin. It fixed the compilation issues for me. should try out deploying the artifact. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Retrieving-the-submit-button-value-tp4664137p4664139.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
Re: AjaxLazyLoadPanel loading asynchronously
Martin Grigorov-4 wrote Hi, Create a panel that has a child an image (the busy indicator). Add a timer behavior to this panel and check whether the slow operation is done and replace the image with another component that renders the new data: public void onTimer(AjaxRequestTarget target) { Data newData = getNewData(); if (newData != null) { NewComponent c = new Component(image.getId(), newData); image.replaceWith(c); target.add(c); } else { // target.appendJavaScript(still waiting ...); } } Martin Grigorov Wicket Training and Consulting Thanks Martin! This pattern seems very similar to https://gist.github.com/jonnywray/594468 and https://gist.github.com/jonnywray/636875 which I have seen referenced in some posts here. While trying these, I am finding in FutureUpdateBehavior, onTimer(), the line if(future.isDone()) is null most times (not all). I am not quite sure why this would be. When it is null, the constructor value passed through is not null, but is null within onTimer. Any ideas on this? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxLazyLoadPanel-loading-asynchronously-tp4664035p4664140.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
Re: AjaxLazyLoadPanel loading asynchronously
Because it is transient: https://gist.github.com/jonnywray/636875#file-futureupdatebehavior-java-L19 After deserialization it will be null. Martin Grigorov Wicket Training and Consulting On Mon, Feb 3, 2014 at 10:33 AM, vp143 vishal.po...@cipriati.co.uk wrote: Martin Grigorov-4 wrote Hi, Create a panel that has a child an image (the busy indicator). Add a timer behavior to this panel and check whether the slow operation is done and replace the image with another component that renders the new data: public void onTimer(AjaxRequestTarget target) { Data newData = getNewData(); if (newData != null) { NewComponent c = new Component(image.getId(), newData); image.replaceWith(c); target.add(c); } else { // target.appendJavaScript(still waiting ...); } } Martin Grigorov Wicket Training and Consulting Thanks Martin! This pattern seems very similar to https://gist.github.com/jonnywray/594468 and https://gist.github.com/jonnywray/636875 which I have seen referenced in some posts here. While trying these, I am finding in FutureUpdateBehavior, onTimer(), the line if(future.isDone()) is null most times (not all). I am not quite sure why this would be. When it is null, the constructor value passed through is not null, but is null within onTimer. Any ideas on this? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxLazyLoadPanel-loading-asynchronously-tp4664035p4664140.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
Accessing WebApplication from the service layer
Hey, I've just been sketching out an entity locking mechanism (below) to prevent users from editing entities which another user is already in the process of editing. It works fine but the problem is that placing this in my WebApplication class means that I need to make MyApplication.get() call from within my service layer and this seems a tad messy. Is this a Wicket cardinal sin or am I just stressing over nothing? Cheers, Chambre class EntityLock { public String entityId; public String entityName; public String sessionId; public Date locked; public Date lastBumped; } @SuppressWarnings(unchecked) private MapString, EntityLock getEntityLocksByEntity() { HashMapString, EntityLock locksByEntity = (HashMapString, EntityLock) getMetaData(ENTITY_LOCKS_BY_ENTITY); if (locksByEntity == null) { locksByEntity = new HashMapString, EntityLock(); setMetaData(ENTITY_LOCKS_BY_ENTITY, locksByEntity); } return locksByEntity; } public boolean acquireEntityLock(PersistentEntity entity) { EntityLock lock = getEntityLocksByEntity().get(entity.getId()); if (lock != null) { if ((System.currentTimeMillis() - lock.lastBumped.getTime()) (1 * 60 * 1000)) { releaseEntityLock(entity); } else { return false; } } getEntityLocksByEntity().put(entity.getId(), newEntityLock(entity)); return true; } private EntityLock newEntityLock(PersistentEntity entity) { EntityLock newLock = new EntityLock(); newLock.entityId = entity.getId(); if (entity instanceof HibernateProxy) { newLock.entityName = ((HibernateProxy) entity).getHibernateLazyInitializer().getEntityName(); } else { newLock.entityName = entity.getClass().getName(); } newLock.sessionId = getSession().getId(); Date now = new Date(); newLock.locked = now; newLock.lastBumped = now; return newLock; } public void releaseEntityLock(PersistentEntity entity) { getEntityLocksByEntity().remove(entity.getId()); } public boolean isEntityLocked(PersistentEntity entity) { return getEntityLocksByEntity().get(entity.getId()) != null; } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Accessing-WebApplication-from-the-service-layer-tp4664145.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
Re: Accessing WebApplication from the service layer
Hi, Extract the locking managing code in a service. Then use Spring/CDI/Guice/... to manage the service dependencies for you. Martin Grigorov Wicket Training and Consulting On Mon, Feb 3, 2014 at 2:38 PM, ChambreNoire a...@tentelemed.com wrote: Hey, I've just been sketching out an entity locking mechanism (below) to prevent users from editing entities which another user is already in the process of editing. It works fine but the problem is that placing this in my WebApplication class means that I need to make MyApplication.get() call from within my service layer and this seems a tad messy. Is this a Wicket cardinal sin or am I just stressing over nothing? Cheers, Chambre class EntityLock { public String entityId; public String entityName; public String sessionId; public Date locked; public Date lastBumped; } @SuppressWarnings(unchecked) private MapString, EntityLock getEntityLocksByEntity() { HashMapString, EntityLock locksByEntity = (HashMapString, EntityLock) getMetaData(ENTITY_LOCKS_BY_ENTITY); if (locksByEntity == null) { locksByEntity = new HashMapString, EntityLock(); setMetaData(ENTITY_LOCKS_BY_ENTITY, locksByEntity); } return locksByEntity; } public boolean acquireEntityLock(PersistentEntity entity) { EntityLock lock = getEntityLocksByEntity().get(entity.getId()); if (lock != null) { if ((System.currentTimeMillis() - lock.lastBumped.getTime()) (1 * 60 * 1000)) { releaseEntityLock(entity); } else { return false; } } getEntityLocksByEntity().put(entity.getId(), newEntityLock(entity)); return true; } private EntityLock newEntityLock(PersistentEntity entity) { EntityLock newLock = new EntityLock(); newLock.entityId = entity.getId(); if (entity instanceof HibernateProxy) { newLock.entityName = ((HibernateProxy) entity).getHibernateLazyInitializer().getEntityName(); } else { newLock.entityName = entity.getClass().getName(); } newLock.sessionId = getSession().getId(); Date now = new Date(); newLock.locked = now; newLock.lastBumped = now; return newLock; } public void releaseEntityLock(PersistentEntity entity) { getEntityLocksByEntity().remove(entity.getId()); } public boolean isEntityLocked(PersistentEntity entity) { return getEntityLocksByEntity().get(entity.getId()) != null; } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Accessing-WebApplication-from-the-service-layer-tp4664145.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
Re: Accessing WebApplication from the service layer
Hello, OK so no storing my MapString, EntityLock in the Application MetaData then? Many thanks, Chambre -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Accessing-WebApplication-from-the-service-layer-tp4664145p4664147.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
Re: Accessing WebApplication from the service layer
Well, you can either store it as application metadata or make your locking service implementation a singleton (managed by your dependency injection framework of choice). Either way, you abstract away the exact storage location of your locks behind the facade of your EntityLockingService. Met vriendelijke groet, Kind regards, Bas Gooren schreef ChambreNoire op 3-2-2014 14:48: Hello, OK so no storing my MapString, EntityLock in the Application MetaData then? Many thanks, Chambre -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Accessing-WebApplication-from-the-service-layer-tp4664145p4664147.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
Re: Accessing WebApplication from the service layer
Yes however I also store the id of the session that owns the lock in a map so that I can easily flush locks when a user session expires. This would mean that EntityLockService would need access to the current WebSession which also seems messy... Chambre -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Accessing-WebApplication-from-the-service-layer-tp4664145p4664149.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
Re: Accessing WebApplication from the service layer
class MyApp extends WebApplication { @Inject EntityLockService lockService; @Override public void sessionUnbound(String sessionId) { lockService.cleanup(sessionId); } } Martin Grigorov Wicket Training and Consulting On Mon, Feb 3, 2014 at 3:09 PM, ChambreNoire a...@tentelemed.com wrote: Yes however I also store the id of the session that owns the lock in a map so that I can easily flush locks when a user session expires. This would mean that EntityLockService would need access to the current WebSession which also seems messy... Chambre -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Accessing-WebApplication-from-the-service-layer-tp4664145p4664149.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
Re: AjaxLazyLoadPanel loading asynchronously
I cannot get future here (https://gist.github.com/jonnywray/636875#file-futureupdatebehavior-java-L31) to have a value. I do not understand when/how it gets deserialized? Martin Grigorov-4 wrote Because it is transient: https://gist.github.com/jonnywray/636875#file-futureupdatebehavior-java-L19 After deserialization it will be null. Martin Grigorov Wicket Training and Consulting -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxLazyLoadPanel-loading-asynchronously-tp4664035p4664151.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
Re: Accessing WebApplication from the service layer
Yup that's exactly what I have done. My problem lies with the lock creation in newEntityLock(PersistentEntity entity) which needs the session Id... Chambre -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Accessing-WebApplication-from-the-service-layer-tp4664145p4664152.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
Re: AjaxLazyLoadPanel loading asynchronously
Hi, When your page gets serialized (which can happen between requests), transient fields (like the future field) are set to null. When your behavior is triggered and the page is deserialized, the field is null. Met vriendelijke groet, Kind regards, Bas Gooren schreef vp143 op 3-2-2014 15:16: I cannot get future here (https://gist.github.com/jonnywray/636875#file-futureupdatebehavior-java-L31) to have a value. I do not understand when/how it gets deserialized? Martin Grigorov-4 wrote Because it is transient: https://gist.github.com/jonnywray/636875#file-futureupdatebehavior-java-L19 After deserialization it will be null. Martin Grigorov Wicket Training and Consulting -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxLazyLoadPanel-loading-asynchronously-tp4664035p4664151.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