Re: Excluding path from Wicket filter (to let 404 pass as-is)?
There's a parameter "ignorePaths" which you can configure in web.xml. See WicketFilter source. Christoph On 22.09.2012 10:07, Ondřej Žižka wrote: Hi, I have Wicket filter at /* and RESTEasy in AS 7, which is a servlet at /rest/* Wicket processes 404 because of WicketFilter /* REQUEST ERROR 404 /404 Now when I send 404 from a REST pojo, it's goes to Wicket as well. Which I don't want to - it's rest, So I'd like to keep it simple and minimal. What's the best way to solve this? web.xml doesn't offer much, so I guess it would be similar to this? https://cwiki.apache.org/WICKET/how-to-write-json-response.html if( ... path.contains("/rest/") requestCycle.getResponse().write(" ... "); Or is there some way to exclude some requests from being processed by Wicket from within? Thanks, Ondra - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket 1.5 migration questions
On 12.09.2012 22:50, Alec Swan wrote: I tested your implementation and was able to pull global/css/styles.css from the browser. However, the following code threw an exception: response.renderCSSReference(new MyPackageResourceReference(MyResources.class, "css/styles.css"), "screen"); Maybe you could simply use response.renderCSSReference( getRequest().getContextPath() + "/global/css/styles.css"); or is there a problem with it? Christoph - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket 1.5 migration questions
On 12.09.2012 21:38, Alec Swan wrote: PackageResourceReference IS-A ResourceReference and neither has a no-arg constructor. My point exactly. That's why I can't just do mountResource("/global", new MyRR()) as Martin suggested. My quick try: public class MyPackageResourceReference extends PackageResourceReference { private final String prefix; public MyPackageResourceReference(Class scope, String prefix) { super(scope, "dummy"); this.prefix = prefix; } @Override public String getName() { Request request = RequestCycle.get().getRequest(); String url = request.getUrl().toString(); if (!url.startsWith(prefix)) { throw new IllegalStateException(); } return url.substring(prefix.length()); } } Use it like: mountResource("/global", new MyPackageResourceReference(MyResources.class, "global/")); It needs to know where it is mounted so it can remove the prefix. Maybe there's a more elegant way around this but it works. Christoph - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to prevent duplicates when using HeaderContributor
Hi, the Javadoc of IHeaderResponse#renderString says: "Renders an arbitrary string to the header. The string is only rendered if the same string hasn't been rendered before." So if you call it with two different titles the expected behavior is to get the title tag twice. I wouldn't use a IHeaderResponse for that. My suggestion is to use a normal title tag in your base page markup. Provide a method which returns the current title and let specific pages override that method as needed. Christoph heikki (2012-05-03 15:10): hello, I'd like to be able to use a fixed title for my pages, that gets overridden for some of the pages. To do that, I have a fixed title element in my base HTML page: Then in the pages that should have a different title, I override renderHead() like this: @Override public void renderHead(final IHeaderResponse response) { String title = "" + getTheDynamicTitle() +""; response.renderString(title); } The result is that my rendered page has 2 elements in its header, the fixed one and the dynamic one. I would have thought that Wicket would be smart enough to replace an existing header element; the IHeaderResponse javadoc says "Implementation of this interface is responsible for filtering duplicate contributions (so that for example the same javascript is not loaded twice) during the same request". Well. Do I need to write my own implementation of IHeaderResponse for this ? It would seem like a pretty common use case to me, did anyone already solve it ? Kind regards Heikki Doeleman -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-prevent-duplicates-when-using-HeaderContributor-tp4605975.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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: force model update on a wicket form
That's because Component#setDefaultModelObject is called internally. It uses an IModelComparator to check whether the model object needs to be changed. The default implementation uses an Object#equals() check. So if the new value is equal to the old value it ignores the call. If you want another behavior (e.g. reference equality or to change it every time) then override Component#getModelComparator in your component to provide an appropriate IModelComparator. Christoph albgentius (2012-04-28 15:41): I've noticed that only when one of the component has changed value in the UI of a form, then wicket calls updateFormComponentModels. I was wondering if there is any way to force an update to the model of the components even if none of the form components has changed value. Thank you, Greg -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/force-model-update-on-a-wicket-form-tp4594765p4594765.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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: reloading of HTML and classes
You are right, I was able to reproduce it: https://issues.apache.org/jira/browse/WICKET-4509 Christoph On 20.04.2012 18:24, Andrew Geery wrote: An issue I ran into with having Wicket reload the html files in development mode is that it doesn't seem to work if the path to the html files has spaces in it. For example, running under Eclipse with the workspace in c:\Documents and Settings\... html reloading did not work. Taking the exact same configuration but putting the workspace directly on the c:\ drive (e.g., c:\workspace), the htm reloading works perfectly. Hope that helps. Andrew On Tue, Apr 10, 2012 at 2:45 AM, Martin Grigorovwrote: On Sun, Apr 8, 2012 at 5:38 AM, Bernard wrote: Hi, The HTML part is covered if your IDE copies HTML files to the deployment directory when you save them. Wicket will then pick up this change and reload the corresponding pages. This works for existing markup but not for new markup that was missing. https://github.com/wicketstuff/core/tree/master/jdk-1.7-parent/wicketstuff-wicket7 provides an extension of Wicket's default ModificationWatcher that uses JDK7 NIO2 WatchService. This should help for this problem. The Java classes part can only be handled with debugging, JRebel or a complete re-deployment. There is no hot-deployment of individual classes in GlassFish (I don't know whether any other server supports this). However GlassFish has session preservation so the re-deploy process is seamless. To further speed up the deployment, one can copy most libraries (including Wicket) into the GlassFish domain's lib dir instead of copying them on every deployment. The "Deploy on Save" feature is only useful for mini applications - it is too slow. Bernard On Fri, 06 Apr 2012 16:48:11 +0200, you wrote: I've been fighting this for the past two days, but I'm not succeeding. I'm using Wicket 1.5.5 on GlassFish 3.1.2 and that runs without a problem. I have configured org.apache.wicket.protocol.http.ReloadingWicketFilter to reload the classes, but that is not working. The only way to reload the class file is by using JRebel. Also Wicket reports that it runs in DEVELOPMENT mode, but it is not reloading the HTML files. In an attempting to resolve that I explicitely configured getResourceSettings().setDefaultCacheDuration(Duration.ONE_SECOND); but that does not make a difference. The only way I can get it to work somewhat, is to add my own ResourceFinder directly on the src folder: getResourceSettings().setResourceFinder(new IResourceFinder() { @Override public IResourceStream find(Class clazz, String pathname) { File f = new File("C:/Documents and Settings/User/My Documents/s2m/sources/components/service/src/main/java/" + pathname); if (f.exists()) { return new FileResourceStream( f ); } return null; } }); getResourceSettings().setUseDefaultOnMissingResource(true); But still the source are not reloaded reliably. I figure if the cache expires, a new call to the resource finder should be done, correct? Is there any debugging of these autoreload features, so I can see what Wicket is doing? Tom - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - 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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: reload model each time
On 14.04.2012 16:38, Emmanouil Batsis (Manos) wrote: On 04/14/2012 03:03 PM, Christoph Leiter wrote: Here's a good article about EntityModel, which does what you want: http://wicketinaction.com/2008/09/building-a-smart-entitymodel/ Sorry for jumping in but wanted to make sure I get this right. In the example given above, does it make sense to conditionally set the entity to null within detach() based on whether the object has been persisted (i.e. id != null in my case) or not? Sure, that's what happens in the last listing. :) My intention is to serialize the model object when that not yet persisted to handle multistep "create" forms etc., making this a generic model implementation for al my CRUD operations. Good idea. Just keep in mind that you can't use an EntityModel if the entity has already been persisted and if you want to change it with multiple ajax requests/multistep forms. It will lose any changes on every request. Simply serialize the entity again for that use case. Christoph - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: reload model each time
Here's a good article about EntityModel, which does what you want: http://wicketinaction.com/2008/09/building-a-smart-entitymodel/ Christoph Tom Eugelink (2012-04-14 13:38): Another newbie question; it is now the case that each model is serialized between requests and (I presume) stored in the session. I would really prefer if a identifier (primary key + lazy locking versionnr) could be remembered and that each time when Wicket needs the model, it is loaded from the database. Is this possible? Is there something like a ReloadingModel? Tom - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket with ServletContainerInitializer
Hi, I'll reply to my own message. :) Martin Grigorov figured out that Jetty doesn't install the DefaultServlet in this configuration. Without a servlet the WicketFilter cannot work. There's now new working sample code at https://issues.apache.org/jira/browse/WICKET-4350 Christoph Christoph Leiter (2012-04-03 12:55): Hi, I'm trying to use ServletContainerInitializer to start my wicket application. There's already work done to support this in WICKET-4350. It's not working for me, however. The filter is registered in jetty but I get a 404 response for every request. What I've done so far (starting from a quickstart): 1) Add dependency: org.eclipse.jetty.orbit:org.objectweb.asm:3.1.0.v200803061910 2) Delete web.xml 3) Create file META-INF/services/javax.servlet.ServletContainerInitializer with the content com.mycompany.Initializer 4) Add AnnotationConfiguration to the jetty configuration: bb.setConfigurations(new Configuration[] { new AnnotationConfiguration() }); 5) Add Initializer: | public class Initializer implements ServletContainerInitializer { | @Override | public void onStartup(Set> c, ServletContext servletContext) throws ServletException { | WicketApplication app = new WicketApplication(); | app.setConfigurationType(RuntimeConfigurationType.DEVELOPMENT); | WicketFilter wicketFilter = new WicketFilter(app); | wicketFilter.setFilterPath(""); | Dynamic filter = servletContext.addFilter("wicket", wicketFilter); | filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); | } | } That's the relevant part of the jetty debug log for the filter registration: | DEBUG - Container - Container org.eclipse.jetty.servlet.ServletHandler@78334ba0 + wicket as filter | DEBUG - Container - Container org.eclipse.jetty.servlet.ServletHandler@78334ba0 + [/*]/[]==31=>wicket as filterMapping | DEBUG - ServletHandler - filterNameMap={wicket=wicket} | DEBUG - ServletHandler - pathFilters=[[/*]/[]==31=>wicket] | DEBUG - ServletHandler - servletFilterMap={} | DEBUG - ServletHandler - servletPathMap=null | DEBUG - ServletHandler - servletNameMap={} | DEBUG - AbstractLifeCycle - starting wicket | DEBUG - WebAppClassLoader - loaded class org.apache.wicket.Initializer from sun.misc.Launcher$AppClassLoader@7981c4eb | INFO - Application - [wicket] init: Wicket core library initializer The log for a request to /: | DEBUG - Server - REQUEST / on BlockingHttpConnection@3c7352d1,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-5,l=18,c=0},r=1 | DEBUG - ContextHandler - scope null||/ @ o.e.j.w.WebAppContext{/,null},src/main/webapp | DEBUG - ContextHandler - context=||/ @ o.e.j.w.WebAppContext{/,null},src/main/webapp | DEBUG - session - sessionManager=org.eclipse.jetty.server.session.HashSessionManager@efc0830 | DEBUG - session - session=null | DEBUG - ServletHandler - servlet ||/ -> null | DEBUG - ServletHandler - chain=null | DEBUG - ServletHandler - Not Found / | DEBUG - Server - RESPONSE / 404 Environment is Wicket 1.5.5, jetty 8.1.2. I tried with Tomcat 7 as well but no luck either. Any help is appreciated Christoph - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Wicket with ServletContainerInitializer
Hi, I'm trying to use ServletContainerInitializer to start my wicket application. There's already work done to support this in WICKET-4350. It's not working for me, however. The filter is registered in jetty but I get a 404 response for every request. What I've done so far (starting from a quickstart): 1) Add dependency: org.eclipse.jetty.orbit:org.objectweb.asm:3.1.0.v200803061910 2) Delete web.xml 3) Create file META-INF/services/javax.servlet.ServletContainerInitializer with the content com.mycompany.Initializer 4) Add AnnotationConfiguration to the jetty configuration: bb.setConfigurations(new Configuration[] { new AnnotationConfiguration() }); 5) Add Initializer: | public class Initializer implements ServletContainerInitializer { |@Override | public void onStartup(Set> c, ServletContext servletContext) throws ServletException { | WicketApplication app = new WicketApplication(); | app.setConfigurationType(RuntimeConfigurationType.DEVELOPMENT); | WicketFilter wicketFilter = new WicketFilter(app); | wicketFilter.setFilterPath(""); | Dynamic filter = servletContext.addFilter("wicket", wicketFilter); | filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); | } | } That's the relevant part of the jetty debug log for the filter registration: | DEBUG - Container - Container org.eclipse.jetty.servlet.ServletHandler@78334ba0 + wicket as filter | DEBUG - Container - Container org.eclipse.jetty.servlet.ServletHandler@78334ba0 + [/*]/[]==31=>wicket as filterMapping | DEBUG - ServletHandler - filterNameMap={wicket=wicket} | DEBUG - ServletHandler - pathFilters=[[/*]/[]==31=>wicket] | DEBUG - ServletHandler - servletFilterMap={} | DEBUG - ServletHandler - servletPathMap=null | DEBUG - ServletHandler - servletNameMap={} | DEBUG - AbstractLifeCycle - starting wicket | DEBUG - WebAppClassLoader - loaded class org.apache.wicket.Initializer from sun.misc.Launcher$AppClassLoader@7981c4eb | INFO - Application- [wicket] init: Wicket core library initializer The log for a request to /: | DEBUG - Server - REQUEST / on BlockingHttpConnection@3c7352d1,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-5,l=18,c=0},r=1 | DEBUG - ContextHandler - scope null||/ @ o.e.j.w.WebAppContext{/,null},src/main/webapp | DEBUG - ContextHandler - context=||/ @ o.e.j.w.WebAppContext{/,null},src/main/webapp | DEBUG - session- sessionManager=org.eclipse.jetty.server.session.HashSessionManager@efc0830 | DEBUG - session- session=null | DEBUG - ServletHandler - servlet ||/ -> null | DEBUG - ServletHandler - chain=null | DEBUG - ServletHandler - Not Found / | DEBUG - Server - RESPONSE / 404 Environment is Wicket 1.5.5, jetty 8.1.2. I tried with Tomcat 7 as well but no luck either. Any help is appreciated Christoph - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Eclipse, Wicket 1.5 and Jrebel
Hi, do you use 1.5.4 with package resources? There's a bug that causes locked resources: https://issues.apache.org/jira/browse/WICKET-4359 Until 1.5.5 is released you can use 1.5.3, which is not affected by this bug. Christoph On 04.03.2012 10:29, Jürgen Lind wrote: Hi, I was just wondering if anybody is using the above combination. Since upgrading to 1.5. I have massive problems in reloading changed HTML templates as Eclipse sometimes tries to do a full build because of a locked resource. I am also in contact with the Jrebel guys, I just wanted to know if somebody else has a similar problem. J. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component specific JavaScript
Sure: $(document).ready(function() { Wicket.Event.subscribe('/dom/node/added', function(element) { $(element).css('border', '1px solid red'); }); }); On 19.02.2012 13:39, Jürgen Lind wrote: I'm not sure if I get you right on this one: the first argument of which event handler is the added element? Could you probably add some code to illustrate this? J. On 19.02.2012 13:28, Christoph Leiter wrote: Hi Juergen, there's actually no need to scan the full DOM with this method. :) The first argument of the event handler is the added element. You can simply use it as is or pass it to $() to do jQuery magic just for the relevant part. Christoph On 19.02.2012 13:18, Jürgen Lind wrote: Christoph, I have use yout approach (jQuery + css-class) for some time now as well. However, I have found that if the DOM tree grows rather large, a full scan puts significant load on the browser. That's why I want to be more specific and limit the scanning + updating to the relevant parts of the page. J. On 19.02.2012 13:02, Christoph Leiter wrote: On 18.02.2012 17:46, Jürgen Lind wrote: thank you for your reply, I did not know that such a method exists (does it for 1.4 or is this already Wicket 1.5). An secondly: are these handlers fired on a ajax update of an existing DOM Element or only when it is added? This is also available in 1.4. The events are fired when you add something to the ajax request via target.add(Component) And where would I put the Javascript that registers the handler? In the Markup-Page of the Component? How do I make sure, the handler is added only once? I use jQuery and register the handler globally in my main.js for every page within $(document).ready(). This approach works very well if you don't want to create subclasses of components but rather execute some specific JS if e.g. a css class is present. I use it to add a hint image to every autocomplete textfield via jQuery. If it's more component specific then the renderHead() solution seems better. Christoph - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org Mit freundlichen Grüßen, Jürgen Lind - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component specific JavaScript
Hi Juergen, there's actually no need to scan the full DOM with this method. :) The first argument of the event handler is the added element. You can simply use it as is or pass it to $() to do jQuery magic just for the relevant part. Christoph On 19.02.2012 13:18, Jürgen Lind wrote: Christoph, I have use yout approach (jQuery + css-class) for some time now as well. However, I have found that if the DOM tree grows rather large, a full scan puts significant load on the browser. That's why I want to be more specific and limit the scanning + updating to the relevant parts of the page. J. On 19.02.2012 13:02, Christoph Leiter wrote: On 18.02.2012 17:46, Jürgen Lind wrote: thank you for your reply, I did not know that such a method exists (does it for 1.4 or is this already Wicket 1.5). An secondly: are these handlers fired on a ajax update of an existing DOM Element or only when it is added? This is also available in 1.4. The events are fired when you add something to the ajax request via target.add(Component) And where would I put the Javascript that registers the handler? In the Markup-Page of the Component? How do I make sure, the handler is added only once? I use jQuery and register the handler globally in my main.js for every page within $(document).ready(). This approach works very well if you don't want to create subclasses of components but rather execute some specific JS if e.g. a css class is present. I use it to add a hint image to every autocomplete textfield via jQuery. If it's more component specific then the renderHead() solution seems better. Christoph - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component specific JavaScript
On 18.02.2012 17:46, Jürgen Lind wrote: thank you for your reply, I did not know that such a method exists (does it for 1.4 or is this already Wicket 1.5). An secondly: are these handlers fired on a ajax update of an existing DOM Element or only when it is added? This is also available in 1.4. The events are fired when you add something to the ajax request via target.add(Component) And where would I put the Javascript that registers the handler? In the Markup-Page of the Component? How do I make sure, the handler is added only once? I use jQuery and register the handler globally in my main.js for every page within $(document).ready(). This approach works very well if you don't want to create subclasses of components but rather execute some specific JS if e.g. a css class is present. I use it to add a hint image to every autocomplete textfield via jQuery. If it's more component specific then the renderHead() solution seems better. Christoph - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Component specific JavaScript
Hello Juergen, you can register a function that gets called when wicket creates a new element in the DOM: Wicket.Event.subscribe('/dom/node/added', function(element) { // do stuff }); You can also use the '/dom/node/removing' channel. Hope this helps. Christoph Jürgen Lind (2012-02-18 16:55): Hi, I was wondering if there is any kind of best practice to add specific javascript to a component. I often have the case, where a piece of javascript needs to run when the component is rendered as part of full-page request, and then subsequently as part of a self-triggered Ajax-Request or as part of an Ajax-Request triggered by another component. I would like to have one place where I can put the Javascript and be shure, it is run every time... Cheers, J. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org