Re: How to resolve right path for variable images (with Jetty)
Use ByteArrayResource instead that loads the image's bytes from wherever you need. On Wed, Dec 26, 2012 at 2:54 PM, Delange delan...@telfort.nl wrote: In my webapplication a user can upload images. They are displayed on other pages. When I start the application with Jetty from the Eclipse directory, all images are stored directly under the project folder. But when I want to display them, they must be under src/main/webapp/ The is caused by the ContextRelativeResource. If I don't use this it doesn't work Has anyone a solution for this strange effect? My directory structure in eclipse is: mywebapplication images photos pic001.jpg src main java ... resources ... webapp images photo pic001.jpg -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-resolve-right-path-for-variable-images-with-Jetty-tp4655058.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 -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com http://jweekend.com/
Re: Attempting to establish session for static resources in Wicket 6
The improvement made by Sven has been introduced earlier with 7beaa9f and later reverted because of https://issues.apache.org/jira/browse/WICKET-4500 (7a86fe3) I.e. WICKET-4500 should be valid again. @Chris Colman: Please retest it. On Mon, Dec 24, 2012 at 2:09 AM, Chris Colman chr...@stepaheadsoftware.comwrote: Ah excellent! Thanks Sven. I was thinking about the creation of a simple test to be added to the test suite that would override WebApplication#newSession and then make a request for a static resource and then throw an exception if newSession gets called. This would help trap any future regression of this issue. Hi Chris, as already written, these are temporary sessions that should do no harm. Nevertheless I've added a check into RestartResponseAtInterceptPageException#InterceptData (which probes every request to be able to restore post parameters from before an intercept page) whether a session exists: public static InterceptData get() { - return Session.get().getMetaData(key); + if (Session.exists()) + { + return Session.get().getMetaData(key); + } + return null; } Your particular stacktrace below should no longer trigger the creation of a session now. Sven On 12/23/2012 02:05 PM, Chris Colman wrote: A while ago when working with Wicket 1.5 we raised issue 4334 that dealt with the problem of jsessoin ID's being present in static resource URLs for the initial request and this issue was fixed. Not requiring jsession ID in the URL meant there was no reason to ever establish a session during requests for static resources i.e. WebApplication#newSession was never called for static resource requests. This worked very well but we've just discovered that in Wicket 6, even though the URLs for static resources do not contain jsessionIDs there is some code that is calling getSession - unnecessarily we believe (we hope =] ). Is there any reason why WebApplicatoin#newSession is called when no session is required to service the static request? If not it would be great if that call could be avoided. Calling WebApplication#newSession on static resources becomes a problem when you employ OpenSessionInView/OpenPersistenceManagerInView by using a filter to wrap all Wicket requests within the context of an open persistence session/manager. To optimize performance we use an 'ignore list' that avoids wrapping the request if it is for a resource that starts with a particular pattern (eg., /wicket/resource,/robots.txt) We override WebApplication#newSession and do some fancy things whenever a new session is established - this is intended for non static resource requests. Some of this code assumes that there is an OpenSessionInView - which fails in the case of static resources because their URLs are part of the ignore list and so the request was not wrapped within an open persistence session/manager. I was hoping that Wicket 6 could be fixed to avoid the call to newSession like Wicket 1.5 did after the resolution of 4334. Here's a stack trace of a call that is servicing a request for a wicket static resource: 2012/12/23 23:16:24.607 ERROR - DefaultExceptionMapper - unexpected exception when handling another exception: null java.lang.NullPointerException at com.sas.av.model.context.EServerContext.establishSiteVisitorForCrawler(E ServerContext.java:3055) at com.sas.av.model.context.EServerContext.initSession(EServerContext.java: 3585) at com.sas.av.ui.wicket.templates.WicketModelExposerApplication.newSession( WicketModelExposerApplication.java:148) at org.apache.wicket.Application.fetchCreateAndSetSession(Application.java: 1557) at org.apache.wicket.Session.get(Session.java:152) at org.apache.wicket.RestartResponseAtInterceptPageException$InterceptData. get(RestartResponseAtInterceptPageException.java:146) at org.apache.wicket.RestartResponseAtInterceptPageException$1.matchedData( RestartResponseAtInterceptPageException.java:211) at org.apache.wicket.RestartResponseAtInterceptPageException$1.getCompatibi lityScore(RestartResponseAtInterceptPageException.java:179) at org.apache.wicket.request.mapper.CompoundRequestMapper.mapRequest(Compou ndRequestMapper.java:138) at org.apache.wicket.request.cycle.RequestCycle.resolveRequestHandler(Reque stCycle.java:183) at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle .java:208) at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(Req uestCycle.java:282) at
Wicket integration with Spring
I am making an application in which I want to integrate Wicket + Spring. Application is a grocery store on which user comes and buy something. I know there are two ways to do this. 1. Using the *annotation *aprroach. Wicket-Spring integration shows various ways on how to inject Spring Beans into Wicket pages. public class FormPage extends WebPage { @SpringBean private IContact icontact; ... Form form = new Form(contactForm, new CompoundPropertyModel(contact)) { private static final long serialVersionUID = 1L; protected void onSubmit(Contact contact) { icontact.saveContact(contact); } }; 2. The @SpringBean is of course valid and considered a best practice by many. But there is also *another approach*, where your Wicket Application has the services you need. public class YourWicketApp extends WebApplication{ public static YourWicketApp get(){ return (YourWicketApp) Application.get(); } private ServiceA serviceA; // getter and setter for serviceA here } Now in your component, call YourWicketApp.get().getServiceA(); I want to know which is the best way to integrate spring with wicket. /However as far as I remember Wicket pages and components aren't managed by Spring container so you cannot use @Transactional annotation on them (which is a bad idea anyway - transactions belong to deeper levels)./ *Is this statement valid?* -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-integration-with-Spring-tp4655077.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: Wicket integration with Spring
Hi, There is also https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/wicketstuff-springreference-parent / https://github.com/wicketstuff/core/wiki/SpringReference On Thu, Dec 27, 2012 at 12:11 PM, Arun Chauhan arundraj...@gmail.comwrote: I am making an application in which I want to integrate Wicket + Spring. Application is a grocery store on which user comes and buy something. I know there are two ways to do this. 1. Using the *annotation *aprroach. Wicket-Spring integration shows various ways on how to inject Spring Beans into Wicket pages. public class FormPage extends WebPage { @SpringBean private IContact icontact; ... Form form = new Form(contactForm, new CompoundPropertyModel(contact)) { private static final long serialVersionUID = 1L; protected void onSubmit(Contact contact) { icontact.saveContact(contact); } }; 2. The @SpringBean is of course valid and considered a best practice by many. But there is also *another approach*, where your Wicket Application has the services you need. public class YourWicketApp extends WebApplication{ public static YourWicketApp get(){ return (YourWicketApp) Application.get(); } private ServiceA serviceA; // getter and setter for serviceA here } Now in your component, call YourWicketApp.get().getServiceA(); I want to know which is the best way to integrate spring with wicket. I prefer @SpringBean because with approach 2) you tie every component with this specific implementation of WebApplication. So you cannot reuse this component in another application, and your WicketTester tests will need to setup the whole application to be able to run. With approach 1) you need just to make ServiceA available for the test of a given component. /However as far as I remember Wicket pages and components aren't managed by Spring container so you cannot use @Transactional annotation on them (which is a bad idea anyway - transactions belong to deeper levels)./ *Is this statement valid?* Yes. Better create a Spring bean that cares about the transactions. Something like: WicketComponent uses ServiceBean delegatesTo RepositoryBean -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-integration-with-Spring-tp4655077.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 -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com http://jweekend.com/
Re: Attempting to establish session for static resources in Wicket 6
Sorry, I wasn't aware of this back and forth. It's not clear to me how 7a86fe3 'fixed' WICKET-4500 though: If there's no session, how does it help to create one and then looking for non-present meta data? Sven On 12/27/2012 09:55 AM, Martin Grigorov wrote: The improvement made by Sven has been introduced earlier with 7beaa9f and later reverted because of https://issues.apache.org/jira/browse/WICKET-4500 (7a86fe3) I.e. WICKET-4500 should be valid again. @Chris Colman: Please retest it. On Mon, Dec 24, 2012 at 2:09 AM, Chris Colman chr...@stepaheadsoftware.comwrote: Ah excellent! Thanks Sven. I was thinking about the creation of a simple test to be added to the test suite that would override WebApplication#newSession and then make a request for a static resource and then throw an exception if newSession gets called. This would help trap any future regression of this issue. Hi Chris, as already written, these are temporary sessions that should do no harm. Nevertheless I've added a check into RestartResponseAtInterceptPageException#InterceptData (which probes every request to be able to restore post parameters from before an intercept page) whether a session exists: public static InterceptData get() { - return Session.get().getMetaData(key); + if (Session.exists()) + { + return Session.get().getMetaData(key); + } + return null; } Your particular stacktrace below should no longer trigger the creation of a session now. Sven On 12/23/2012 02:05 PM, Chris Colman wrote: A while ago when working with Wicket 1.5 we raised issue 4334 that dealt with the problem of jsessoin ID's being present in static resource URLs for the initial request and this issue was fixed. Not requiring jsession ID in the URL meant there was no reason to ever establish a session during requests for static resources i.e. WebApplication#newSession was never called for static resource requests. This worked very well but we've just discovered that in Wicket 6, even though the URLs for static resources do not contain jsessionIDs there is some code that is calling getSession - unnecessarily we believe (we hope =] ). Is there any reason why WebApplicatoin#newSession is called when no session is required to service the static request? If not it would be great if that call could be avoided. Calling WebApplication#newSession on static resources becomes a problem when you employ OpenSessionInView/OpenPersistenceManagerInView by using a filter to wrap all Wicket requests within the context of an open persistence session/manager. To optimize performance we use an 'ignore list' that avoids wrapping the request if it is for a resource that starts with a particular pattern (eg., /wicket/resource,/robots.txt) We override WebApplication#newSession and do some fancy things whenever a new session is established - this is intended for non static resource requests. Some of this code assumes that there is an OpenSessionInView - which fails in the case of static resources because their URLs are part of the ignore list and so the request was not wrapped within an open persistence session/manager. I was hoping that Wicket 6 could be fixed to avoid the call to newSession like Wicket 1.5 did after the resolution of 4334. Here's a stack trace of a call that is servicing a request for a wicket static resource: 2012/12/23 23:16:24.607 ERROR - DefaultExceptionMapper - unexpected exception when handling another exception: null java.lang.NullPointerException at com.sas.av.model.context.EServerContext.establishSiteVisitorForCrawler(E ServerContext.java:3055) at com.sas.av.model.context.EServerContext.initSession(EServerContext.java: 3585) at com.sas.av.ui.wicket.templates.WicketModelExposerApplication.newSession( WicketModelExposerApplication.java:148) at org.apache.wicket.Application.fetchCreateAndSetSession(Application.java: 1557) at org.apache.wicket.Session.get(Session.java:152) at org.apache.wicket.RestartResponseAtInterceptPageException$InterceptData. get(RestartResponseAtInterceptPageException.java:146) at org.apache.wicket.RestartResponseAtInterceptPageException$1.matchedData( RestartResponseAtInterceptPageException.java:211) at org.apache.wicket.RestartResponseAtInterceptPageException$1.getCompatibi lityScore(RestartResponseAtInterceptPageException.java:179) at org.apache.wicket.request.mapper.CompoundRequestMapper.mapRequest(Compou ndRequestMapper.java:138) at org.apache.wicket.request.cycle.RequestCycle.resolveRequestHandler(Reque stCycle.java:183) at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle
Re: Attempting to establish session for static resources in Wicket 6
I don't remember the details now. Chris confirmed privately that he will re-test his scenario. I'll be able to take a look at this soon. On Thu, Dec 27, 2012 at 12:50 PM, Sven Meier s...@meiers.net wrote: Sorry, I wasn't aware of this back and forth. It's not clear to me how 7a86fe3 'fixed' WICKET-4500 though: If there's no session, how does it help to create one and then looking for non-present meta data? Sven On 12/27/2012 09:55 AM, Martin Grigorov wrote: The improvement made by Sven has been introduced earlier with 7beaa9f and later reverted because of https://issues.apache.org/** jira/browse/WICKET-4500https://issues.apache.org/jira/browse/WICKET-4500 (7a86fe3) I.e. WICKET-4500 should be valid again. @Chris Colman: Please retest it. On Mon, Dec 24, 2012 at 2:09 AM, Chris Colman chr...@stepaheadsoftware.com**wrote: Ah excellent! Thanks Sven. I was thinking about the creation of a simple test to be added to the test suite that would override WebApplication#newSession and then make a request for a static resource and then throw an exception if newSession gets called. This would help trap any future regression of this issue. Hi Chris, as already written, these are temporary sessions that should do no harm. Nevertheless I've added a check into RestartResponseAtInterceptPage**Exception#InterceptData (which probes every request to be able to restore post parameters from before an intercept page) whether a session exists: public static InterceptData get() { - return Session.get().getMetaData(key)**; + if (Session.exists()) + { + return Session.get().getMetaData(key)** ; + } + return null; } Your particular stacktrace below should no longer trigger the creation of a session now. Sven On 12/23/2012 02:05 PM, Chris Colman wrote: A while ago when working with Wicket 1.5 we raised issue 4334 that dealt with the problem of jsessoin ID's being present in static resource URLs for the initial request and this issue was fixed. Not requiring jsession ID in the URL meant there was no reason to ever establish a session during requests for static resources i.e. WebApplication#newSession was never called for static resource requests. This worked very well but we've just discovered that in Wicket 6, even though the URLs for static resources do not contain jsessionIDs there is some code that is calling getSession - unnecessarily we believe (we hope =] ). Is there any reason why WebApplicatoin#newSession is called when no session is required to service the static request? If not it would be great if that call could be avoided. Calling WebApplication#newSession on static resources becomes a problem when you employ OpenSessionInView/**OpenPersistenceManagerInView by using a filter to wrap all Wicket requests within the context of an open persistence session/manager. To optimize performance we use an 'ignore list' that avoids wrapping the request if it is for a resource that starts with a particular pattern (eg., /wicket/resource,/robots.txt) We override WebApplication#newSession and do some fancy things whenever a new session is established - this is intended for non static resource requests. Some of this code assumes that there is an OpenSessionInView - which fails in the case of static resources because their URLs are part of the ignore list and so the request was not wrapped within an open persistence session/manager. I was hoping that Wicket 6 could be fixed to avoid the call to newSession like Wicket 1.5 did after the resolution of 4334. Here's a stack trace of a call that is servicing a request for a wicket static resource: 2012/12/23 23:16:24.607 ERROR - DefaultExceptionMapper - unexpected exception when handling another exception: null java.lang.NullPointerException at com.sas.av.model.context.**EServerContext.** establishSiteVisitorForCrawler**(E ServerContext.java:3055) at com.sas.av.model.context.**EServerContext.initSession(** EServerContext.java: 3585) at com.sas.av.ui.wicket.**templates.**WicketModelExposerApplication.** newSession( WicketModelExposerApplication.**java:148) at org.apache.wicket.Application.**fetchCreateAndSetSession(** Application.java: 1557) at org.apache.wicket.Session.get(**Session.java:152) at org.apache.wicket.**RestartResponseAtInterceptPage** Exception$InterceptData. get(**RestartResponseAtInterceptPage**Exception.java:146) at org.apache.wicket.**RestartResponseAtInterceptPage** Exception$1.matchedData( RestartResponseAtInterceptPage**Exception.java:211) at
Re: @SpringBean issue in CustomValidator
Only Component and Behavior instances support auto-inject. You need to call: Injector.get().inject(this) in the constructor of any other type. On Thu, Dec 27, 2012 at 12:56 PM, wicket_new_user murthy.m...@gmail.comwrote: Hi, i've written a new custom validator and trying to Inject one bean which is resulting in an error org.apache.wicket.WicketRuntimeException: Exception 'null' occurred during validation com.foo.CustomNameValidation on component 3:report:name My piece of code is below public class CustomNameValidation implements IValidatorString { @SpringBean private IReportDAO reportDAO; @Override public void validate(IValidatableString validatable) { final String reportName = validatable.getValue(); if (*/reportDAO/*.findByReportName(reportName) 0L) { validatable.error(new ValidationError().addMessageKey(reportNameAlreadyExists)); } } } == I'm unable to understand what is missing from the above to get the reportDAO as null thanks -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/SpringBean-issue-in-CustomValidator-tp4655081.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 -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com http://jweekend.com/
Re: Parsing company id from url
Sebastian, That makes a lot of sense. I think I like that solution better because it seems simpler and more intuitive. I may write a ServletFilter that does the app lookup part and store it in the session. Thanks a lot! Josh -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Parsing-company-id-from-url-tp4655029p4655086.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
Updating a self-made Panel
Hey there, my self-made video-class (extending Panel) doesnt get updated, if its model changes. I got a Class ClassA, which gets new Information through a Model, whenever i select a choice in a List on my Webpage. That already works. In this Class A, there is a MultiLineLabel, which gets perfectly updated, showing a descreption depending on which choice is selected on the website. Also, in this Class A, there is my self-made Video-Class. It's called like this: Video test = new Video(myVideo, new ModelClassB(){ @Override public ClassB getObject() { if (ClassA.this.getModel().getObject() != null){ return ClassA.this.getModel().getObject(); } else return new ClassB(); } }); ClassB holds the Source of the VideoFile and some other Information. The Videosource is always Null, which means, though the MultiLineLabel gets the Updated Model of ClassA, the Video-Class doesnt get updated. Ive been searching through the internet for hours now, without finding anything helpful. Hope you guys are able to give me some solution to this problem. Thanks in regard. Greetings Benny -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Updating-a-self-made-Panel-tp4655087.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: How to resolve right path for variable images (with Jetty)
Do you have an example, also with html? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-resolve-right-path-for-variable-images-with-Jetty-tp4655058p4655088.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
Different root between upload folder and ContextRelativeResource
I have an application which can upload pictures. When I use the upload with Jetty in my Eclipse directory it stores all pictures under eclipseproject /images /src/main/webapp/images But if i want to display them with ContextRelativeResource then they must be in /src/main/webapp/images Upload command is Folder uploadFolder = new Folder(opdrachten/+input.getOpdrachtnummer(), ); for display i use String picture = opdrachten/+opdracht.getOpdrachtnummer()+/+file.getName(); logger.info(picture); Image image2 = new Image(image2,new ContextRelativeResource(picture)); What is wrong? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Different-root-between-upload-folder-and-ContextRelativeResource-tp4655089.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