Re: [ANNOUNCEMENT] New Tapestry 5 book
Hi Igor, I bought the PDF Book today and started reading immediately, very well written so far looks very promising! But where can I get the content (examples) that will be delivered on CD with the printed version? thx, Max Am 16.09.2009 um 20:28 schrieb Igor Drobiazko: Hello folks, I am pleased to announce a new Tapestry 5 book. The book is written in German and is available as eBook on publisher's website: http://www.addison-wesley.de/main/main.asp?page=home/bookdetailsProductID=174975 The hardcover version of the book will be available starting from Sep 28 2009. I'll make another announcement when the hardcover version is released. Among other things the book covers : * Getting Started with Tapestry 5 * Concepts of the framework * Localization/internationalization * Creating Forms * Generation of user interfaces for JavaBeans * Writing own components and mixins * Ajax * Writing tests for Tapestry applications * Hibernate and Spring integration * Dependency Injection and Tapestry IoC * AOP and bytecode manipuation Special thanks go to Howard and Ulrich Stärk. Howard gave me some hints on how to write a better book and wrote a foreword. Ulrich was responsible for the technical review of the book and helped me to improve the quality. Enjoy -- Best regards, Igor Drobiazko
Re: Audit logging - how to acces SSO in Hibernate
; } public void handle(PageRenderRequestParameters parameters, PageRenderRequestHandler handler) throws IOException { RincoSessionUser webSessionUser = (RincoSessionUser) _manager.getIfExists(WebSessionUser.class); if (webSessionUser != null) { SecurityContext securityContext = new SecurityContext(webSessionUser.getUserId()); SecurityContextHolder.set(securityContext); _logger.debug(SecurityContext added to the thread {} , new Object[] { securityContext }); } handler.handle(parameters); } } SecurityContextHolder is the class that interacts with threadlocal: public class SecurityContextHolder { private static ThreadLocalSecurityContext tLocal = new ThreadLocalSecurityContext(); public static void set(SecurityContext securityContext) { tLocal.set(securityContext); } public static SecurityContext get() { return tLocal.get(); } public static void remove() { tLocal.remove(); } } U can get the SecurityContext during the thread execution with: SecurityContextHolder.get() Let me know if u need something else On Tue, Jul 28, 2009 at 12:25 AM, Max Weißböck (info)m...@weissboeck.info wrote: Ok, I think I get the idea... But where and when do you set the ThreadLocal? It must be set on every request (each request is another thread...) Do you have a common base class where you handle this? Any other way you do it? Max Am 28.07.2009 um 00:08 schrieb Juan E. Maya: Hey Max, I had a similar problem and at the end create an object in the ThreadLocal that contains a SecurityContext with the user information (very lightweight object). The idea was taken from Spring-Security. This way u have access to the user in the execution thread. It was kind of weird for me to be accessing the HttpSession in all the layers of the application. On Mon, Jul 27, 2009 at 11:18 PM, Max Weißböck (info)m...@weissboeck.info wrote: Sorry, my question seems not to be clear. It is not a Hibernate question, I now how to acces and set the attributes using the event. I already set the creation and modification date in each entity. But what I need too, is who (which user) did the creation/ modification of an entity. This information (the user) is in an SSO (WebUser in my case) but I could not figure out, how I can get access to this SSO from the Hibernate Listener Class. thx, Max Am 27.07.2009 um 22:42 schrieb Igor Drobiazko: This is a Hibernate question, not Tapestry. Have a look into the event passed to your listener. There is a method called getEntity(). On Mon, Jul 27, 2009 at 10:34 PM, Max Weißböck (info) m...@weissboeck.infowrote: I'm using Hibernate Listeners PreUpdateEventListener and PreInsertEventListener to do audit logging in the DB. Now my problem is, how can I get access in the EventListenr class to the SSO where the user is stored? As Hibernate loads the classes as defined in the config file (see below), I can not bind them using AppModule and @Inject something - or at least I do not know how. I searched the list but found no solution (or did not understand it ;-) Thx, Max --- definition in hibernate.cfg.xml --- !-- Audit Listener -- listener type=pre-insert class=net.weissboeck.gimmo.entities.AuditListenerImpl/ listener type=pre-update class=net.weissboeck.gimmo.entities.AuditListenerImpl/ -- Best regards, Igor Drobiazko - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Audit logging - how to acces SSO in Hibernate
Thanks very much, works perfect! I owe you some beers, so if you come to Vienna sometimes Max Am 29.07.2009 um 10:33 schrieb Juan E. Maya: U have to create a binding for the request filter. Just add in the bind method of ur module something like: binder.bind(PageRenderRequestFilter.class, SecurityContextPageRenderRequestFilter .class).withId(securityContextPageRenderRequestFilter); On Wed, Jul 29, 2009 at 9:51 AM, Max Weißböck (info)m...@weissboeck.info wrote: Hi Juan, thanks very much! I'm using Chenillekit Acess too, so just tried it but I'm having a little problem. Must be something obvious I can't see I put all your classes in the services directory. The only thing I changed is RincoSessionUser to my own WebUser class. On first access to Appliction I'm getting the following error: [ERROR] ioc.Registry Service id 'securityContextPageRenderRequestFilter' isa not defined by any module. Defined services: AccessValidator, ActionRenderResponseGenerator, AdminService, [ERROR] ioc.Registry Operations trace: [ERROR] ioc.Registry [ 1] Realizing service PageRenderRequestHandler [ERROR] ioc.Registry [ 2] Invoking org .apache .tapestry5 .services.TapestryModule.buildPageRenderRequestHandler(List, Logger, PageRenderRequestHandlerImpl) (at TapestryModule.java:1415) [ERROR] ioc.Registry [ 3] Determining injection value for parameter #1 (java.util.List) [ERROR] ioc.Registry [ 4] Collecting ordered configuration for service PageRenderRequestHandler [ERROR] ioc.Registry [ 5] Invoking method net .weissboeck .gimmo .services .AppModule.contributePageRenderRequestHandler(OrderedConfiguration, PageRenderRequestFilter) (at AppModule.java:227). [ERROR] ioc.Registry [ 6] Determining injection value for parameter #2 (org.apache.tapestry5.services.PageRenderRequestFilter) [ERROR] TapestryModule.PageRenderRequestHandler Construction of service PageRenderRequestHandler failed: Error invoking service builder method org .apache .tapestry5 .services.TapestryModule.buildPageRenderRequestHandler(List, Logger, PageRenderRequestHandlerImpl) (at TapestryModule.java:1415) (for service 'PageRenderRequestHandler'): Error invoking service contribution method net .weissboeck .gimmo .services .AppModule.contributePageRenderRequestHandler(OrderedConfiguration, PageRenderRequestFilter): Service id 'securityContextPageRenderRequestFilter' is not defined by any module. Defined services: AccessValidator, ActionRenderResponseGenerator, AdminService, ... java.lang.RuntimeException: Error invoking service builder method org .apache .tapestry5 .services.TapestryModule.buildPageRenderRequestHandler(List, Logger, PageRenderRequestHandlerImpl) (at TapestryModule.java:1415) (for service 'PageRenderRequestHandler'): Error invoking service contribution method net .weissboeck .gimmo .services .AppModule.contributePageRenderRequestHandler(OrderedConfiguration, PageRenderRequestFilter): Service id 'securityContextPageRenderRequestFilter' is not defined by any module. Defined services: AccessValidator, ActionRenderResponseGenerator, AdminService, .. at org .apache .tapestry5 .ioc .internal .ServiceBuilderMethodInvoker .createObject(ServiceBuilderMethodInvoker.java:76) at org.apache.tapestry5.ioc.internal.OperationTrackingObjectCreator $1.invoke(OperationTrackingObjectCreator.java:45) at org .apache .tapestry5 .ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java: 68) at org .apache .tapestry5 .ioc .internal .PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:68) at org .apache .tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:941) at org .apache .tapestry5 .ioc .internal .OperationTrackingObjectCreator .createObject(OperationTrackingObjectCreator.java:49) at org .apache .tapestry5 .ioc .internal .SingletonServiceLifecycle .createService(SingletonServiceLifecycle.java:29) at org .apache .tapestry5 .ioc .internal .LifecycleWrappedServiceCreator .createObject(LifecycleWrappedServiceCreator.java:46) Am 28.07.2009 um 01:06 schrieb Juan E. Maya: What i am doing is to contribute a PageRenderRequestHandler like this: public static void contributePageRenderRequestHandler (OrderedConfigurationPageRenderRequestFilter configuration, final @Local @InjectService(securityContextPageRenderRequestFilter) PageRenderRequestFilter securityContextPageRenderRequestFilter) { configuration.add(securityContext, securityContextPageRenderRequestFilter, after:*); } I am using Chenillekit's access component: (http://www.chenillekit.org/chenillekit-access/index.html) so in the filter i get the WebSessionUser using the ApplicationStateManager. Here u should get the object from the session. Just be sure that the filter is executed after the WebSessionUser is put into the session
Re: How to use JavaScript for dependent selects?
I had the very same problem, here is the solution I have (with great help from the list - search for it) --- java part --- selection model as found in T5 HowTos in the wicki and with event definition from Chenillekit--- @IncludeJavaScriptLibrary( { context:js/Chenillekit.js, context:js/ RESelection.js }) public class Index { @InjectSelectionModel(labelField = name, idField = oid) @Persist private ListREType reTypes; @InjectSelectionModel(labelField = name, idField = oid) @Persist private ListRESubType reSubTypes; @Component(parameters = {event=change, onCompleteCallback=literal:onCompleteChangeReSubType}) @Mixins({ck/OnEvent}) private Select reType; @Log @OnEvent(component=reType, value=change) public JSONArray onChangeRETypeEvent(String value) { JSONArray jsonArray = new JSONArray(); // Tapestry cant handle the empty first field for us in this situation reSubTypes = dataService .getRESubTypesWithFirstEmpty (dataService.loadREType(Long.parseLong(value))); query.setReSubType(reSubTypes.get(0)); for (RESubType subType : reSubTypes) { JSONObject jo = new JSONObject(); jo.put(value, subType.getOid()); jo.put(label, subType.getName()); jsonArray.put(jo); } return jsonArray; } --- tml part --- t:label for=retype/ select t:type=select t:id=retype value=query.retype model=reTypesSelectionModel encoder=reTypesValueEncoder validate=required/ t:label for=resubtype/ select t:type=select t:id=resubtype value=query.resubtype model=reSubTypesSelectionModel encoder=reSubTypesValueEncoder/ javascript part --- function onCompleteChangeReSubType(response) { selectElement = $('resubtype'); while (selectElement.options.length 0) { selectElement.options[0] = null; } for (index = 0; index response.length; index++) { if (index == 0) { selectElement.options[index] = new Option(response[index].label, response[index].value, true, true); } else { selectElement.options[index] = new Option(response[index].label, response[index].value); } } //Tapestry.ElementEffect.highlight($(resubtype)); } hope this helps, Max Am 26.07.2009 um 20:16 schrieb sparqle: All, I know Java and have been using pure Java frameworks like ZK and Echo2 to develop web applications. I don't know anything about JavaScript, and have been trying to learn T5 in the hope of creating a real application. However, it appears that with T5 I am not completely shielded from JavaScript (may be I can do this in pure Java?) if I want to do AJAX. The specific example that I want to implement is the classic 2 dropdown - the second one dependent on the first one. So let's say you select a country, and the in the second dropdown, the list of states/provinces is updated to match what is available for the country selected in the first dropdown. From the forums, I have gathered that I must use the Chenille Kit onEvent mixin to make this happen. I also saw some sample codes in the forums that appear to solve this exact issue. The problem is that I don't know where to put this code (in Java file or tml file or some other js file) and then how to tie these things together. In the T5 help documentation, there is some info about using RenderSupport for this. Again, the code given is only snippets with no complete example that I can download/copy. I could not understand this documentation at all. So my question is simple: where should this code be located and how are all these things connected? Is there anything else that needs to be added - such as RenderSupport (and where)? select t:id=operator t:type=select t:mixins=commons/onEvent t:event=change t:onCompleteCallback=onCompleteOperatorChange .../ --- @OnEvent(component = operator, value = change) public JSONArray onChangeOperatorEvent(String value) { JSONArray jsonArray = new JSONArray(); for (Plaza plaza : getDestinationSelectValues(value)) { JSONObject jsonObject = new JSONObject(); jsonObject.put(value, plaza.getId()); jsonObject.put(label, plaza.getDescription()); jsonArray.put(jsonObject); } return jsonArray; } -- function onCompleteOperatorChange(response) { selectElement = $(entryPlaza); responseJSON = response.evalJSON(); while (selectElement .options.length 0) { selectElement .options[0] = null; } for (index = 0; index responseJSON .length; index++) { selectElement.options[index] = new
Re: Audit logging - how to acces SSO in Hibernate
Sorry, my question seems not to be clear. It is not a Hibernate question, I now how to acces and set the attributes using the event. I already set the creation and modification date in each entity. But what I need too, is who (which user) did the creation/modification of an entity. This information (the user) is in an SSO (WebUser in my case) but I could not figure out, how I can get access to this SSO from the Hibernate Listener Class. thx, Max Am 27.07.2009 um 22:42 schrieb Igor Drobiazko: This is a Hibernate question, not Tapestry. Have a look into the event passed to your listener. There is a method called getEntity(). On Mon, Jul 27, 2009 at 10:34 PM, Max Weißböck (info) m...@weissboeck.infowrote: I'm using Hibernate Listeners PreUpdateEventListener and PreInsertEventListener to do audit logging in the DB. Now my problem is, how can I get access in the EventListenr class to the SSO where the user is stored? As Hibernate loads the classes as defined in the config file (see below), I can not bind them using AppModule and @Inject something - or at least I do not know how. I searched the list but found no solution (or did not understand it ;-) Thx, Max --- definition in hibernate.cfg.xml --- !-- Audit Listener -- listener type=pre-insert class=net.weissboeck.gimmo.entities.AuditListenerImpl/ listener type=pre-update class=net.weissboeck.gimmo.entities.AuditListenerImpl/ -- Best regards, Igor Drobiazko - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Audit logging - how to acces SSO in Hibernate
Ok, I think I get the idea... But where and when do you set the ThreadLocal? It must be set on every request (each request is another thread...) Do you have a common base class where you handle this? Any other way you do it? Max Am 28.07.2009 um 00:08 schrieb Juan E. Maya: Hey Max, I had a similar problem and at the end create an object in the ThreadLocal that contains a SecurityContext with the user information (very lightweight object). The idea was taken from Spring-Security. This way u have access to the user in the execution thread. It was kind of weird for me to be accessing the HttpSession in all the layers of the application. On Mon, Jul 27, 2009 at 11:18 PM, Max Weißböck (info)m...@weissboeck.info wrote: Sorry, my question seems not to be clear. It is not a Hibernate question, I now how to acces and set the attributes using the event. I already set the creation and modification date in each entity. But what I need too, is who (which user) did the creation/ modification of an entity. This information (the user) is in an SSO (WebUser in my case) but I could not figure out, how I can get access to this SSO from the Hibernate Listener Class. thx, Max Am 27.07.2009 um 22:42 schrieb Igor Drobiazko: This is a Hibernate question, not Tapestry. Have a look into the event passed to your listener. There is a method called getEntity(). On Mon, Jul 27, 2009 at 10:34 PM, Max Weißböck (info) m...@weissboeck.infowrote: I'm using Hibernate Listeners PreUpdateEventListener and PreInsertEventListener to do audit logging in the DB. Now my problem is, how can I get access in the EventListenr class to the SSO where the user is stored? As Hibernate loads the classes as defined in the config file (see below), I can not bind them using AppModule and @Inject something - or at least I do not know how. I searched the list but found no solution (or did not understand it ;-) Thx, Max --- definition in hibernate.cfg.xml --- !-- Audit Listener -- listener type=pre-insert class=net.weissboeck.gimmo.entities.AuditListenerImpl/ listener type=pre-update class=net.weissboeck.gimmo.entities.AuditListenerImpl/ -- Best regards, Igor Drobiazko - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: having big trouble with evalJSON() - am I really at war with it?
Thanks so much, you really saved my day! Am 23.07.2009 um 17:18 schrieb Sven Homburg: dont use the evanJSON() function, its not needed anymore with regards Sven Homburg Founder of the Chenille Kit Project http://www.chenillekit.org 2009/7/23 Max Weißböck (info) m...@weissboeck.info: Based on the example from Hugo Palma (see http://markmail.org/message/4bdwo2yrx6tavdgh) I implemented a dependend checkbox. Event handling is fine, but I lost hours finding out while response.evalJSON() fails and I still have no clue... Im always getting this erreor; Error communication with the server: Result of expression 'response.evalJSON' [undefined] is not a function. Looks like evalJSON ist not defined (I'm not a JavaScript guy at all) How do I import the js library that includes the evalJSON function? I tried everithing I can think of and this is my current js import @IncludeJavaScriptLibrary( { context:js/Chenillekit.js, context:js/RESelection.js, ${tapestry.scriptaculous}/ prototype.js }) public class RealEstateCreate { Any help is VERY welcome, as I'm at a dead end now Thanks, Max This are the js, tml and class files -- RESelection.js - function onCompleteChangeReSubType(response) { selectElement = $('resubtype'); Tapestry.debug(response); Tapestry.debug(1); responseJSON = response.evalJSON(); Tapestry.debug(2); while (selectElement.options.length 0) { selectElement.options[0] = null; } for (index = 0; index responseJSON.length; index++) { selectElement.options[index] = new Option(responseJSON [index].label, responseJSON [index].value); } Tapestry.ElementEffect.highlight($(resubtype)); } class--- - tml RealEstateCreate.tml html t:type=layout title=message:pagename sidebarTitle=message:sidebarTitle xmlns:t=http://tapestry.apache.org/schema/tapestry_5_1_0.xsd; xmlns:p=tapestry:parameter t:form t:id=form class=yform t:errors/ div class=type-text t:label for=title/ t:textfield t:id=title value=realestate.title validate=required/ /div t:label for=retype/ select t:type=select t:id=retype value=realestate.retype model=reTypesSelectionModel encoder=reTypesValueEncoder validate=required/ t:label for=resubtype/ select t:type=select t:id=resubtype value=realestate.resubtype model=reSubTypesSelectionModel encoder=reSubTypesValueEncoder validate=required/ t:ybeaneditor t:id=realestate exclude=title p:description t:label for=description/ t:textarea t:id=description value=realestate.description/ /p:description /t:ybeaneditor div class=type-button input type=submit value=Anlegen/ /div /t:form t:if test=message div class=info ${message} /div /t:if p:sidebar div class=menue-box t:agentmenu/ /div /p:sidebar /html class RealEstateCreate.java -- package net.weissboeck.gimmo.pages.realestate; import java.util.List; import net.weissboeck.gimmo.annotations.InjectSelectionModel; import net.weissboeck.gimmo.beans.WebUser; import net.weissboeck.gimmo.entities.Agent; import net.weissboeck.gimmo.entities.RESubType; import net.weissboeck.gimmo.entities.REType; import net.weissboeck.gimmo.entities.RealEstate; import net.weissboeck.gimmo.services.DataService; import net.weissboeck.gimmo.services.RealEstateService; import net.weissboeck.gimmo.services.UserService; import net.weissboeck.gimmo.util.ExceptionParser; import org.apache.tapestry5.PersistenceConstants; import org.apache.tapestry5.annotations.Component; import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary; import org.apache.tapestry5.annotations.InjectPage; import org.apache.tapestry5.annotations.Log; import org.apache.tapestry5.annotations.Mixins; import org.apache.tapestry5.annotations.OnEvent; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.annotations.SessionState; import org.apache.tapestry5.corelib.components.Form; import org.apache.tapestry5.corelib.components.Select; import org.apache.tapestry5.ioc.annotations.Inject; import org.apache.tapestry5.json.JSONArray; import org.apache.tapestry5.json.JSONObject; import org.chenillekit.access.annotations.Restricted; import org.slf4j.Logger; @Restricted(groups = { AGENT }) @IncludeJavaScriptLibrary( { context:js/Chenillekit.js, context:js/RESelection.js, ${tapestry.scriptaculous}/ prototype.js }) public class RealEstateCreate { @Inject private Logger logger; @SessionState private WebUser webUser; @Component private
T5 Hibernate listener crash problem - problem with classloader?
If I configuer my AuditListener in the hibernate.cfg.xml file like this listener type=pre-insert class=net.weissboeck.gimmo.entities.AuditListener/ im getting the following error after first acces to database: [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: Exception constructing service 'ValueEncoderSource': Error invoking service builder method org .apache.tapestry5.services.TapestryModule.buildValueEncoderSource(Map, InvalidationEventHub) (at TapestryModule.java:1910) (for service 'ValueEncoderSource'): Error invoking service contribution method org .apache .tapestry5 .hibernate .HibernateModule.contributeValueEncoderSource(MappedConfiguration, boolean, HibernateSessionSource, Session, TypeCoercer, PropertyAccess, LoggerSource): Exception constructing service 'HibernateSessionSource': Error invoking service builder method org .apache .tapestry5 .hibernate.HibernateCoreModule.buildHibernateSessionSource(Logger, List, RegistryShutdownHub) (at HibernateCoreModule.java:123) (for service 'HibernateSessionSource'): Unable to instantiate specified event (pre-insert) listener class: net.weissboeck.gimmo.entities.AuditListener Debugging seems to indicate a problem with the classloader. Has anyone got hibernate listeners working with T5 hibernate module? This is my AuditListener class (I use a common abstract base entity with alle the technical and audit data for all my entities) package net.weissboeck.gimmo.entities; import java.util.Date; import org.hibernate.event.PreUpdateEvent; import org.hibernate.event.PreUpdateEventListener; public class AuditListener implements PreUpdateEventListener { private static final long serialVersionUID = 1L; @Override public boolean onPreUpdate(PreUpdateEvent pEvent) { AbstractBaseEntity entity = (AbstractBaseEntity) pEvent.getEntity(); entity.setLastUpdated(new Date()); return false; } } - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org