Re: Which model to use for forwarding form processing results?
Hi Thorsten, This sounds like a good use-case for an event. You can have the form broadcast an event to the page, and let any component that needs to redraw based on the data handle that event. This provides a nice decoupling between the form result and 0…n other components in your page that need the data. The components handling the event then also don’t need to know where the event originated. For more info, see the wicket guide; the info is under chapter 17.2, scroll down to “Wicket events infrastructure”. https://ci.apache.org/projects/wicket/guide/6.x/guide/advanced.html#advanced_2 And a bonus tip: you can use the wicketstuff-annotationeventdispatcher jar to make your life even easier. Just include it in your project (it will automatically register itself in wicket), and then you can annotate any public component method in your page with @OnEvent, for example: @OnEvent public void onFormDataSubmittedEvent(FormDateSubmittedEvent event) { … impl } It’s actually a great way to handle data-passing in pages. Met vriendelijke groet, Kind regards, Bas Gooren Op 10 mei 2016 bij 08:54:14, Thorsten Schöning (tschoen...@am-soft.de) schreef: Hi all, I have one and the same form on different pages used to provide some input data which is afterwards used by the form's onSubmit handler to request some complex data structure from a 3rd party service. This result needs to be forwarded to the caller/owner of the form, mainly pages, so those can provide the data to different views focussing on different aspects of the data. Most of those views are panels using different DataViews to provide data in HTML tables in the end. The important thing is that the form shouldn't render the results itself, only return some raw data structure, and the panels shouldn't need to know about the form as well. What is the best way to send those resulting data around? From my understanding it's not the default model of the form with all the convert input stuff, those input comes from the user, but it may be that of the page containing form and panels, so both could access the page and its default model. Else I could simply create a model instance and forward it using the CTORs of the form and panels, without (misusing?) the page's default model. Does it even matter at all? Thanks! Mit freundlichen Grüßen, Thorsten Schöning -- Thorsten Schöning E-Mail: thorsten.schoen...@am-soft.de AM-SoFT IT-Systeme http://www.AM-SoFT.de/ Telefon...05151- 9468- 55 Fax...05151- 9468- 88 Mobil..0178-8 9468- 04 AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Issue with serialization of a page
Hi Daniele, In general I would not rely on a page not being serialized, as you have no control over the timing of serialization :-) We always generate a UUID for each object we need to track and store it in global state (e.g. a static final ConcurrentHashMap<UUID, ClassOfObjectWeTrack> on the page or application). The page then needs to store the UUID so it can locate the actual object in the global state map. What’s important is to handle cleanup properly: - clean up the map item after usage, or - clean up map items after a certain timeout, or - clean up map items (oldest first) after the map reaches a certain size Met vriendelijke groet, Kind regards, Bas Gooren Op 10 maart 2016 bij 10:04:53, Daniele IPPOLITI (daniele.ippol...@amadeus.com) schreef: Hello, I would like to write you because I’m migrating since wicket 1.4.X to wicket 7.X, but I’m facing a problem that I was not facing before: In the onSubmit of AdvancedSearchForm, the class set the next page creating MultiAvailResultPage In the initiate of MultiAvailResultPage we have used a Future variable When we need to show the page to the user we call: But this time future is not any more containing the original value but is null!!! This because the variable is declared transient and we passed through a serialization that apparently before we were not. Do you have explanations to that? Maybe something changed between the old version? Idea on how to solve it? (even creating a detachable model it seems not solving the issue because the Future variable doesn’t have any id that I can keep to retrieve it after the serialization. The two classes are attached to the mail if you need to have a deeper look. Your help it will be really appreciated. Kind regards, ___ Daniele Ippoliti Software Engineer, PMP ® R Amadeus SAS Phone: +33 (0) 4 97042180 daniele.ippol...@amadeus.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket 6.16 problem with popup window to the front by IE11
Hi Harry, What exactly is the problem? Is the popup not rendering at all in IE11? Have you checked the javascript console to see if there is a javascript problem? Your code is mostly about redirecting (or rendering) to a url for a manual; Is that part not working in IE11? Met vriendelijke groet, Kind regards, Bas Gooren Op 4 maart 2016 bij 11:42:20, Harry (hkl...@csc.com) schreef: Hi all, I’m new in this forum and I am no expert on wicket. I try to get a popup window to the front at the browser IE11, with Firefox and Chrome it works. I open the popup window with an item "*HELP*" from a Choicebox. Here the code: public class SwitchAboutChoice extends DropDownChoice { private static final long serialVersionUID = 1L; private final Logger log = LoggerFactory.getLogger(SwitchAboutChoice.class); @SuppressWarnings("unused") private final CHOICE currentChoice = CHOICE.INFO; private class ChoiceRenderer implements IChoiceRenderer { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(CHOICE c) { return new StringResourceModel("HIST." + c.name(), SwitchAboutChoice.this, null).getString(); } public String getIdValue(CHOICE c, int arg1) { return c.name(); } } public SwitchAboutChoice(String id, final PtsModal modalAbout, final ICommonWebSession iws) { super(id); this.setDefaultModel(new PropertyModel(this, "currentChoice")); setOutputMarkupId(true); setChoices(Arrays.asList(CHOICE.values())); setChoiceRenderer(new ChoiceRenderer()); add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { log.debug("AboutChoice update: {}", getModelObject().name()); switch (getModelObject()) { case HELP: // Makes the pop-up window RESIZABLE PopupSettings popup = new PopupSettings("_blank", PopupSettings.RESIZABLE); //Generates URL only dependent on the current base Url popup.setTarget("'"+ RequestCycle.get().getUrlRenderer().renderContextRelativeUrl(iws.getManualUri())+"'"); target.appendJavaScript(popup.getPopupJavaScript()); break; case ABOUT: if (target != null) { ……….. } break; default: break; } setModelObject(CHOICE.INFO); target.add(SwitchAboutChoice.this); } }); setNullValid(false); } } Can anyone help here? Kind regards Harry -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-16-problem-with-popup-window-to-the-front-by-IE11-tp4673821.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 model problem
Hi, I think the only way to track this is with custom code (or with aspects for example). Since the contract of IModel only has detach() (and not isDetached()), this cannot be tracked easily. What I would do in such a case is probably to add a requestcyclelistener which walks a page after a request, iterates (/visits) over all the components and checks their models. Of course this requires the models to expose a way to check their status and origin. Also, what we do to prevent this: we have an abstract base model called a AbstractConversionModelwhich takes a parent model (S) and converts to a target type (T), caching the conversion. This model takes a parent model as input (and subclasses of it require a java 8 Functionor expose an abstract method for the conversion etc). This model also takes care of detaching the parent model. In the end it’s all about education I guess: programmer’s should be careful when chaining models and ensure they detach the parent (/chained) model. Met vriendelijke groet, Kind regards, Bas Op 19 februari 2016 bij 15:41:03, gmparker2000 (greg.par...@brovada.com) schreef: Thanks for the reply. I suspect this is exactly the case we have created for ourselves. Although we have a good grasp on the detach process I suspect that there are places where this rule of thumb is not being followed. Although the example I gave is somewhat fictitious, any of the LDMs we have in our framework perform a detach on the parent. In the form there are numerous places where adhoc anonymous models are created and this is probably where the problems occur. Is there a recommended way to track these down? I ended up recompiling a version of Wicket with changes to LoadableDetachableModel that would essentially track every LDM within a RequestCycle. At the end of a request cycle I was left with a list of the models that never got detached. I also added a "whereAmI" member variable to LDM that would capture the stack trace in the constructor so I could figure out who instantiated the model in the first place. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-model-problem-tp4673620p4673664.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 model problem
Hi! Perhaps this is stating the obvious since it looks like you know what you are doing, but just to be sure: Does your LoadableDetachableExpressionModel call detach on its “parent” model? This is the most frequently occurring source of model leaks I have seen. Since the last model in the chain is usually attached to a component, that model gets detached, but if your “child” model does not call detach on the “parent” model and the “parent” model is not attached to a component, it will never get detached. Which model in your example is not getting detached without your override of onDetach() in MyPanel? Does it happen to be “abc”? Met vriendelijke groet, Kind regards, Bas Op 19 februari 2016 bij 15:18:41, gmparker2000 (greg.par...@brovada.com) schreef: It's hard to give specifics as the form is very complex. I do have a general example of a pattern prevalent throughout the form. The pseudo code goes something like this: // Page class MyPage extends Page { onInitialize() { Panel p = PanelFactory.createPanel("myPanel", "myObject"); this.add(p); } } // Factory for creating panels that use a document cache based loadable detachable // model class PanelFactory { Panel createPanel(String panelName, String cachedObjectName) { // uses the document name to retrieve doc from the cache using it's name DocumentCacheLDM ldm = new DocumentCacheLDM(cachedObjectName); // return a panel initialized with the model if ("myPanel".equals(panelName)) { return new MyPanel(ldm); } } } // Panel class MyPanel extends Panel { MyPanel(final IModel cacheLDM) { // create an LDM that uses the cache LDM and an expression. Note that it is marked final // so it can be used in the list panel below final LoadableDetachableModel abc = new LoadableDetachableExpressionModel(cacheLDM, "a.b.c"); // another one based on abc LoadableDetachableModel def = new LoadableDetachableExpressionModel(abc, "d.e.f"); // create a panel for DEF object Panel subPanel = new SubPanel(def); this.add(subPanel); // create a model for a repeating list of GHI LoadableDetachableModel ghi = new LoadableDetachableExpressionModel(abc, "g.h.i"); // create a repeating section for GHIs ListPanel listPanel = new ListPanel("listPanel", ghi) { @Override public Component createItemComponent(String id, IModel model, Item item) { return new GHIPanel(id, model, isReadonly, mode); } @Override public void addItem(AjaxRequestTarget target) { // uses abc model from above to add the new GHI abc.getObject().addNewGHI(); } @Override public IModel getItemModel(GHI item) { // create an LDM for the GHI item that might use the items's id internally // to load return new LoadableDetachableExpressionModel(abc, item); } @Override public void removeItem(GHI item, AjaxRequestTarget target) { abc.getObject().deleteGHI(item); } } this.add(listPanel); } } This pattern, in our case, seems to end with a bunch of models that never get detached. Therefore on subsequent request we end up with some parts of the form reattached to the document from the cache and other parts attached to orphaned transient models from their unattached models. Then when you submit the form the components that are attached to the cached object update the correct model object but the ones that didn't get detached properly update the orphaned model objects. So we end up with data lose. To get this working we changed the MyPanel class to something like this: // Panel class MyPanel extends Panel { private LoadableDetachableModel abc; private LoadableDetachableModel def; private LoadableDetachableModel ghi; void onDetach() { abc.detach(); def.detach(); ghi.detach(); } MyPanel(final IModel cacheLDM) { // create an LDM that uses the cache LDM and an expression abc = new LoadableDetachableExpressionModel(cacheLDM, "a.b.c"); // another one based on abc def = new LoadableDetachableExpressionModel(abc, "d.e.f"); // create a panel for DEF object Panel subPanel = new SubPanel(def); this.add(subPanel); // create a model for a repeating list of GHI ghi = new LoadableDetachableExpressionModel(abc, "g.h.i"); // create a repeating section for GHIs ListPanel listPanel = new ListPanel("listPanel", ghi) { @Override public Component createItemComponent(String id, IModel model, Item item) { return new GHIPanel(id, model, isReadonly, mode); } @Override public void addItem(AjaxRequestTarget target) { // uses abc model from above to add the new GHI abc.getObject().addNewGHI(); } @Override public IModel getItemModel(GHI item) { // create an LDM for the GHI item that might use the items's id internally // to load return new LoadableDetachableExpressionModel(abc, item); } @Override public void removeItem(GHI item, AjaxRequestTarget target) { abc.getObject().deleteGHI(item); }
Re: ResourceFinders - order of looking into folders for resource
Hi Marieke, I see that ResourceSettings exposes method getResourceFinders() which returns a List. Assuming that’s where you register your custom finder, isn’t the easy solution to simply add it to the top of the list? E.g. add(0, yourFinder) instead of add(yourFinder)? Met vriendelijke groet, Kind regards, Bas Op 11 februari 2016 bij 12:11:46, Marieke Vandamme (marieke.vanda...@tvh.com) schreef: Hi, We work with an extra ResourceFinder a lot, so that we can modify html when webapplication is already running. Now I want to change the html from a library, but the html is still in the library. I can not remove it from there.. Is there some way I can override this existing html, without removing it from the library? Something like defining a ResourceFinder as the first to look from? Thanks for any help ! Kind Regards, Marieke Vandamme -- DISCLAIMER http://www.tvh.com/glob/en/email-disclaimer "This message is delivered to all addressees subject to the conditions set forth in the attached disclaimer, which is an integral part of this message."
Re: Listing on http://builtwithwicket.tumblr.com/
Hi Martin, I’ve just resubmitted it (and got the “Thank you! Your submission has been received and is awaiting moderator approval.”-screen, just like last time…). Thanks! Met vriendelijke groet, Kind regards, Bas Op 8 februari 2016 bij 14:04:58, Martin Grigorov (mgrigo...@apache.org) schreef: Hi Bas, There was no notification from Tumblr for new entries for approval the last few months. Please re-post! Thank you! Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Feb 8, 2016 at 1:58 PM, Bas Gooren <b...@iswd.nl> wrote: > Hi all! > > We submitted one of our websites to the “Built with wicket” Tumblr a short > while ago but never heard back. Is it still maintained? > > Met vriendelijke groet, > Kind regards, > > Bas
Listing on http://builtwithwicket.tumblr.com/
Hi all! We submitted one of our websites to the “Built with wicket” Tumblr a short while ago but never heard back. Is it still maintained? Met vriendelijke groet, Kind regards, Bas
Re: DateTimeField AJAX DatePicker not work
Hi Christopher, Martin, I just did a quick debug, and it’s caused by the inline enclosure. When I replace that with a WebMarkupContainer, and manage the visibility of that element, everything works as expected. See my gist here: https://gist.github.com/bgooren/11602fa0d786548bfd70 We’ve had some unexpected issues with inline enclosures in the past, which is why I usually use explicit containers. In any case: the DatePicker behavior does not get it’s renderHead() method called once the second DateTimeField becomes visible, and it is inside the inline enclosure. Why that is the case requires more debugging. My gist provides a solution in the meantime. Met vriendelijke groet, Kind regards, Bas Gooren Op 3 februari 2016 bij 23:41:21, Martin Grigorov (mgrigo...@apache.org) schreef: Hi, I don't have time to debug this problem now but I'll try to do it early next week. Please create a ticket in JIRA so it won't get forgotten! Thanks! Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Tue, Feb 2, 2016 at 2:02 PM, Christopher Auth <a...@hexix.de> wrote: > Hi, > I have some problems with the > org.apache.wicket.extensions.yui.calendar.DateTimeField. In the > constructor I set the visibility to false. Ajax redraw, when a checkbox > is clicked, the DateTimeField is marked as visible. As far as everything > works. Only then I can't open the DatePicker of the second DateTimeField. > > An example is below https://github.com/ChrAu/wickettest > to find. > > I have test it with Wicket 6.19/6.22/7.2 > > Regards > Christopher > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Replacement for MarkupContainer#get and MarkupContainer#swap
Hi All, Since wicket 7 I see that index-based methods in MarkupContainer have been deprecated. We use those methods in some of our list editors - components that allow editing of lists of entities inside a form which provides ordering (move an item up & down). The beauty of the current methods is that we easily have very fast re-renders of complex editors, since we can swap the items on the server-side, and swap them on the client side too, and don’t have to rerender the entire list component. I know wicket 8 is quite a while away still, but would like to know what the preferred way of building such editors will be when wicket 8 comes out. Since it will not be possible anymore to access elements by index and swap them, the only alternative we see is to re-render the entire list component - which means it will also have to be a “soft” form submit to not lose any input. Any ideas? Met vriendelijke groet, Kind regards, Bas
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: 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
Re: XSS in wicket. Wicket fault or my fault?
Hi! You can also replace your Label's model with a StringResourceModel. See http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/model/StringResourceModel.html Met vriendelijke groet, Kind regards, Bas Gooren schreef Gonzalo Aguilar Delgado op 30-1-2014 11:17: Hi Martin, This is how I've done it. label = new Label(message, getString(main.message, new ModelWebUser(authSession.getUser(; label.setOutputMarkupId(true); And in the MainTmsPage.properties I have: main.message=Hello b${realName}/b.br Welcome to the Technoactivity Payment Solutions main page. And it worked! El 30/01/14 10:03, Martin Grigorov escribió: Hi, On Wed, Jan 29, 2014 at 6:26 PM, Gonzalo Aguilar Delgado gagui...@aguilardelgado.com wrote: Hi there, I'm building an application for a client and my security advisor told me about a XSS attack that can be performed on the site. When user logs-in I welcome they by Saying Hello user. div class=thumbnail p wicket:id=message Hello ${realName}. How do you substitute the value of ${realName} ? Wicket doesn't support such placeholders. The Wicket syntax would be: Hello span wicket:id=realName/span. Together with: page.add(new Label(realName, Some Name); Welcome to the Synapse web. /p /div As you can see I use I18N so this is not the real text that will show up, but's similar. I used to think that wicket validated output before building web but the white hat hacked it by just putting a fake name into the database. Too easy for me... The content of realName is: '';!--SCRIPTalert('XSS')/SCRIPT={()} So I ended with: Hellob'';!--scriptalert('XSS')/script=amp;{()} In the web page. And the script executed on login. I was thinking about baking a method into my DAO classes to validate everything that goes to the database. But it should be a better solution. Can you point me to right one? Best regards, - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: a little question about add(new XComponent(id).setVisible(false))
I think it's fine to change the hierarchy in onBeforeRender(), as long as you do it before calling super.onBeforeRender(), since that calls OBR on the children of your panel. And (you gotta love wicket), this is even made explicit in the source code of MarkupContainer#onBeforeRender(): /** * Called just before a component is rendered. * p * strongNOTE/strong: If you override this, you *must* call super.onBeforeRender() within * your implementation. * * Because this method is responsible for cascading {@link #onBeforeRender()} call to its * children it is strongly recommended that super call is made at the end of the override. * /p */ Before we had onInitialize, we would use onBeforeRender() and a boolean guard variable (boolean initialized) to accomplish the same thing. Conclusion, it's fine, as long as you call super.onBeforeRender() at the end of your method. Met vriendelijke groet, Kind regards, Bas Gooren schreef Decebal Suiu op 16-12-2013 16:50: I tested with: public class MyPanel extends Panel { public MyPanel(String id) { super(id); } @Override protected void onBeforeRender() { super.onBeforeRender(); add(new MyLabel(l1, Label 1)); add(new MyLabel(l2, Label 2)); add(new MyLabel(l3, Label 3)); } } in MyPanel, where MyLabel extends Label with the constructor contains and debug message: public MyLabel(String id, String label) { super(id, label); System.out.println(MyLabel.MyLabel(): + id); } And yes, the MyLabel constructed is not called if MyPanel is not visible. My impression was that in onBeforeRender I cannot change the hierarchy (add children). The 100 children was a random number that show you that my panel contains many components :) Thanks, Decebal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/a-little-question-about-add-new-XComponent-id-setVisible-false-tp4663041p4663045.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
Thanks!
Hi *, I have to say, the more I work with wicket, the happier I become. A big thank you! to both the excellent developers and those helping others on the mailing list! Wicket is a truly amazing piece of kit. Having recently played with a number of other frameworks for real production apps, wicket continues to impress me. Even after using it for years in rather big projects. I love the whole less magic is better-attitude and configurability. -- Met vriendelijke groet, Kind regards, Bas Gooren
Re: Optional wrapping H1 tag
I'd do it like this: h1 wicket:id=logo-h1 a wicket:id=logo-home.../a /h1 add(new WebMarkupContainer(logo-h1) { void onConfigure() { super.onConfigure(); setRenderBodyOnly(!getPage().getClass().equals(Homepage.class)); } }.add(new Link...)); In other words: only render the H1 body when not on the homepage. setRenderBodyOnly() allows you to control if a tag should be fully rendered, or just it's body. onConfigure() can be overriden to update a components settings whenever it is about to be rendered. Met vriendelijke groet, Kind regards, Bas Gooren schreef Scott Carpenter op 22-11-2013 19:24: Suppose you have a web site with a logo in the header which links to the home page. On the home page itself, you have the same logo and the link, but you also want to wrap the logo with an H1 tag. (Or maybe it's not that you have a burning desire to do this, but your client has requested it.) In my Wicket inexperiencedness, I might try this: wicket:enclosure child=homePageHomeLink h1a wicket:id=homePageHomeLink title=Home href=#ABC, Inc./a/h1 /wicket:enclosure wicket:enclosure child=homeLink a wicket:id=homeLink title=Home href=#ABC, Inc./a /wicket:enclosure And then on the Java side, set one or the other to be invisible. That works, but I'd like to know if there's a better way. Thank you!
Re: Session invalidation and background thread
Hi, I guess it depends on the lifecycle of those threads how I would handle this. Suppose the session is invalidated and destroyed, what should happen to the threads? Do they continue (A) or do they need to stop (B)? A) In this case I would not depend on the session at all, if possible. Simply copy the OAuth token to a private variable in your threads. B) Instead of the threads polling to see if the session is still there, I'd turn things around. Keep track of sessions-and-their-threads somewhere. Register a session invalidation listener, and when the session is invalidated, you can run some code to neatly stop and clean up your threads. Met vriendelijke groet, Kind regards, Bas Gooren schreef Marios Skounakis op 22-11-2013 23:45: Hi all, This is maybe a Spring question but as my app is a wicket app and I use this list regularly and everyone is very helpful I thought I'd ask here first. I have a RequestCycleListener which during onBeginRequest() conditionally spawns some background threads and runs them using an Executor. These threads need access to an oauth token which is stored in the session. So I create my threads in the RequestCycleListener, give them a reference to the wicket session and run them in the background thread. The threads also have a reference to Spring's session (via spring's RequestContextHolder.getRequestAttributes()/setRequestAttributes()). Actually the dependence on spring session is much harder to alleviate as they often need to access session scoped beans. I'm wondering what exactly happens if I try to invalidate the session (e.g. when the user logs out) while such a background thread is running. Is there a possibility for harmful side-effects? Should I consider adding code to my threads to periodically check that the session is still valid? After all they do have a reference to the session object, so this sounds feasible. If it matters at all, I'm using Tomcat. Thanks in advance, Marios
Re: Java EL for Wicket
Hi Steve, Thanks for sharing! As longtime wicket users we are doing something similar. We have the notion of a page context to which components can contribute data (it's a simple mapString, Object) by implementing an interface (PageContextContributor). A component can then either: - add an InlineContextLabel, which will replace expressions in it's body using the page context, or - add an InlineContextMarkupContainer, which can serve as a parent to wicket:message tags, so they can resolve properties in the page context The reason we have started using this in more recent projects is that we didn't like the split you get once you have pages (or components) which have localized html files, but also contain some dynamic content: labels with property replacement. Before using our above solution, we would have some of the content in properties files, and some in the localized html files. Now we can have a lot more of the localized stuff directly in the html files. I'll have a look at your code. Met vriendelijke groet, Kind regards, Bas Gooren schreef Steve op 21-11-2013 12:05: This will probably horrify some of the wicket dev team. It's probably not the 'wicket way'. But I've been using wicket for years and there's plenty of thing you can do in many different ways but a few things that you just can't. An incidental but very useful part of this package in a Renderer class. It's an extension of wicket's ComponentRenderer that allows you to Render components without having to create a wicket application. If you do happen to be inside a wicket application when you invoke it no problem. But with the wicket version you have no choice. So for a quick and dirty HTML output it lets you go with 2 lines of code: Renderer.init(); String html = Renderer.renderComponent(myPanel).toString(); The main part of the package is an integration of JUEL with wicket allowing you to put Java Expression Language into your markup which will be evaluated just before the wicket rendering cycle. It might seem odd but I've wished this was part of wicket for years. There's many times when I just want to populate a html element with a bean property and it gets a bit tedious having to add it in both markup and code. It also makes dynamic markup generation a lot easier given that your generator only needs to spit out HTML for many purposes and doesn't need to generate java code as well. The wicket version would be something like this: markup: span wicket:id=label1 color=red/span span wicket:id=label2/span code: add(new Label(label1, bean.getFirstName()) .add(AttributeModifier.replace(color, new Model(green) { public String getObject() { bean.getColor(); } })); add(new Label(label2, bean.getLastName()); The EL version would be simply:more span color=bean.color${bean.firstName}/span span${bean.lastName}/span No code needed at all if 'bean' is a property of the Component. Otherwise you can just add a single line: setELBaseObject(bean); then the above html becomes even simpler: span color=color${firstName}/span span${lastName}/span All the magic of wicket is retained. But with a much neater way of adding simple values to markup. The code is model aware. If any part of an expression evaluates to a wicket model it will be unwrapped before the rest of the expression is evaluated. So all the model magic is also retained and models can be used to achieve anything particularly fancy needed for an evaluation. Currently the code is split into two behaviours. The first part enables modifiable markup. If you want a simple way to interfere with markup before wicket gets to it you can use this behaviour on it's own by overriding a single method: String modifyMarkup(String). The second part is the EL implementation (which uses the JUEL library). Both are implemented using the behaviour pattern because there's no common parent class to inject this behaviour into the Component class heirarchy. Currently there's implementations for Panel, ListView and Page but looking at those an example should give you an idea how to add the behaviour to other component types. Be warned the code is very fresh so is likely got a few bugs and I have fairly hefty TODO list. But I intend using it for a couple of projects I'm working on so it should be getting plenty of developer love in the near future. I'm the first to admit it's a bit hacky in the way it hooks into the wicket lifecycle. Wicket really doesn't make it easy to intercept markup. With luck the dev team won't hate this idea too much and might provide some neater hooks in future versions of the API. You can find it here: https://bitbucket.org/shadders/wicket-el - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket Components as Class Members
Since the original question was about storing component references as class members, let me answers how we handle that in our shop. Wicket serializes stateful pages anyway, so any component references within the page don't hurt (at all). It's just a 4-byte reference to an object wicket already references (through the component hierarchy). As for stateless pages it matters even less, as they are not serialized at all (so only a 4-byte reference per component uses some memory). I think the most important rules regarding serialization are: - don't reference other pages or components within those pages - don't reference large object (use loadable detachable models instead) Like an earlier reponse to this question said: referencing components by their (string) id within the page is quite ugly. not to mention it breaks quite easily. We use component references extensively (e.g. when the visibility of one component depends on the state others), and have never encountered any problems. Met vriendelijke groet, Kind regards, Bas Gooren schreef meduolis op 8-11-2013 17:20: The only thing I googled related to final and wicket is this: 7. Java nuances — There are two Java nuances that catch many Wicket newcomers off-guard. 1. The first is serialization. Wicket uses Java serialization to store the state of your component hierarchy (the page and all its components and their components and so-on) in memory or on disk between page requests. This means you need to be careful because things can get serialized by accident. The most common cause of this is declaring a variable final outside of an anonymous inner class and then using it inside that anonymous inner class. Doing this causes the compiler to add a member variable to the anonymous inner class. If that final variable is a large collection or a service from your middle-tier, this can cause a gigantic explosion of memory usage and can be hard to track down. In short: be very cautious with what you reference within anonymous inner classes and use member variables in your classes sparingly. source: http://wickettraining.com/ten-things-every-wicket-programmer-should-know.html -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-Components-as-Class-Members-tp4662235p4662237.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: Component detecting Ajax update
And from within the component itself you can override onEvent and handle the event whose payload is an AjaxRequestTarget. The component can then check if it's in the getComponents() collection of said target. e.g. @Override public void onEvent( IEvent ? event ) { Object payload = event.getPayload(); if( payload instanceof AjaxRequestTarget ) { AjaxRequestTarget target = (AjaxRequestTarget) payload; if(target.getComponents().contains(this)) { // your logic goes here } } } Met vriendelijke groet, Kind regards, Bas Gooren schreef Martin Grigorov op 4-11-2013 8:27: Hi, You can use org.apache.wicket.ajax.AjaxRequestTarget.IListener#onBeforeRespond(MapString, Component map, AjaxRequestTarget) to be notified before ART starts preparing its XML response. The 'map' contains all already added components. On Fri, Nov 1, 2013 at 3:45 PM, Nick Pratt nbpr...@gmail.com wrote: Is there a way for a Component to detect if its been added to an AjaxRequestTarget? N
Re: Displaying ListView After Being Hidden
That's precisely why that method/functionality exists. If you have a component which is not visible on the first render, how can wicket replace it on subsequent ajax renders? When you call setOutputMarkupPlaceholderTag(true), wicket will render a tag with style=display:none which provides wicket's ajax library with a hook in the dom. Suppose you don't call that method, there will be no element in the dom which can be replaced. Met vriendelijke groet, Kind regards, Bas Gooren schreef Jared Sol op 25-10-2013 23:03: No problem. I'm not exactly sure. I just know when hiding an element and then unhiding it you have to tell the component to keep a placeholder so it doesn't lose access to the component when you hide it. Might have something to do with keeping it around in the dom and using display=none. I haven't looked into the details. Sent from my iPhone On Oct 25, 2013, at 11:45 AM, dhongyt davidhtr...@gmail.com wrote: Thanks you! That worked for me. What is the reason for this? Is this so that it would it would hold the placeholder with in wmc? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Displaying-ListView-After-Being-Hidden-tp4661963p4661972.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
Dynamic markup loading caching in base page
Hi *, We built an app which has a base page, and several child pages which inherit from the base page. The app is themeable, and one of the requirements of the app is/was that these themes should be manageable. This means we have a set of themes which can be changed on-the-fly. To add flexibility to our app, a theme can override the html of the base page. To handle the custom html, our base page implements IMarkupResourceStreamProvider and IMarkupCacheKeyProvider. Every user of the app can select a theme, so the theme is determined per request. The cache key is generated based on the theme id and the container class: @Override public String getCacheKey( MarkupContainer container, Class ? containerClass ) { final Theme theme = getWebsite().getTheme(); return Theme# + theme.getId() + - + containerClass.getName(); } The markup resource stream is only overriden for the base page: @Override public IResourceStream getMarkupResourceStream( MarkupContainer container, Class ? containerClass ) { final Theme theme = getWebsite().getTheme(); if( containerClass.equals( WebsiteLayout.class ) ) { String markup = theme.getMarkup(); return new StringResourceStream( markup, text/html ); } return defaultResourceStreamProvider.getMarkupResourceStream( container, containerClass ); } (where defaultResourceStreamProvider is a DefaultMarkupResourceStreamProvider instance). The problem we are facing is that when the user switches to a different theme, they keep seeing the html code of the previously selected theme. Debugging shows that when the theme is changed: - getCacheKey is hit for both the child page and the base page - getMarkupResourceStream is hit for both the child page and the base page I think it could be due to the way wicket's DefaultMarkupResourceStreamProvider handles inheritance: maybe it (too) caches the base page markup? Can anyone help with this? How do we properly cache dynamic html for a base page which is used by several (static) child pages? Thanks! -- Met vriendelijke groet, Kind regards, Bas Gooren
Re: Dynamic markup loading caching in base page
Sorry, I forgot to add that this is a wicket 1.5 app. As a quick follow-up, after looking at the InheritedMarkupMarkupLoader, I see that it delegates loading of the parent (base page) markup to the MarkupFactory. I think that means that our current setup should work, when it doesn't. Met vriendelijke groet, Kind regards, Bas Gooren Op 3-10-2013 18:59, schreef Bas Gooren: Hi *, We built an app which has a base page, and several child pages which inherit from the base page. The app is themeable, and one of the requirements of the app is/was that these themes should be manageable. This means we have a set of themes which can be changed on-the-fly. To add flexibility to our app, a theme can override the html of the base page. To handle the custom html, our base page implements IMarkupResourceStreamProvider and IMarkupCacheKeyProvider. Every user of the app can select a theme, so the theme is determined per request. The cache key is generated based on the theme id and the container class: @Override public String getCacheKey( MarkupContainer container, Class ? containerClass ) { final Theme theme = getWebsite().getTheme(); return Theme# + theme.getId() + - + containerClass.getName(); } The markup resource stream is only overriden for the base page: @Override public IResourceStream getMarkupResourceStream( MarkupContainer container, Class ? containerClass ) { final Theme theme = getWebsite().getTheme(); if( containerClass.equals( WebsiteLayout.class ) ) { String markup = theme.getMarkup(); return new StringResourceStream( markup, text/html ); } return defaultResourceStreamProvider.getMarkupResourceStream( container, containerClass ); } (where defaultResourceStreamProvider is a DefaultMarkupResourceStreamProvider instance). The problem we are facing is that when the user switches to a different theme, they keep seeing the html code of the previously selected theme. Debugging shows that when the theme is changed: - getCacheKey is hit for both the child page and the base page - getMarkupResourceStream is hit for both the child page and the base page I think it could be due to the way wicket's DefaultMarkupResourceStreamProvider handles inheritance: maybe it (too) caches the base page markup? Can anyone help with this? How do we properly cache dynamic html for a base page which is used by several (static) child pages? Thanks!
Re: Dynamic markup loading caching in base page
Another hour of debugging revealed the problem... The MarkupCache method loadMarkupAndWatchForChanges has code which shortcuts our custom cache key: // get the location String String locationString = markupResourceStream.locationAsString(); if (locationString == null) { // set the cache key as location string, because location string // couldn't be resolved. locationString = cacheKey; } Since our child pages are loaded through wicket's default resource loading mechanism, a MarkupResourceStream instance is used. The MarkupCache has a level of indirection: cacheKey = locationString locationString = cached markup Since our child pages' markup resource stream have a location on disk, this effectively means wicket caches the actual content only once instead of per theme: all our custom cache keys point to the same location string. The fix was easy: I created an IResourceStreamWrapper class, and let it wrap the MarkupResourceStream of child pages. This effectively makes them return a null location string, and thus the child pages are cached per theme. Met vriendelijke groet, Kind regards, Bas Gooren Op 3-10-2013 19:11, schreef Bas Gooren: Sorry, I forgot to add that this is a wicket 1.5 app. As a quick follow-up, after looking at the InheritedMarkupMarkupLoader, I see that it delegates loading of the parent (base page) markup to the MarkupFactory. I think that means that our current setup should work, when it doesn't. Met vriendelijke groet, Kind regards, Bas Gooren Op 3-10-2013 18:59, schreef Bas Gooren: Hi *, We built an app which has a base page, and several child pages which inherit from the base page. The app is themeable, and one of the requirements of the app is/was that these themes should be manageable. This means we have a set of themes which can be changed on-the-fly. To add flexibility to our app, a theme can override the html of the base page. To handle the custom html, our base page implements IMarkupResourceStreamProvider and IMarkupCacheKeyProvider. Every user of the app can select a theme, so the theme is determined per request. The cache key is generated based on the theme id and the container class: @Override public String getCacheKey( MarkupContainer container, Class ? containerClass ) { final Theme theme = getWebsite().getTheme(); return Theme# + theme.getId() + - + containerClass.getName(); } The markup resource stream is only overriden for the base page: @Override public IResourceStream getMarkupResourceStream( MarkupContainer container, Class ? containerClass ) { final Theme theme = getWebsite().getTheme(); if( containerClass.equals( WebsiteLayout.class ) ) { String markup = theme.getMarkup(); return new StringResourceStream( markup, text/html ); } return defaultResourceStreamProvider.getMarkupResourceStream( container, containerClass ); } (where defaultResourceStreamProvider is a DefaultMarkupResourceStreamProvider instance). The problem we are facing is that when the user switches to a different theme, they keep seeing the html code of the previously selected theme. Debugging shows that when the theme is changed: - getCacheKey is hit for both the child page and the base page - getMarkupResourceStream is hit for both the child page and the base page I think it could be due to the way wicket's DefaultMarkupResourceStreamProvider handles inheritance: maybe it (too) caches the base page markup? Can anyone help with this? How do we properly cache dynamic html for a base page which is used by several (static) child pages? Thanks!
Re: Google Maps refuses access
I have no idea, as I have not had this problem myself. You should call or e-mail google support about this. Met vriendelijke groet, Kind regards, Bas Gooren Op 14-9-2013 11:44, schreef Piratenvisier: How long am I blocked. Do I have to do anything, or does the blockage go away after a few days. Am 12.09.2013 08:55, schrieb Bas Gooren: Hi, You're probably hitting a usage limit: https://developers.google.com/maps/documentation/business/articles/usage_limits?hl=nl#http403 Met vriendelijke groet, Kind regards, Bas Gooren Op 12-9-2013 8:41, schreef Piratenvisier: I am using google maps embeded in my 1.5 wicket application . I used the wicket.contrib.gmap modules, which worked fine till now. Since a few days I get back the error: Server returned HTTP response code: 403 for URL: http://maps.google.com/maps/geo?q=30161+Hannover+Eichstra%C3%9Fe+10output=csvkey=x What has changed ? - 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: Google Maps refuses access
Hi, You're probably hitting a usage limit: https://developers.google.com/maps/documentation/business/articles/usage_limits?hl=nl#http403 Met vriendelijke groet, Kind regards, Bas Gooren Op 12-9-2013 8:41, schreef Piratenvisier: I am using google maps embeded in my 1.5 wicket application . I used the wicket.contrib.gmap modules, which worked fine till now. Since a few days I get back the error: Server returned HTTP response code: 403 for URL: http://maps.google.com/maps/geo?q=30161+Hannover+Eichstra%C3%9Fe+10output=csvkey=x What has changed ? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: p tags!
Could it be related to http://stackoverflow.com/questions/10763780/putting-div-inside-p-is-adding-an-extra-p ? I've seen odd behavior before when using block-level elements inside p-tags. However, from your e-mail it's not entirely clear what your html looks like. Subcomponents of mainpanel were wrapped in p-tags does sound like you may have divs inside p tags. Met vriendelijke groet, Kind regards, Bas Gooren Op 9-9-2013 4:28, schreef Colin Rogers: Wicketeers! I have an odd bug, that has been resolved, but I it doesn't explain what and why the issue existed - and with a view to avoiding the issue in future, I thought I should seek some wisdom! :) Basically - I have a application where the 'main panel' is replaced as a link is clicked (along with other panels, too) - oddly, when I hit certain links repeatedly, instead of the mainPanel simply replacing the old version and updating, it produced duplicates - no duplicates in the other panels, just the mainPanel. Meaning I had the same panel repeated from each click down the page. After tons of reverting on code, hacking and experimenting, I finally found the culprit... yep; p tags. When any of my sub-components of mainPanel were wrapped in p tags, it caused the parent to duplicate instead of replace. Replace the p tag with a div and everything works fine. So obviously I have a perfectly good solution! Does anyone have an explanation for this? I'm totally stumped as to why p tags would cause issues in the DOM? Cheers, Col. EMAIL DISCLAIMER This email message and its attachments are confidential and may also contain copyright or privileged material. If you are not the intended recipient, you may not forward the email or disclose or use the information contained in it. If you have received this email message in error, please advise the sender immediately by replying to this email and delete the message and any associated attachments. Any views, opinions, conclusions, advice or statements expressed in this email message are those of the individual sender and should not be relied upon as the considered view, opinion, conclusions, advice or statement of this company except where the sender expressly, and with authority, states them to be the considered view, opinion, conclusions, advice or statement of this company. Every care is taken but we recommend that you scan any attachments for viruses.
Re: Use Wicket as a REST API
Hi, Yes, what you are doing is a perfectly ok way to handle this. Optionally you could use a shared resource for this, but I say that's just a matter of preference. We use something inspired by https://code.google.com/p/wicket-rest/ This gives you some abstraction over the json (or xml/...) handling. Furthermore you can override sensible methods like doGet or doPost which clearly communicate intent. Met vriendelijke groet, Kind regards, Bas Gooren Op 14-8-2013 20:32, schreef robianmcd: I found that this works but I'm not sure if there is a better way of doing this: @MountPath(value = /api/my/rest/url) public class MyPostHandler extends SecureWebPage { public MyPostHandler () { final WebRequest webRequest = (WebRequest) getRequest(); final HttpServletRequest rawRequest = (HttpServletRequest) webRequest.getContainerRequest(); if (rawRequest.getMethod().equalsIgnoreCase(POST)) { BufferedReader br; try { br = rawRequest.getReader(); String jsonString = br.readLine(); //Do something with the JSON here } catch (IOException e) { } } } } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Use-Wicket-as-a-REST-API-tp4660894p4660898.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 call Java Function from JavaScript
Wicket's ajax functions require you to load the wicket ajax javascript. This is handled by the AbstractDefaultAjaxBahavior out of the box. However, since you do not call super.renderHead(component,response) in your code, the required javascript files are not loaded. Met vriendelijke groet, Kind regards, Bas Gooren Op 3-7-2013 19:09, schreef Andun Sameera: Hi All, I have looked in to this topic in many places and found some ways. In this particular scenario, I have used https://cwiki.apache.org/confluence/display/WICKET/Calling+Wicket+from+Javascriptarticle as the reference. What I did in Java, public class HomePage extends WebPage { private static final long serialVersionUID = 1L; public HomePage(final PageParameters parameters) { super(parameters); final AbstractDefaultAjaxBehavior behave = new AbstractDefaultAjaxBehavior() { protected void respond(final AjaxRequestTarget target) { target.add(new Label(foo, Yeah I was just called from Javascript!)); } public void renderHead(Component component,IHeaderResponse response){ String componentMarkupId = component.getMarkupId(); String callbackUrl = getCallbackUrl().toString(); response.render(JavaScriptHeaderItem.forScript(var componentMarkupId='+componentMarkupId+'; var callbackUrl='+callbackUrl+';,values)); } }; add(behave); } } and my HomePage.html, !DOCTYPE HTML html body script src=http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js /script script type=text/javascript $(function() { var wcall = Wicket.Ajax.get({ u: '${callbackUrl}' + '' }); alert(wcall); }); /script /body /html What I tried to do is call the get ajax method using the vars I have initialized. But when my page loads, in the firebug console it says, ReferenceError: Wicket is not defined [Break On This Error] var wcall = Wicket.Ajax.get({ u: '${callbackUrl}' + '' }); What has gone wrong here ? Is there any other good way to call Java Function from Javascript? Thanks!
Re: Injecting DB service results in IllegalStateException: EntityManager is closed
Hi Andreas, When I debugged your code yesterday, I changed the injection in JpaService to ProviderEntityManager, and the error was gone. See http://pastebin.com/6NwjcVt4 Please ensure that your Jetty instance is actually using the updated code; Met vriendelijke groet, Kind regards, Bas Gooren Op 28-6-2013 10:04, schreef Andreas Lundblad: On Thu, Jun 27, 2013 at 11:27 PM, Bas Gooren b...@iswd.nl wrote: PS See https://code.google.com/p/google-guice/wiki/InjectingProviders (header Providers for Mixing Scopes). Met vriendelijke groet, Kind regards, Bas Gooren A (possibly stupid) follow-up question. To try out the idea that you proposed with a Provider, I changed @Inject IService service; ... service.xyz() to @Inject ProviderIService service; ... service.get().xyz() But I still get the same EntityManager is closed error. (I also tried changing from EntityManager to ProviderEntityManager in the JpaService. Same error.) Is this the correct way of using Guice Providers in Wicket? If no, where can I find examples/documentation on how to use Providers in Wicket? If yes, the EntityManager is closed error seems to be due to something else. best regards, Andreas Lundblad - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Injecting DB service results in IllegalStateException: EntityManager is closed
Hi, Looking at the github project you refer to, it should work. The GuiceComponentInjector which is set-up in the wicket application injects proxies. That means that when your form is submitted (and a second request is made), a new service instance is created. So if it's not working for you, there is probably another problem with your code. Can you show us some relevant parts of your code, e.g. the validator and the page which contains the validator? Met vriendelijke groet, Kind regards, Bas Gooren Op 26-6-2013 22:32, schreef Andreas Lundblad: I've just started using Wicket (I'm half way through Wicket in Action). I've run into the following problem with a user registration form: In order to make sure that the provided e-mail is not already registered I've written a UniqueEmailValidator which I attach to the email field. This validator needs access to the DB-service to query the database for already registered email-adresses. The problem is that the DB-service is injected when the registration page is created and since I'm using open-session-in-view, the DB-service EntityManager is closed after the page is rendered. This causes an IllegalStateException: EntityManager is closed once the form is submitted in a subsequent request. (Since the same old DB-service object is used in the second request.) (I had the same problem when trying to inject the DB-service in the session-object. The same DB-service object was used in multiple requests causing the IllegalStateException.) I figured this must be a fairly common problem but can't for my life find any solutions in the archives or through googling. I'm curious what the best practice is to solve this. (My project builds upon the code available here: http://github.com/javadev/wicket-guice-demo ) best regards, Andreas Lundblad - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Injecting DB service results in IllegalStateException: EntityManager is closed
I agree; Since the EntityManager is bound to the request (scope), it's usually better to inject ProviderEntityManager However, in the demo project the service is not a singleton, so it should be fine. A new instance of the service is created for every injection. Met vriendelijke groet, Kind regards, Bas Gooren Op 27-6-2013 9:10, schreef Martin Grigorov: Hi, I'm not sure whether this is the best solution but you can inject a Provider: @Inject private ProviderEntityManager em; ... em.get().find(...); On Thu, Jun 27, 2013 at 9:36 AM, Bas Gooren b...@iswd.nl wrote: Hi, Looking at the github project you refer to, it should work. The GuiceComponentInjector which is set-up in the wicket application injects proxies. That means that when your form is submitted (and a second request is made), a new service instance is created. So if it's not working for you, there is probably another problem with your code. Can you show us some relevant parts of your code, e.g. the validator and the page which contains the validator? Met vriendelijke groet, Kind regards, Bas Gooren Op 26-6-2013 22:32, schreef Andreas Lundblad: I've just started using Wicket (I'm half way through Wicket in Action). I've run into the following problem with a user registration form: In order to make sure that the provided e-mail is not already registered I've written a UniqueEmailValidator which I attach to the email field. This validator needs access to the DB-service to query the database for already registered email-adresses. The problem is that the DB-service is injected when the registration page is created and since I'm using open-session-in-view, the DB-service EntityManager is closed after the page is rendered. This causes an IllegalStateException: EntityManager is closed once the form is submitted in a subsequent request. (Since the same old DB-service object is used in the second request.) (I had the same problem when trying to inject the DB-service in the session-object. The same DB-service object was used in multiple requests causing the IllegalStateException.) I figured this must be a fairly common problem but can't for my life find any solutions in the archives or through googling. I'm curious what the best practice is to solve this. (My project builds upon the code available here: http://github.com/javadev/**wicket-guice-demohttp://github.com/javadev/wicket-guice-demo) best regards, Andreas Lundblad --**--**- To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Injecting DB service results in IllegalStateException: EntityManager is closed
I'm not the one who posed the original question. Andreas, like I said: please show us some code, and we can help you pinpoint your issue. In case your service is being serialized, a quick fix is to inject a ProviderEntityManager instead of an EntityManager. Met vriendelijke groet, Kind regards, Bas Gooren Op 27-6-2013 14:25, schreef Martin Grigorov: Here are some discussions: http://stackoverflow.com/questions/10431640/guice-persist-attempting-to-execute-an-operation-on-a-closed-entitymanager http://stackoverflow.com/questions/14585505/jpa-guice-persist-permanently-opened-connection-issue On Thu, Jun 27, 2013 at 3:20 PM, Bas Gooren b...@iswd.nl wrote: I agree; Since the EntityManager is bound to the request (scope), it's usually better to inject ProviderEntityManager However, in the demo project the service is not a singleton, so it should be fine. A new instance of the service is created for every injection. Met vriendelijke groet, Kind regards, Bas Gooren Op 27-6-2013 9:10, schreef Martin Grigorov: Hi, I'm not sure whether this is the best solution but you can inject a Provider: @Inject private ProviderEntityManager em; ... em.get().find(...); On Thu, Jun 27, 2013 at 9:36 AM, Bas Gooren b...@iswd.nl wrote: Hi, Looking at the github project you refer to, it should work. The GuiceComponentInjector which is set-up in the wicket application injects proxies. That means that when your form is submitted (and a second request is made), a new service instance is created. So if it's not working for you, there is probably another problem with your code. Can you show us some relevant parts of your code, e.g. the validator and the page which contains the validator? Met vriendelijke groet, Kind regards, Bas Gooren Op 26-6-2013 22:32, schreef Andreas Lundblad: I've just started using Wicket (I'm half way through Wicket in Action). I've run into the following problem with a user registration form: In order to make sure that the provided e-mail is not already registered I've written a UniqueEmailValidator which I attach to the email field. This validator needs access to the DB-service to query the database for already registered email-adresses. The problem is that the DB-service is injected when the registration page is created and since I'm using open-session-in-view, the DB-service EntityManager is closed after the page is rendered. This causes an IllegalStateException: EntityManager is closed once the form is submitted in a subsequent request. (Since the same old DB-service object is used in the second request.) (I had the same problem when trying to inject the DB-service in the session-object. The same DB-service object was used in multiple requests causing the IllegalStateException.) I figured this must be a fairly common problem but can't for my life find any solutions in the archives or through googling. I'm curious what the best practice is to solve this. (My project builds upon the code available here: http://github.com/javadev/wicket-guice-demohttp://github.com/javadev/**wicket-guice-demo http://**github.com/javadev/wicket-**guice-demohttp://github.com/javadev/wicket-guice-demo ) best regards, Andreas Lundblad --** --**- To unsubscribe, e-mail: users-unsubscribe@wicket.**apa**che.orghttp://apache.org users-unsubscribe@**wicket.apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Injecting DB service results in IllegalStateException: EntityManager is closed
Hi Andreas, When your validator fails, you remain on the FormPage. A quick debug session shows me that the injected IService remains the same accross requests. The fix for your problem is simple, and a best practice anyway: inject ProviderEntityManager in your service. It's a best practice since the service does not know the scope of the entitymanager, all it knows is that the entitymanager has a different lifecycle; Your service may be instantiated and kept around for the time your app is running, but could also be instantiated on the fly when needed. That's one of the reasons why Provider was invented: if the scope is different, a provider allows you to nicely deal with it. In case you are not familiar with providers: it has no negative side-effects in terms of performance. The guice-persist module binds the EntityManager per request, so all calls to ProviderEntityManager while in the same request will yield the exact same EntityManager instance. Met vriendelijke groet, Kind regards, Bas Gooren Op 27-6-2013 22:03, schreef Andreas Lundblad: On Thu, Jun 27, 2013 at 3:59 PM, Bas Gooren b...@iswd.nl wrote: I'm not the one who posed the original question. Andreas, like I said: please show us some code, and we can help you pinpoint your issue. Thanks for all the rapid help! I've created a minimal page that shows the error. Basically no difference from the original code ( http://github.com/javadev/wicket-guice-demo ) To reproduce: 1. Download and unzip http://aoeu.se/www/wicketguice-problem.zip 2. mvn jetty:run 3. Go to localhost:9090, then go to Form page 4. Try to submit gavin 5. Try to submit gavin again. This results in the 'EntityManager is closed' exception. No idea how to solve this. If it's unsolvable, I'll look into the Provider approach, but it would be really nice to manage without it. best regards, Andreas Lundblad - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Injecting DB service results in IllegalStateException: EntityManager is closed
PS See https://code.google.com/p/google-guice/wiki/InjectingProviders (header Providers for Mixing Scopes). Met vriendelijke groet, Kind regards, Bas Gooren Op 27-6-2013 22:03, schreef Andreas Lundblad: On Thu, Jun 27, 2013 at 3:59 PM, Bas Gooren b...@iswd.nl wrote: I'm not the one who posed the original question. Andreas, like I said: please show us some code, and we can help you pinpoint your issue. Thanks for all the rapid help! I've created a minimal page that shows the error. Basically no difference from the original code ( http://github.com/javadev/wicket-guice-demo ) To reproduce: 1. Download and unzip http://aoeu.se/www/wicketguice-problem.zip 2. mvn jetty:run 3. Go to localhost:9090, then go to Form page 4. Try to submit gavin 5. Try to submit gavin again. This results in the 'EntityManager is closed' exception. No idea how to solve this. If it's unsolvable, I'll look into the Provider approach, but it would be really nice to manage without it. best regards, Andreas Lundblad - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Injecting DB service results in IllegalStateException: EntityManager is closed
Hi Andreas, My guess is that the GuiceComponentInjector proxies are detached when the page is serialized. The last page (or the last N pages) are kept in memory by wicket (I think, last I checked was some years ago). Checking ... Yes, see LazyInitProxyFactory and its nested class JdkJHandler (which is used for injected interfaces). The proxy is replaced on serialization. Somehow I always thought the proxies were also detached when the page is detach()-ed. Guess not :-) Met vriendelijke groet, Kind regards, Bas Gooren Op 27-6-2013 23:37, schreef Andreas Lundblad: On Thu, Jun 27, 2013 at 11:25 PM, Bas Gooren b...@iswd.nl wrote: Hi Andreas, When your validator fails, you remain on the FormPage. A quick debug session shows me that the injected IService remains the same accross requests. I've seen this too. I thought that this didn't matter since, as you said: The GuiceComponentInjector which is set-up in the wicket application injects proxies. The fix for your problem is simple, and a best practice anyway: inject ProviderEntityManager in your service. It's a best practice since the service does not know the scope of the entitymanager, all it knows is that the entitymanager has a different lifecycle; Your service may be instantiated and kept around for the time your app is running, but could also be instantiated on the fly when needed. That's one of the reasons why Provider was invented: if the scope is different, a provider allows you to nicely deal with it. In case you are not familiar with providers: it has no negative side-effects in terms of performance. The guice-persist module binds the EntityManager per request, so all calls to ProviderEntityManager while in the same request will yield the exact same EntityManager instance. PS See https://code.google.com/p/google-guice/wiki/InjectingProviders (header Providers for Mixing Scopes). Thank you Bas for this excellent answer. Much appreciated. -- Andreas Lundblad - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Multitenant app: what's a good place to perform account lookup?
Martin, Thanks, that's another possible solution indeed. Met vriendelijke groet, Kind regards, Bas Gooren Op 26-6-2013 9:29, schreef Martin Grigorov: Hi, I think you can use custom root request mapper for this too. See https://github.com/apache/wicket/blob/master/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleFirstMapper.java?source=cc - it extracts the locale from the first url segment. On Tue, Jun 25, 2013 at 6:55 PM, Bas Gooren b...@iswd.nl wrote: Hi *, One of our multi-tenant apps uses the incoming hostname to look up the account to attach to. We've currently handled it like so: - Request scoped guice provider, which performs the lookup (which can return Account.UNKNOWN) - Base page class which validates the account returned by the provides at construction time This works quite well for us, but it does mean that any component not extending the base page class will also need to validate the account. I think a more logical place to perform the lookup (and cache it) is in a request cycle listener. However, in case no matching account is found, we need to render a 404 page. One way of handling that is by throwing an AbortWithHttpErrorCodeExceptio* *n in onRequestHandlerResolved, since that will also allow us to inspect the resolved handler and check if it's pointing to our 404 page (to prevent a loop). Is there a better/cleaner way to handle such concerns? -- Met vriendelijke groet, Kind regards, Bas Gooren
Multitenant app: what's a good place to perform account lookup?
Hi *, One of our multi-tenant apps uses the incoming hostname to look up the account to attach to. We've currently handled it like so: - Request scoped guice provider, which performs the lookup (which can return Account.UNKNOWN) - Base page class which validates the account returned by the provides at construction time This works quite well for us, but it does mean that any component not extending the base page class will also need to validate the account. I think a more logical place to perform the lookup (and cache it) is in a request cycle listener. However, in case no matching account is found, we need to render a 404 page. One way of handling that is by throwing an AbortWithHttpErrorCodeException in onRequestHandlerResolved, since that will also allow us to inspect the resolved handler and check if it's pointing to our 404 page (to prevent a loop). Is there a better/cleaner way to handle such concerns? -- Met vriendelijke groet, Kind regards, Bas Gooren
Re: Model performance question
Hi, It sounds like you know what you are doing, but I just want to check why you chose myObject as a variable name in your example? If you are properly using detachable models and do not want to serialize a large object graph, myObject needs to be a loadable detachable model, and not an actual object in your example. myLDM or myObjectModel would be a more logical name. In my experience it doesn't matter where you create your models, because using a compound property model will automatically create propertymodels on your nested components anyway. Each component needs its own model anyway, to get and set its value. Met vriendelijke groet, Kind regards, Bas Gooren Op 25-6-2013 16:20, schreef gmparker2000: Considering two alternative ways to set a model: ... final CompoundPropertyModel myModel = new CompoundPropertyModel(myObject); control1.setModel(myModel.bind(field1)); control2.setModel(myModel.bind(field2)); control3.setModel(myModel.bind(field3)); ... and ... control1.setModel(new PropertyModel(myObject, field1)); control2.setModel(new PropertyModel(myObject, field2)); control3.setModel(new PropertyModel(myObject, field3)); ... are there any performance benefits of one over the other? I profiled each and they appear equivalent from the number of objects created point of view. I just want to make sure that option two isn't doing something like serializing myObject for each control. It doesn't appear that this is happening but wanted to make sure. We are binding controls to fairly large nested Java Objects. Other than making sure to use LoadableDetachable models where possible are there any other strategies for making sure performance is optimal? For example, would setting the model on the form rather than on each control have any performance benefit? Thanks -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Model-performance-question-tp4659771.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: DataTable and unserializable data
Hi, Most wicket components use models and providers mainly so you can decide if the data should be serialized or not. You can control what kind of models are used, and how much data they serialize. If you use proper loadable detachable models, then wicket will not serialize your Contact instances. What happens is this: wicket renders your datatable, and if it (or something else on the page) contains stateful components, serializes the page. Now two things can happen (amongst others, and not mutually exclusive): A - a stateful component is invoked, e.g. the user clicks a link inside your datatable. Wicket now looks up the specific link inside your datatable (as it was last rendered), and load()s your model, and thus the Contact it points to. B - the page is re-rendered. Wicket basically removes all rows inside your datatable, and re-renders its based on your provider. A datatable is basically a fancy RefreshingView with some additional components, and as the name of that class points out: the contents are refreshed on each render. I haven't taken an in-depth look myself yet, but I'm sure this is explained in the excellent free wicket guide recently created by another wicket user: http://wicket.apache.org/learn/books/freeguide.html Met vriendelijke groet, Kind regards, Bas Gooren Op 21-6-2013 18:48, schreef Baptiste75: A thousand thanks, Sebastian! Your sample did it! Juste a last question, out of curiosity (if you have a clue): Did this exception occur because DataTable, after retrieving the user objects from the provider, *stores* them somewhere in an inner component? And so when the Page is serialized, the DataTable is too, and my objects Contact as well? Because then I am wondering the point for a DataTable to memorize the user data... I would expect it to iterate on them, display, and then get rid of them, transiently... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataTable-and-unserializable-data-tp4659659p4659678.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: DataTable and unserializable data
Hi, In your example, the loadableDetachableModel (LDM) doesn't help. It references the final object passed in to the model() method, which means the contact object is serialized. The point of using LDMs is that they only store a reference (e.g. an ID) of an object, and can re-create or lookup the actual object based on that reference. E.g.: ContactModel extends LDMContact { private long contactId; ContactModel(Contact contact) { setObject(contact); } setObject(Contact contact) { super.setObject(contact); this.contactId = contact != null ? contact.getId() : null; } load() { return this.contactId != null ? new ContactDao().find(contactId) : null; } } Met vriendelijke groet, Kind regards, Bas Gooren Op 21-6-2013 12:16, schreef Baptiste75: Is it possible to use an implementation of DataTable (like AjaxFallbackDefaultDataTable) with unserializable data? My page throws the usual NotSerializableException, in spite of using LoadableDetachableModel everywhere I can. I am tearing my hair out to understand where the problem comes from. Can someone please help? Thanks. I want to precise that I use a LoadableDetachableModel in the method model() of my DataProvider: @Override public IModelApplication model(final Contact object) { return new LoadableDetachableModelContact() { @Override protected Contact load() { return object; } }; } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/DataTable-and-unserializable-data-tp4659659.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: user interface design: if any error, textbox channge to red ... ...
Hi! Feedback messages are cleanup up (removed) after each request. The attribute modified you added to the component, remains in place if the page is stateful. That's why the field still has the error class after a reload. You can do a number of things to make this work, but the essence is that the attribute should only be updated if the form component has errors. You can then add this behavior (e.g. the attribute modifier) to all formcomponents when constructing the form. This can also be automated with a component instantiation listener. To only update the attribute if the component has errors, override method isEnabled on the behavior, cast the component to a FormComponent and return !formComponent.isValid(). Met vriendelijke groet, Kind regards, Bas Gooren Op 14-6-2013 15:03, schreef always_rick: I am able to do it with AttributeModifier.append( class, error ). However, if I press F5, the feedback message disappears, the textbox remains red. It seems that error stays there forever. Did I missing something? How does the feedback message work? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/user-interface-design-if-any-error-textbox-channge-to-red-tp4659495.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
Custom markup cache key in hierarchy
Hi *, We've built a platform which hosts dynamic websites. Websites can be added/updated/removed on demand, and all run on a single wicket application (wicket 1.5-based). So far we've used custom css to override the look feel for each websites, providing the websites with a selection of themes (css + images). One of the features we're currently researching is to allow a theme to provide custom html to the wicket base page which is used for layout. We've also built a CMS in wicket, so using IMarkupResourceStreamProvider and IMarkupCacheKeyProvider is something we've done before. So far, so good. The problem is that we have various pages in the app which extend our base page (WebsiteLayout), and their markup is not refreshed once the layout changes it's theme (and thus has different html). Even though we return a different markup cache key (it's based on the theme ID), and a different markup resource stream, the new markup is never loaded. I think it's due to the fact that pages which extend the layout also have their entire markup cached (MergedMarkup). My original idea was to only provide a custom cache key for the layout, and let wicket handle everything else. Then, when the theme html is updated, we can simply remove that single cache key from the wicket markup cache, and it will be reloaded. I think we can circumvent that by providing a custom markup cache key for all pages which extend the layout, but that creates a bit of a hassle for cleaning up the markup cache. It's doable (keep track of all cache keys generated for a theme, and remove all of them from the cache), but before we proceed I'd like some feedback from others: is this the way to go? -- Met vriendelijke groet, Kind regards, Bas Gooren
Re: Session creation with stateless pages in Chrome
Hi! Ok, so just to confirm: your original post states that you see a bound wicket session when loading a stateless page with google chrome, but Session.bind() is never called? For as far as I know when wicket binds a sessions it always does so through Session.bind(). So if that is not called, there's another piece of code outside wicket which binds the session. Do you have any other servlets or servlet filters in place? How do you know a wicket session is bound? And how are you checking if Session.bind() is called? Met vriendelijke groet, Kind regards, Bas Gooren Op 29-5-2013 8:36, schreef ChambreNoire: That's the problem. Session.bind() isn't called. I put a breakpoin in AbstractHttpSessionStore.bind() but still it's hard to tell what's causing this to be called... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Session-creation-with-stateless-pages-in-Chrome-tp4659106p4659122.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: Session creation with stateless pages in Chrome
Have you checked if Chrome is prefetching other pages (which may be stateful)? Met vriendelijke groet, Kind regards, Bas Gooren Op 28-5-2013 12:14, schreef ChambreNoire: Hello folks, I have rendered all of my pre-login wicket pages fully stateless. I have just noticed that while no wicket sessions are created until a valid login occurs using most browsers, when accessing the site via Google Chrome, the wicket session is bound after the initial rendering. As for various reasons I have opted to extract cetain pageparameters within the wicket session constructor, this is problematic. I suppose could always move this pageparameter extraction into the various stateless pages which need these parameters (and thus duplicate it) however I'd like to know why on earth this happens exclusively with Google Chrome (in case it's symptomatic of some other undetected problem). Any ideas? Thanks, Anthony -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Session-creation-with-stateless-pages-in-Chrome-tp4659106.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: Session creation with stateless pages in Chrome
Simply by having a look at your tomcat (or reverse proxy) access log? Of course this is only needed if the page you are hitting has links to other, stateful pages. You can also set a breakpoint in Session.bind() to see when it's called. Met vriendelijke groet, Kind regards, Bas Gooren Op 28-5-2013 15:59, schreef ChambreNoire: How would I check this? I disabled Predict network actions to improve page load performance but that hasn't changed anything. Thanks -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Session-creation-with-stateless-pages-in-Chrome-tp4659106p4659111.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: Attaching Ajax Function to Java Method
Select2's wicket integration should provide you with some pointers [1]. It basically points down to implementing a listener interface, and providing the url to it to your javascript code. You can then return your data when the listener interface's method is called. [1] https://github.com/ivaynberg/wicket-select2/blob/master/wicket-select2/src/main/java/com/vaynberg/wicket/select2/AbstractSelect2Choice.java Met vriendelijke groet, Kind regards, Bas Gooren Op 14-5-2013 22:36, schreef William Speirs: I'm trying to create a typeahead component for Wicket that uses Bootstrap's Typeahead: To set this up though I need to provide the .typeahead method in JavaScript with a function that will return the results, given the query. What I'd like to do is attach that JavaScript function to a Java method much like what is done with an AjaxEventBehavior [2]. I cannot figure out how to go about setting all of this up... any ideas? Thanks... Bill- [1] http://twitter.github.io/bootstrap/javascript.html#typeahead [2] http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/ajax/AjaxEventBehavior.html
Re: Mount CSS resources in jar module
Hi, We've written a (wicket 1.5) class for this: ClassResourcesMapper. It allows you to map all resources under a class (the scope) at a fixed url. I've put it on pastebin: http://pastebin.com/0vGHCRMs Met vriendelijke groet, Kind regards, Bas Gooren Op 3-5-2013 9:02, schreef Herman Suijs: Hi all, I'm working on multiple portals which use a common-wicket jar containing HTML, styling and some common components. I'm using Wicket 1.5. What I'm trying to do is to render the css in the AbstractPage in this jar module as /css/screen.css. Because I don't have an Application class in common-wicket, I use an Initializer to create a SharedResource: SharedResources sharedResources = application.getSharedResources(); sharedResources.add(css/screen.css, new CssPackageResource(this.getClass(), css/screen.css, null, null, null)); sharedResources.add(css/print.css, new CssPackageResource(this.getClass(), css/print.css, null, null, null)); screen.css imports other css files from the same directory. As far as I know I need to have the css/screen.css relative to the Initializer above, so it can find the screen.css and the css to import. But I'm not sure. In the AbstractPage I render the CSS like this: response.renderCSSReference(new SharedResourceReference(CommonWicketInitializer.class, css/screen.css), screen); response.renderCSSReference(new SharedResourceReference(CommonWicketInitializer.class,css/print.css), print); This gives me a url in the HTML: link rel=stylesheet type=text/css href=../resource/my.package.view.CommonWicketInitializer/css/screen-ver-1367498513000.css media=screen / I've tried to do mountResource on the screen.css: ICompoundRequestMapper rootRequestMapperAsCompound = application.getRootRequestMapperAsCompound(); rootRequestMapperAsCompound.add(new ResourceMapper(css/screen.css, new PackageResourceReference(this.getClass(), css/screen.css))); This makes my screen.css available as /css/screen.css, but the imported css files cannot be retrieved. I've been looking for a way to mount /css and all beneath it, but I've found no way to do that yet. Maybe someone can help me with this. Thanks.
Re: Session messages
Hi, Since you are redirecting to another stateless page (setResponsePage(Class)), the browser is redirected to the new url which creates a new, temporary session for the second request. If you don't link to another page (so no setResponsePage call), it will work, since the response is rendered in the same request cycle as the request. Met vriendelijke groet, Kind regards, Bas Gooren Op 30-4-2013 17:44, schreef Bertrand Guay-Paquet: Hi, This is not the behavior I'm getting. I created a stateless page with this: add(new FencedFeedbackPanel(feedback)); add(new StatelessLinkVoid(success) { @Override public void onClick() { getSession().info(Success message (without bind())); setResponsePage(SessionMessagePage.class); } }); add(new StatelessLinkVoid(successBind) { @Override public void onClick() { getSession().bind(); getSession().info(Success message (with bind())); setResponsePage(SessionMessagePage.class); } }); The success link does not display a session message in the feedback panel if the session is temporary. It does work when the session is bound however. I stepped inside FenceFeedbackPanel#newFeedbackMessagesModel() and compared the Session object returned by getSession() there and in the success link. They are not the same java object. On 30/04/2013 7:07 AM, Martin Grigorov wrote: Hi, Wicket uses temporary Sessions for stateless application. Adding a feedback message to such session will live till the end of the current request. Since the response page is rendered in the same request/response cycle the feedback messages should be still reachable. On Mon, Apr 29, 2013 at 11:41 PM, Bertrand Guay-Paquet ber...@step.polymtl.ca wrote: Hello, When using the Sessions info(), error() and success() methods, and the session is not bound, the messages are lost. This can happen easily when on stateless pages. The fix for this is easy: I need to make sure the session is bound and call Session.bind(). However, I think it would be nice for the Session to get bound automatically when adding messages to it. Otherwise, the messages are silently discarded and the cause is not so obvious. What do you think, should I open an issue for this? Regards, Bertrand --**--**- To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.orgusers-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: User data during request of AuthenticatedWebSession
Andre, Your listener will also be called for resources served by wicket, so my guess is you have 1-7 resources on your page which are served by wicket. E.g. resources you store next to your pages (inside the same java package). So my guess is that you're not seeing multiple hits to onBeginRequest for a single request, but simply multiple requests to wicket. If you only want to handle requests to pages inside your listener, you can do so by overriding onRequestHandlerResolved instead: void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler) { if(handler instanceof IPageClassRequestHandler) { // This is a request to a page, or a component on a page } } Met vriendelijke groet, Kind regards, Bas Gooren Op 24-4-2013 22:34, schreef Andre Schütz: Hello, thank you for the answers. I created my own RequestCycleListener and have another question. public MyRequestCycleListener extends AbstractRequestCycleListener { public onBeginRequest(RequestCycle cycle) { super.onBeginRequest(cycle); MyAuthenticatedSession session = (MyAuthenticatedSession)Session.get(); if (session.isSignedIn()) { System.out.println(Is signed in); // this is planned // String email = session.getAuthenticatedMail(); // ObjectId userID = userDAO.getUserID(email); // cycle.setMetaData(userID, userID); } else { System.out.println(Is not signed in); } } } public MyApplication extends AuthenticatedWebApplication { public void init() { super.init(); IRequestCycleListener cycle = new MyRequestCycleListener(); getRequestCycleListener().add(cycle); } } public MyPage extends WebPage() { public MyPage ... } My question is as follows: I load MyPage and the onBeginRequest method is called multiple times during the load of the page (between 2 and 8 times) and displays the lines Is signed in. I planned to store the email ID of the User in the session and load the User data in the onBeginRequest function of the RequestCycleListener. But ... I only want to load the User data once per request. What do I wrong? Any help? Thanks, Andre On Mon, 22 Apr 2013 11:03:43 +0530 vineet semwal vineetsemwa...@gmail.com wrote: yes,you can store some key in session like emailId and then retrieve and store the user and related data in request cycle metadata ,as you are storing in requestcycle metadata ,scope of the data will be for the whole request only . no need to create your own requestcycle for that,create your requestcycle listener which onbeginrequest stores the user related data in requestcycle metadata On Mon, Apr 22, 2013 at 1:55 AM, Andre Schütz andre-p...@gmx.de wrote: I plan to implement a project with AuthenticatedWebApplication. The users have to sign up for an account. My question is regarding the user data that I have to load during each request of the single pages. The project will be as follows: (1) User logs into the system (2) The dashboard will be loaded (3) The user clicks the menu and gets a different representation of the information I would like to know the following two things: (a) The user registers with his email and a password (The email is unique in the database). I wanted to store the email in the AuthenticatedWebSession and load the desired user data during each request of a WebPage. Would that be a good idea? (b) I read in the documentation about the WebRequestCycle. Would it be useful to implement an own WebRequestCycle for the loading of the user data? I hope to hear some opinions. Thanks in advance. Andre - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- regards, Vineet Semwal
Re: Does getRenderBodyOnly need to be final?
Since you have a base panel class, why not call setRenderBodyOnly() in onInitialize or onConfigure based whatever logic you planned to put in getRenderBodyOnly()? Met vriendelijke groet, Kind regards, Bas Gooren Op 1-4-2013 19:20, schreef Chris Colman: I've come across a HTML/CSS template that is sensitive to the spans wicket places in various places and would like to do a global remove of these but don't want to have to call setRenderBodyOnly(true) on every component if I can avoid it. I thought that maybe I could override getRenderBodyOnly in my app's base panel class so that all panels are automagically affected but I discovered that getRenderBodyOnly is marked as final in the framework. Is there any reason for this? It could be really useful to override this. Yours sincerely, Chris Colman Pagebloom Team Leader, Step Ahead Software pagebloom - your business your website growing together Sydney:(+61 2) 9656 1278 Canberra: (+61 2) 6100 2120 Email: chr...@stepahead.com.au mailto://chr...@stepahead.com.au Website: http://www.pagebloom.com blocked::http://www.pagebloom.com/ http://develop.stepaheadsoftware.com blocked::http://develop.stepaheadsoftware.com/
Re: Tracking performance issues on requests best practices
We use New Relic extensively, which allows us to (a) annotate key parts of the app we wish to monitor, and (b) allow profiling in production, if we ever need it. I'm not affiliated with New Relic, just a happy user of it. Please note that it's not a free tool, but given the ease of use (it's very easy to set up) I've never looked back. In case you want a free solution: run your app through a profiler to see where most time per request is spent. Met vriendelijke groet, Kind regards, Bas Gooren Op 1-4-2013 21:45, schreef Serban.Balamaci: Hello guys, I'm trying to have a finer look at what is taking time on the serverside in our application. What I have so far is that I'm using Spring AOP to track down calls to all the methods and time to the Services layer. PS: I'm using JETM http://jetm.void.fm/ (it may be old, but is simple and give pretty much what you need). 2. I've collected the time for the whole request to process in a AbstractRequestCycleListener onBeginRequest, onEndRequest so as to see a sum of the total time spent on a particular usecase. What I've expected to find is that most of the resulting time would be spent in the services layer and pretty much summed up to be near the request time on the requestcyclelistener. Practical data shows however otherwise, with the sum of the service time not even close to the total of the request time. 3. So I've fine tuned the result to also show the rendering time for the components taking as example RenderPerformanceListener which measure the time between component onBeforeRender and onAfterRender. It's pretty nice to see in jetm hierarchycal component-services call, however it still not nearly close to the whole request time. I'm still looking and seeing that there is some logic also on some component's constructors and also onInitialize() methods that I see no easy way to measure them. IComponentInitializationListener seems to only trigger after initialization, I see no easy way to mark the start time of the onInitialize() and collect the time in the listener. So I'm asking if anyone got an idea, or I'm interested what you guys usually do to track down any performance issues in the app. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Tracking-performance-issues-on-requests-best-practices-tp4657676.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:for behavior
We're still on wicket 1.5, so I don't know if this still applies in 6.x, but the reason for this is that the wicket:for handler is executed in the same order as your html. That means that, since your wicket:for is after the input itself, calling setOutputMarkupId() on it no longer has any effect during that render. The solution is quite simple: wrap the input in the label: label wicket:for=id3 input wicket:id=id3 ... wicket:message .../ /label In this scenario the wicket:for is always handled before the input. Met vriendelijke groet, Kind regards, Bas Gooren Op 14-3-2013 5:01, schreef Maxim Solodovnik: Hello, I'm trying to use wicket:for as follows: input wicket:id=rememberMe type=checkbox /label wicket:for=rememberMewicket:ommessage key=288 //label https://svn.apache.org/repos/asf/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/auth/SignInPage.html the resulting HTML is: tdinput type=checkbox name=rememberMelabel for=id3Remember login/label/td http://demo.dataved.ru/openmeetings/html and label for is not working :( Am I using this feature improperly? Wicket 6.6.0 is used Thanks in advance
Re: Page Hierachy and Packages
Hi David, The auto linking using wicket:link resolves based on actual location on disk if I'm not mistaken. In other words: if you want to link to the homepage from inside the auth package, you should use: ../HomePage.html This means the link will also work if you are previewing the html outside of wicket. Met vriendelijke groet, Kind regards, Bas Gooren Op 8-3-2013 18:02, schreef David Beer: Hi Sven Will try and be more clear. I have fixed the css styling thanks to your suggestion on moving the link out of wicket:head. My question is that if I am navigating From my AdminPage in my auth package to the HomePage in the package above how do I add the link in the HTML. As Then AdminPage is trying to link to a file in the same package using wicket:link? Thanks David On 8 March 2013 16:53, Sven Meier s...@meiers.net wrote: Hi David, if your post was a question, I didn't understand it. Regards Sven On 03/08/2013 05:15 PM, David Beer wrote: Hi Sven Thanks for this so it is better to add the css outside of the wicket:head like you would with normal html pages. Is it possible to get the navigation to go up a level so to navigate to HomePage actually points to the HomePage in the correct package and as mounted at HomePage. Thanks David On 8 March 2013 14:39, Sven Meier s...@meiers.net wrote: Hi, if you keep style.css in your web root, you'll have to remove the wicket:link tag in your markup. Otherwise AutoLinkResolver will think yoy're keeping the css beside your component. Sven On 03/08/2013 03:17 PM, David Beer wrote: Hi All I am new Wicket and like what I have found so far. My problem is that I have created a few pages and forms and placed them in a package named auth. I can navigate to the pages easily but they don't seem to inherite the CSS from the BasePage which is in a different package. Also any links to the HomePage which is in the default package is not found. My BasePage HTML looks like the following: html xmlns=http://www.w3.org/1999/xhtmlhttp://www.w3.org/1999/**xhtml http://www.w3.org/**1999/xhtml http://www.w3.org/1999/xhtml xmlns:wicket=http://wicket.apache.org/dtds.data/wicket-**http://apache.org/dtds.data/wicket-** xhtml1.4-strict.dtdhttp://**wicket.apache.org/dtds.data/** wicket-xhtml1.4-strict.dtdhttp://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd xml:lang=en lang=en head wicket:head wicket:link link rel=stylesheet type=text/css href=style.css/ /wicket:link /wicket:head /head body div id=container div id=header header wicket:id=headerpanel/ /div div class=content_container wicket:child/ /div div id=footer footer wicket:id=footerpanel / /div /div /body /html My AdminPage which is in the auth package is never finds the css file declared in the base page. My project structure is as follows: src/main/java/example/BasePage and HomePage src/main/java/example/auth/AdminPage and SignInPage and SignOutPage html xmlns:wicket=http://wicket.apache.org http://apache.org http://wicket.apache.org head meta http-equiv=Content-Type content=text/html; charset=UTF-8/ titleAdminPage/title /head body wicket:extend h2Welcome ADMIN!/h2 p This page should only be accessible if you are signed in as an administrator. /p p wicket:linka href=HomePage.htmlHome/a /wicket:linkbr/ wicket:linka href=SignOutPage.htmlSign Out/a/wicket:link /p /wicket:extend /body /html I mount the pages in the xxApplication class as follows: mountPage(/Home, HomePage.class); mountPage(/guest-list, GuestListPage.class); mountPage(/auth/adminpage, AdminPage.class); mountPage(/auth/signin, SignInPage.class); mountPage(/auth/signout, SignOutPage.class); How can fix the navigation and the location of the css file so that it is found. The css file is located the Webapps dir. Thanks David --** --**- To unsubscribe, e-mail: users-unsubscribe@wicket.**apa**che.orghttp://apache.org users-unsubscribe@**wicket.apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org --** --**- To unsubscribe, e-mail: users-unsubscribe@wicket.**apa**che.orghttp://apache.org users-unsubscribe@**wicket.apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org --**--**- To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Forms do not reset after submit
Hi! What you describe should only happen in certain cases: - when you link to the page using a stored reference e.g. in ctor: myTargetPage = new MyTargetPage() in click handler: setResponsePage(myTargetPage); This results in a single, shared page instance. The page will keep track of state, and thus the state is shared. - when you create a new page instance (bookmarkable or not doesn't matter) for every click, but it's data comes from a static source (page-static, session-based or other) This means that your freshly created page instance loads data from a source which caches its data. E.g. your EntityFactory does not always return a fresh instance. So the first question is: how do you link to your Add a record page? Met vriendelijke groet, Kind regards, Bas Gooren Op 19-2-2013 17:12, schreef Michael Chandler: Good morning all! I thought I had a good handle on an issue I was having, but it appears as though that problem is persisting. When I present a form to the user to collect information that saves on a domain object, the form does not reset after the form has been submitted. At first, I thought it was related to how I link to pages, then I became convinced it was my use of a LoadableDetachableModel. Now, after refactoring the code several times, I'm convinced that I have over-looked something simple but I cannot figure out what it is. To summarize, I have a form that binds to an object as follows: CompoundPropertyModelJob jobModel = new CompoundPropertyModelJob((Job) EntityFactory.getInstance().getBean(job)); jobForm.setModel(jobModel); When the form fields are all completed and the form is submitted, the form's onSubmit() successfully handles the submission and my implementation persists the data to my domain object (Job) and the data is confirmed in the database. The last line conducts a redirect to the main screen with a setResponsePage() call. When I click the link to add a new record to the database using the same form, the form fields are populated with all of the same data I just entered, suggesting to me that the previous domain object is still bound to that page instead of refreshing and binding a clean, new instance of the Job class. Can anyone offer any tips or suggestions on what I am doing wrong? Best, Mike
Re: Forms do not reset after submit
Mike, That looks normal; you are creating a new JobAddPage for every click, so that's not the problem. Can you share some code from the JobAddPage? And is the EntityFactory class something you've built yourself? Met vriendelijke groet, Kind regards, Bas Gooren Op 19-2-2013 18:37, schreef Michael Chandler: This means that your freshly created page instance loads data from a source which caches its data. E.g. your EntityFactory does not always return a fresh instance. So the first question is: how do you link to your Add a record page? Bas, You are definitely describing the stateful nature of the behavior I'm seeing. I'm linking to add a record as follows: LinkString addJobLink = new LinkString(addJobLink){ private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(new JobAddPage()); } }; Mike -Original Message- From: Bas Gooren [mailto:b...@iswd.nl] Sent: Tuesday, February 19, 2013 9:20 AM To: users@wicket.apache.org Subject: Re: Forms do not reset after submit Hi! What you describe should only happen in certain cases: - when you link to the page using a stored reference e.g. in ctor: myTargetPage = new MyTargetPage() in click handler: setResponsePage(myTargetPage); This results in a single, shared page instance. The page will keep track of state, and thus the state is shared. - when you create a new page instance (bookmarkable or not doesn't matter) for every click, but it's data comes from a static source (page-static, session-based or other) This means that your freshly created page instance loads data from a source which caches its data. E.g. your EntityFactory does not always return a fresh instance. So the first question is: how do you link to your Add a record page? Met vriendelijke groet, Kind regards, Bas Gooren Op 19-2-2013 17:12, schreef Michael Chandler: Good morning all! I thought I had a good handle on an issue I was having, but it appears as though that problem is persisting. When I present a form to the user to collect information that saves on a domain object, the form does not reset after the form has been submitted. At first, I thought it was related to how I link to pages, then I became convinced it was my use of a LoadableDetachableModel. Now, after refactoring the code several times, I'm convinced that I have over-looked something simple but I cannot figure out what it is. To summarize, I have a form that binds to an object as follows: CompoundPropertyModelJob jobModel = new CompoundPropertyModelJob((Job) EntityFactory.getInstance().getBean(job)); jobForm.setModel(jobModel); When the form fields are all completed and the form is submitted, the form's onSubmit() successfully handles the submission and my implementation persists the data to my domain object (Job) and the data is confirmed in the database. The last line conducts a redirect to the main screen with a setResponsePage() call. When I click the link to add a new record to the database using the same form, the form fields are populated with all of the same data I just entered, suggesting to me that the previous domain object is still bound to that page instead of refreshing and binding a clean, new instance of the Job class. Can anyone offer any tips or suggestions on what I am doing wrong? Best, Mike - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Request scoped variables, in ajaxrequesttarget
Well, it's a lot simpler than that. Simply call rc.setMetaData( METAKEY_MYEVENTDATA, this ); Wicket handles the actual storage details (like storing your data in a MetaDataEntry array etc). Nothing you need to think about :-) Met vriendelijke groet, Kind regards, Bas Gooren Op 13-2-2013 15:31, schreef Oscar Besga Arcauz: Ok, it's a little complicated to create the metadata If I'm rigth, the process is - for example when click on an AjaxLink into the page 1- Execute the method onClick of the AjaxLink 2- Send an event to all the components of the page (the page itself included, on first place, but not other pages ?), - The source of the event is the page itself - The type of broadcast is BREADTH - The payload is the AjaxRequestTarget (from the onclick method call) / EXAMPLE OF DATA / public class MyEventData { static MetaDataKeyMyEventData METAKEY_MYEVENTDATA = new MetaDataKeyMyEventData(){}; String s = ; public MyEventData(){} public MyEventData(String s) { this.s = s; } public MetaDataKeyMyEventData getWicketMetadataData(){ // A little complicated MetaDataKeyMyEventData key = new MetaDataKeyMyEventData(){}; MetaDataEntryMyEventData metaDataEntry = new MetaDataEntryMyEventData(key,this); MetaDataEntryMyEventData[] arrayMetaDataEntry = new MetaDataEntry[]{metaDataEntry}; key.set(arrayMetaDataEntry,this); return key; } public void setIntoRequest(RequestCycle rc){ rc.setMetaData(getWicketMetadataData(),this); } public static MyEventData getFromRequest(RequestCycle rc){ return rc.getMetaData(METAKEY_MYEVENTDATA); } } Oscar Besga Arcauz -Ernesto Reinaldo Barreiro reier...@gmail.com escribió: - Para: users@wicket.apache.org De: Ernesto Reinaldo Barreiro reier...@gmail.com Fecha: 13/02/2013 13:00 Asunto: Re: Request scoped variables, in ajaxrequesttarget Hi Oscar, On Wed, Feb 13, 2013 at 12:54 PM, Oscar Besga Arcauz obe...@isdefe.eswrote: Hi wickers ! I was wondering If there's any method to have request-scoped variables ( as HttpServletRequest.get/setAttributes ) Specially with AjaxRequestTarget, in AJAX calls. Maybe RequestCycle#setMetaData might be useful for that. Regards - Ernesto Reinaldo Barreiro Antilia Soft http://antiliasoft.com/ http://antiliasoft.com/antilia - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Dynamic Components
Sure. After my original post we simplified the code a bit. This is the latest version we use in production. http://pastebin.com/WnxNVj2n This time I've set the paste to never expire. Met vriendelijke groet, Kind regards, Bas Gooren Op 12-2-2013 20:57, schreef Decebal Suiu: Hi Can I see the code. The pastebin show me a Unknown Paste ID! message on link [1]. [1] http://pastebin.com/p4cSNsUw Best regards, Decebal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dynamic-Components-tp4654308p4656289.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: Eclipse JRE 1.5
slf4j is a project which allows a project to implement logging, and the user of that project to decide which actual logging implementation to use. See http://slf4j.org/ Met vriendelijke groet, Kind regards, Bas Gooren Op 9-2-2013 14:59, schreef Stephen Walsh: Looked like there were some other items I needed to upgrade as well: maven compiler plugin, junit. There was one called sfl40j or similar. What is this used for? Thanks again for help! Learning a lot from you guys. Hope to contribute back once I really start understanding. New to java and wicket, so I'm very grateful. — Stephen Walsh On Sat, Feb 9, 2013 at 4:57 AM, Martijn Dashorst martijn.dasho...@gmail.com wrote: Also upgrade your maven-eclipse-plugin to use 2.9. Works much better on OS X. Martijn On Fri, Feb 8, 2013 at 12:08 AM, Stephen Walsh step...@connectwithawalsh.com wrote: This was the answer, Gabriel! Because my computer only has one JRE (1.6 with dev docs) installed, Eclipse was using it, but it appeared as though I was using 1.5. This minor change to my pom.xml solved it though! Thank you! ___ Stephen Walsh | http://connectwithawalsh.com On Thu, Feb 7, 2013 at 12:55 PM, Gabriel Landon glan...@piti.pf wrote: Hi Stephen, This did happen to me once! Did you check in your pom.xml that your source and target attributes are 1.6 ? plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-compiler-plugin/artifactId version2.5.1/version configuration * source1.6/source target1.6/target* optimizetrue/optimize debugtrue/debug showDeprecationtrue/showDeprecation showWarningstrue/showWarnings /configuration /plugin Regards, Gabriel. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Eclipse-JRE-1-5-tp4656164p4656170.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 -- Become a Wicket expert, learn from the best: http://wicketinaction.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket 6.5 CompoundPropertyModel constructor ambiguity
Well, from the looks of it it's a bit odd that you write new CompoundPropertyModelReportWebModel(reportWebModel) instead of new CompoundPropertyModelReport(reportWebModel) since ReportWebModel extends BaseWebModelReport The CPM constructor expects either a type literal or a model. In your case it is both, and you tell the CPM (through the generic type) that you will provide a type literal. Does your CPM have to be of type ReportWebModel? Met vriendelijke groet, Kind regards, Bas Gooren Op 25-1-2013 12:02, schreef Pieter Claassen: When I try to create the following model after migrating to wicket 6.5.0 new CompoundPropertyModelReportWebModel(reportWebModel) *where* ReportWebModel extends BaseWebModelReport *and* BaseWebModelT implements IModel My IDE (Intellij) shows no problem with type checking the code but when I try to compile it I get: java: reference to CompoundPropertyModel is ambiguous, both constructor CompoundPropertyModel(org.apache.wicket.model.IModelT) in org.apache.wicket.model.CompoundPropertyModel and constructor CompoundPropertyModel(T) in org.apache.wicket.model.CompoundPropertyModel match The problem goes away when I remove the generics but then I also lose the type checking. Any suggestions? Thanks, Pieter
Re: AjaxDownload file download example - how to delete serverside file after download
Hi, Looking at RequestHandlerStack reveals that only a single next request handler can be scheduled. So your code results in only the last request handler to actually be scheduled and executed. Since you do create two request handlers, I suspect you create your temporary file before it is actually requested. Since both handlers are constructed, that would explain why you see two temporary files. Instead of trying to schedule multiple request handlers, I'd try to find out why your file is not deleted. Set some breakpoints and find out why it is happening. Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 15:26, schreef RichLiv: I followed the example of this snippet https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html which very neatly shows how to download a file using AJAX. However, I can't seem to get the server file to delete after download - I added a nested class to handle the download and added it in the onRequest but it actually seems to add another server side file (so I suspect it triggers another temporary file create, as that is how I do my downloads) rather than delete the one just downloaded. Anyone spot the mistake ? private class MyDeleteFileHandler extends ResourceStreamRequestHandler { public MyDeleteFileHandler(IResourceStream resourceStream) { super(resourceStream); } @Override public void respond(IRequestCycle requestCycle) { super.respond(requestCycle); Files.remove(new File(AjaxDownload.this.getFileName())); } } . public void onRequest() { ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(getResourceStream(),getFileName()); handler.setContentDisposition(ContentDisposition.ATTACHMENT); getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler); ResourceStreamRequestHandler deleteHandler = new MyDeleteFileHandler(getResourceStream()); getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(deleteHandler); } Can there be only one handler scheduled and if so, can I chain them together somehow ? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxDownload-file-download-example-how-to-delete-serverside-file-after-download-tp4655682.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: Close tag not found while it's there
Is PlaceholderPanel a component defined by your application? It does not allow nested wicket components. Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 20:03, schreef Thies Edeling: With Wicket 6.5.0 I get a close tag not found error in one of my panels (worked for 1.4.x). Looking at the markup I don't see any obvious problems. Unexpected RuntimeException Last cause: Close tag not found for tag: wicket:container wicket:id=projectStatus id=id012. For PlaceholderPanel Components only raw markup is allow in between the tags but not other Wicket Component. Component: [PlaceholderPanel [Component id = 0]] Markup The problem is in file:/data/thies/projects/ehour/src/ehour_w15/eHour-wicketweb/target/classes/net/rrm/ehour/ui/timesheet/panel/ProjectOverviewPanel.html: wicket:container wicket:id=projectStatus div class=AggregateRow div class=foldCella wicket:id=foldLinkimg border=0 src=img/icon_up_off.gif wicket:id=foldImg//a/div div class=textCell style=width: 22% wicket:id=customerName[customerName]/div div class=textCell style=width:15% wicket:id=projectCode[projectCode]/div div class=textCell style=overflow:hidden;cursor:pointer wicket:id=projectNameContainerspan wicket:id=projectName[project name]/span/div div class=numbCell style=width:10% wicket:id=rate/div div class=numbCell style=width:8% wicket:id=monthHours24.50/div div class=numbCell style=width: 19% wicket:id=turnovereuro; 16.000/div /div span wicket:id=summaryRow/span /wicket:container
Re: find html tag
Hi! What you want to accomplish (e.g. changing some html attributes) can be done by adding an attributemodifier to each li component. In pseudocode: RepeatingView uls = ... for_every_li: WebMarkupContainer li = ... uls.add(li); now, you can do something like this: li.add(new AttributeAppender(...) { isEnabled() { return true if you want to append a html attribute; } }); Or alternatively: WebMarkupContainer li = new WMC() { onComponentTag(ComponentTag tag) { super(tag); tag.put(my-html-attribute, value); } } Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 20:45, schreef Michael Jaruska: Hi, is there a way I can find specific html tag in markup? I have this html structure: ul class=mymenu li a href=./mypage.html?cid=menumenu/a ul li a href=./mypage.html?cid=menu/submenusubmenu/a ul li a href=./mypage.html?cid=menu/submenu/subsubmenu1subsubmenu1/a /li li a href=./mypage.html?cid=menu/submenu/subsubmenu2subsubmenu2/a /li li a href=./mypage.html?cid=menu/submenu/subsubmenu3subsubmenu3/a /li /ul /ul /ul I'm processing clicks on anchors with my page: public PageTest(PageParameters parameters){ //cid = category id String category = parameters.get(cid).toString(); ... } Now I need some way I can add atribute into parent li tag of a tag on which I do click. Somethink like (pseudocode): public PageTest(PageParameters parameters){ //cid = category id String category = parameters.get(cid).toString(); //find corresponding a tag Tag anchorTag = go_from_top_ul_tag_and_find_a_tag_by_category(category) //have corresponding anchor tag, get parrent tag of the anchor tag Tag anchorParentTag = anchorTag.getParent(); //and now I can do my mysterious things with menu... } But I don't know where to start my search and I totaly don't know whot to look for in docu. Please, help :-) - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: find html tag
In that case I wouldn't bother trying this at the serverside. Theoretically you can access the html markup and fiddle with it, but that's generally not how wicket is meant to be used. (Trust me, we've been doing quite some advanced stuff with wicket over the years). If all you want to do is change the html code, you can also do that with some javascript code. E.g. override renderHead() in your page and contribute some javascript code for onLoad. But before doing such things: is there a particular reason why you are using static html instead of a component tree? Are you able and willing to switch to a component tree? Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 20:53, schreef Michael Jaruska: Problem is that uls and lis (let's call whole structure menu) is static html code. On 23.1.2013 20:50, Bas Gooren wrote: Hi! What you want to accomplish (e.g. changing some html attributes) can be done by adding an attributemodifier to each li component. In pseudocode: RepeatingView uls = ... for_every_li: WebMarkupContainer li = ... uls.add(li); now, you can do something like this: li.add(new AttributeAppender(...) { isEnabled() { return true if you want to append a html attribute; } }); Or alternatively: WebMarkupContainer li = new WMC() { onComponentTag(ComponentTag tag) { super(tag); tag.put(my-html-attribute, value); } } Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 20:45, schreef Michael Jaruska: Hi, is there a way I can find specific html tag in markup? I have this html structure: ul class=mymenu li a href=./mypage.html?cid=menumenu/a ul li a href=./mypage.html?cid=menu/submenusubmenu/a ul li a href=./mypage.html?cid=menu/submenu/subsubmenu1subsubmenu1/a /li li a href=./mypage.html?cid=menu/submenu/subsubmenu2subsubmenu2/a /li li a href=./mypage.html?cid=menu/submenu/subsubmenu3subsubmenu3/a /li /ul /ul /ul I'm processing clicks on anchors with my page: public PageTest(PageParameters parameters){ //cid = category id String category = parameters.get(cid).toString(); ... } Now I need some way I can add atribute into parent li tag of a tag on which I do click. Somethink like (pseudocode): public PageTest(PageParameters parameters){ //cid = category id String category = parameters.get(cid).toString(); //find corresponding a tag Tag anchorTag = go_from_top_ul_tag_and_find_a_tag_by_category(category) //have corresponding anchor tag, get parrent tag of the anchor tag Tag anchorParentTag = anchorTag.getParent(); //and now I can do my mysterious things with menu... } But I don't know where to start my search and I totaly don't know whot to look for in docu. Please, help :-) - 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: find html tag
Sorry, I read too quickly. What are you trying to accomplish? Let's say you are able to find the appropriate html tag, what do you want to do with it? Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 21:01, schreef Michael Jaruska: And question is not how can I change html attribute but how can I go through html structure and find html tag with specific attribute :-) On 23.1.2013 20:50, Bas Gooren wrote: Hi! What you want to accomplish (e.g. changing some html attributes) can be done by adding an attributemodifier to each li component. In pseudocode: RepeatingView uls = ... for_every_li: WebMarkupContainer li = ... uls.add(li); now, you can do something like this: li.add(new AttributeAppender(...) { isEnabled() { return true if you want to append a html attribute; } }); Or alternatively: WebMarkupContainer li = new WMC() { onComponentTag(ComponentTag tag) { super(tag); tag.put(my-html-attribute, value); } } Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 20:45, schreef Michael Jaruska: Hi, is there a way I can find specific html tag in markup? I have this html structure: ul class=mymenu li a href=./mypage.html?cid=menumenu/a ul li a href=./mypage.html?cid=menu/submenusubmenu/a ul li a href=./mypage.html?cid=menu/submenu/subsubmenu1subsubmenu1/a /li li a href=./mypage.html?cid=menu/submenu/subsubmenu2subsubmenu2/a /li li a href=./mypage.html?cid=menu/submenu/subsubmenu3subsubmenu3/a /li /ul /ul /ul I'm processing clicks on anchors with my page: public PageTest(PageParameters parameters){ //cid = category id String category = parameters.get(cid).toString(); ... } Now I need some way I can add atribute into parent li tag of a tag on which I do click. Somethink like (pseudocode): public PageTest(PageParameters parameters){ //cid = category id String category = parameters.get(cid).toString(); //find corresponding a tag Tag anchorTag = go_from_top_ul_tag_and_find_a_tag_by_category(category) //have corresponding anchor tag, get parrent tag of the anchor tag Tag anchorParentTag = anchorTag.getParent(); //and now I can do my mysterious things with menu... } But I don't know where to start my search and I totaly don't know whot to look for in docu. Please, help :-) - 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: find html tag
Ok, so you are indeed looking for a way to change a html attribute ;-) Since you wrote (in your folluw-up e-mail) that you cannot generate the html, there are some ways, but they mostly work outside of the normal wicket way. 1) In the component which actually renders your static html override onComponentTagBody and fiddle with the markup stream (e.g. look at replaceComponentTagBody) 2) store the static html somewhere by itself, and create a custom model. The model can then load the html and perform string replacement. You can then add a label component which uses the model and has setEscapeModelStrings(false) set. Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 21:11, schreef Michael Jaruska: I need to find the parent li tag of the anchor user clicks - I now from PageParameters which anchor has been clicked. Then I will put into this parent li specific atribute (id=something). This attribute will be then processed by JavaScript on the page. On 23.1.2013 21:04, Bas Gooren wrote: Sorry, I read too quickly. What are you trying to accomplish? Let's say you are able to find the appropriate html tag, what do you want to do with it? Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 21:01, schreef Michael Jaruska: And question is not how can I change html attribute but how can I go through html structure and find html tag with specific attribute :-) On 23.1.2013 20:50, Bas Gooren wrote: Hi! What you want to accomplish (e.g. changing some html attributes) can be done by adding an attributemodifier to each li component. In pseudocode: RepeatingView uls = ... for_every_li: WebMarkupContainer li = ... uls.add(li); now, you can do something like this: li.add(new AttributeAppender(...) { isEnabled() { return true if you want to append a html attribute; } }); Or alternatively: WebMarkupContainer li = new WMC() { onComponentTag(ComponentTag tag) { super(tag); tag.put(my-html-attribute, value); } } Met vriendelijke groet, Kind regards, Bas Gooren Op 23-1-2013 20:45, schreef Michael Jaruska: Hi, is there a way I can find specific html tag in markup? I have this html structure: ul class=mymenu li a href=./mypage.html?cid=menumenu/a ul li a href=./mypage.html?cid=menu/submenusubmenu/a ul li a href=./mypage.html?cid=menu/submenu/subsubmenu1subsubmenu1/a /li li a href=./mypage.html?cid=menu/submenu/subsubmenu2subsubmenu2/a /li li a href=./mypage.html?cid=menu/submenu/subsubmenu3subsubmenu3/a /li /ul /ul /ul I'm processing clicks on anchors with my page: public PageTest(PageParameters parameters){ //cid = category id String category = parameters.get(cid).toString(); ... } Now I need some way I can add atribute into parent li tag of a tag on which I do click. Somethink like (pseudocode): public PageTest(PageParameters parameters){ //cid = category id String category = parameters.get(cid).toString(); //find corresponding a tag Tag anchorTag = go_from_top_ul_tag_and_find_a_tag_by_category(category) //have corresponding anchor tag, get parrent tag of the anchor tag Tag anchorParentTag = anchorTag.getParent(); //and now I can do my mysterious things with menu... } But I don't know where to start my search and I totaly don't know whot to look for in docu. Please, help :-) - 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 - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Create/Edit domain object data
Nick, I'm not sure if anyone responded, so let me share how we deal with this. Since a JPA entity can reference other (persistent entities), and usually does, we've tried to never, ever, serialize JPA entities. The only time where it's needed is when you have an entity creation workflow which spans more than a single screen. For the cases where an entity is created using a single screen, we simply write a LDM which creates a new instance, setting defaults. Wicket then pushes all form fields to the entity on submit, and as a result we have an entity we can persist. Other possible strategies: - serialize the new entity inside a normal model (Model) - pre-create new entities, and have a flag on them which indicates their workflow state (NEW, ACTIVE etc); that way you can simply load them through whatever EntityDatabaseModel you have in place Met vriendelijke groet, Kind regards, Bas Gooren Op 7-12-2012 19:14, schreef Nick Pratt: Im looking for recommendations on how to work with Form data and a JPA/Hibernate model, specifically around creating and editing domain data. I have a JPA backed domain model, and I want to create a page/panel/form that allows entry of a new Foo, as well as being able to pass an existing LDMFoo to the Page/Panel so that I can edit it. Obviously I'd like to use an IModel for the domain object so that I dont end up serializing the DB in to the session, but at the same time, I cant use an LDM until the new entity is saved and an ID is assigned to the object. For the 'new' case, do you just serialize the domain entity in to the session, IModelFoo model = Model.of( new Foo() ); and let the Foo object be serialized until such time as the Foo.id is set so you can switch out the IModel ref to an LDM? Or is it best to just show the minimal number of fields required (*) to create a new Foo (accessed via PropertyModel(this, attributeName), save it, and then set the LDMFoo reference in the page and then let the other form elements be shown? (This approach duplicates code - the fields in the domain object are duplicated as primitives in the Page (which get serialized in to the session) ) The edit functionality needs to allow all fields to be edited (including the fields mentioned in (*) above) - I dont want to duplicate form markup and code - once for the 'new' case and once for the 'edit' case - the 'edit' case would have a lot more fields that could be entered/edited. Are there other approaches that I'm missing, and what is the best pattern to follow here?
Re: Parsing company id from url
Josh, We run the same kind of app, and what we did is simply consume the X-Forwarded-Host in the app server (see http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#x-headers). That way the url - website ID lookup is handled in the app itself. We have an IP especially for this app, and have set up a catch-all virtual host on apache (reverse proxy) which forwards all traffic to our wicket app. Met vriendelijke groet, Kind regards, Bas Gooren Op 23-12-2012 23:34, schreef Sven Meier: Hi Josh, LocaleFirstMapper from wicket-examples seems like something you're looking for, it reads the locale from the first url segment. Sven On 12/23/2012 10:33 PM, jchappelle wrote: I'm hoping this will be an easy question to answer for the wicket gurus out there. I'm developing an app that will have pages specific to companies. They will be able to configure styles and logos and all the pages will be branded for their company. The root url looks like http://server/app. I'm going to have an Apache web server proxy in front of it that looks like http://yourcompany that will proxy to the backing tomcat instance. My problem is that I'm not sure how to formulate a URL that wicket can use to parse the institution id. I was thinking that I could proxy http://company1 to http://server/app/1 and http://company2 to http://server/app/2. I'm not sure if this is a best practice for this situation but it seems reasonable. *Question* How do I parse this kind of parameter from within wicket? IRequestMapper? *Note* Some pages will be secured requiring the user to log in, and other pages will be publicly accessible. Thanks for your time. Josh -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Parsing-company-id-from-url-tp4655029.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
Is it possible to force a single incoming request to be parsed as iso-8859-1?
Hi *, We're integrating with a third party. They call a rest endpoint which we handle through wicket (a special page subclass). We run a full utf-8 stack, and during integration testing we encountered a weird problem. One of the post parameters (a bit of text) is showing the Unicode replacement character (U+FFFD), shown as h�ngt p� d� (when the actual content is hängt på dörr). After a bit of digging I found out that they send an application/x-www-form-urlencoded body without a charset specified. Tomcat thus parses it using the default setting (utf-8). So my problem is this: I get iso-8859-1 content, which is parsed as utf-8, which does not work. Is there a way to make wicket interpret this one request as iso-8859-1? I've taken a look at HttpServletRequest#setCharacterEncoding(), but calling that from within our endpoint (= wicket page) is too late. Wicket has already called ServletWebRequest#isAjax(), and thus post parameters have already been parsed. Unfortunately, I cannot re-interpret the string as latin1, as I don't have access to the original byte[] data. FYI: Wicket 1.5 -- Met vriendelijke groet, Kind regards, Bas Gooren
Re: Is it possible to force a single incoming request to be parsed as iso-8859-1?
Thanks! Since we're using guice-servlets that is a rather easy and elegant solution. Met vriendelijke groet, Kind regards, Bas Gooren Op 14-12-2012 12:57, schreef Martijn Dashorst: Use a servlet filter? Martijn On Fri, Dec 14, 2012 at 12:49 PM, Bas Gooren b...@iswd.nl wrote: Hi *, We're integrating with a third party. They call a rest endpoint which we handle through wicket (a special page subclass). We run a full utf-8 stack, and during integration testing we encountered a weird problem. One of the post parameters (a bit of text) is showing the Unicode replacement character (U+FFFD), shown as h�ngt p� d� (when the actual content is hängt på dörr). After a bit of digging I found out that they send an application/x-www-form-urlencoded body without a charset specified. Tomcat thus parses it using the default setting (utf-8). So my problem is this: I get iso-8859-1 content, which is parsed as utf-8, which does not work. Is there a way to make wicket interpret this one request as iso-8859-1? I've taken a look at HttpServletRequest#setCharacterEncoding(), but calling that from within our endpoint (= wicket page) is too late. Wicket has already called ServletWebRequest#isAjax(), and thus post parameters have already been parsed. Unfortunately, I cannot re-interpret the string as latin1, as I don't have access to the original byte[] data. FYI: Wicket 1.5 -- Met vriendelijke groet, Kind regards, Bas Gooren
Re: Dynamic Components
Hi, We've written the following class to dynamically add components to a page and then render them in an ajax request: http://pastebin.com/p4cSNsUw The rendered component is in the current page, not in a dummy page, so everything works as expected. The only thing that doesn't work is a full re-render, since that requires a hook in the page markup, which does not exist (hence dynamic components). To circumvent that, the dynamic components are automatically removed on a full page re-render. Have a look at the code, maybe it helps you. It's rather simple when you think about it. onInitialize() and ajax calls in the dynamically injected components work as expected for us. We use it in our (wicket 1.5) cms to dynamically inject editors and popups. Met vriendelijke groet, Kind regards, Bas Gooren Op 28-11-2012 21:00, schreef Nick Pratt: Martin The approach of adding the Sub/Details Panel to a DummyPage works fine for basic Panels, but there are a few problems I've hit: 1. onInitialize() isnt called - Im assuming this is because the Panel doesnt go through a normal lifecycle before being rendered back to the ART? 2. None of the Ajax/Links work - they are loading up the DummyPage Now Im assuming this is all because the Component/Panel on the server side isnt associated with a real live page? Following on from a discussion thread that Chris Colman was going on about IComponentResolvers and those components being second class citizens, would it be possible to create dynamic components in a Page, and store them in a non-markup related area of the Page, such that they would go through normal lifecycle events etc, and AJAX callbacks would work to the Page, but they wouldnt be associated with the normal markup/component hierarchy? Based on Chris' comments, it seems like he has the initial stages of a workable solution to breaking the Component / Markup hierarchy and allowing a very flexible way of building applications. While I dont know what else Component Queueing was going to add, it seems that such functionality would provide a way to break the current hierarchy matching requirement. In my specific case, Im ok if the Components get thrown away on a full page (re)render, or that if Components were instantiated and not referenced in the markup, then they could be thrown away. While this might not suit the core framework for v7.0, could I build such functionality using the existing v6 APIs (maybe via a custom BasePage/ Component wrapper) and hooking in to the rendering cycle? N
Re: File download through form submit feedback messages
Hi, Have a look at https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html and try to make it work in wicket 6 (should be easy). This allows you to do ajax updates (e.g. refresh the form) and then redirect the browser to the file. Met vriendelijke groet, Kind regards, Bas Gooren Op 22-11-2012 12:51, schreef juhar: Hi, I have a page with a form on it. After the user has submitted the form successfully (all the fields have validated ok), the server creates a report-file based on the form values. The file is not created as physical file on the server, but it is given as download to the user. Now, if the user first fills the form incorrectly, there are validator feedback messages shown. If the user then submits the form with correct values, the problem is that previous feedback error messages are not cleared. I can't also create a new feedback message saying something like The report was created successfully. The file download response prevents any updating of the current page. I tried submitting the form with ajax using AjaxButton, and was able to clear the feedback messages, but unfortunately it would not work on IE8... IE8 will warn you about the file with a pop-up, and after that the download will just disappear. Also any of my attempts to manually clear the feedback messages have failed. What would be correct way of creating this? I'm using Wicket6. This is the code I'm using currently (relevant bits only): // In the Panel-constructor form.add(new Button(createreportbutton) { @Override public void onSubmit() { createReport(); } }); // Generates the report, and response private void createReport() { // Generate report with something like: reportCommand.generateReport(formValues); final byte[] reportData = reportCommand.getReportData(); final String contentType = reportCommand.getContentType(); final String contentDisposition = reportCommand.getContentDisposition(); // Give the report as download getRequestCycle().scheduleRequestHandlerAfterCurrent( new IRequestHandler() { @Override public void detach(IRequestCycle reqCycle) { } @Override public void respond(IRequestCycle reqCycle) { WebResponse response = (WebResponse)reqCycle.getResponse(); HttpServletResponse res = (HttpServletResponse)response.getContainerResponse(); res.setContentType(contentType); res.setHeader(Content-Disposition, contentDisposition); try { res.getOutputStream().write(reportData); } catch (IOException ex) { ApplicationLogger.error(Error writing report to HTTP response, ex); } } }); } Thanks, Juha -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/File-download-through-form-submit-feedback-messages-tp4654087.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: String Resources associated with entity classes
Hi, So just to confirm: Say you have an entity House, you'll have House.class House.properties 1) where in the properties file you have a key Label with a value? 2) and in wicket you say getString(House.Label), or new ResourceModel(House.Label)? If this is the case, write a custom string resource loader, which takes the first part of the resource key, and checks if there is a matching entity with associated property file. Then use the other parts of the property key for the actual lookup in the property file. Met vriendelijke groet, Kind regards, Bas Gooren Op 27-10-2012 18:24, schreef Dieter Tremel: For every JPA entity class I have a associated properties file in a package called resources under the package of the entity classes. In the files the display label, title, description of the entity and it's attributes are given for internationalization. The keys in the files are not necessarily different for different classes, each class uses a Label key for it's display label. I tried to include this in the wicket resource mechanism by adding a ResourceLoader that uses a BundleStringResourceLoader for each entity class, which is used when a component or it's ancestor implement a EntityClassHolder Interface and can give an entity class. But this does not work, since the String Resources are cached for the first hit entity class, and the cache gives the reply for all other entity classes. So my idea was not sufficient :-( Of course I can write my own mechanism of getting the strings from the properties encapsulated in a model. But wickets resource handling is so sophisticated, that I suppose there is a more elegant way, I do not see. How would you implement resource loading fore files associated to entity classes, not to component hierarchy? Thank You Dieter Tremel - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Mount Page
There is nothing stopping you from calling getApplication() on any component, and casting that to a WebApplication. Using that webapp reference you can easily mount/unmount pages. Met vriendelijke groet, Kind regards, Bas Gooren Op 24-10-2012 17:31, schreef dpmihai: Can a page be mounted to an url from outside WebApplication? I am looking for a way to mount / unmount a page to / from an url when some link from a Panel is clicked. Is this possible? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Mount-Page-tp4653318.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 plugin architecture
Michal, I wrote a mapper which mounts all resources in a package at a fixed url. This eliminates the need for a mapper per resource. See http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-alternative-to-1-4-shared-resources-class-aliases-td4652842.html Met vriendelijke groet, Kind regards, Bas Gooren Op 18-10-2012 16:35, schreef Michal Wegrzyn: In Initializer implementation I do something like: PackageResourceReference logoReference = new PackageResourceReference( MyInitializer.class, img/custom_header_logo.png ); WebApplication.get().getSharedResources().add( img/custom_header_logo.png, logoReference.getResource() ); WebApplication.get().mountResource( img/custom_header_logo.png, logoReference ); It makes for every mounted image new request mapper. Won't it be a problem for a lot of custom images? Best regards, Michal Wegrzyn -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Thursday, October 18, 2012 16:24 To: users@wicket.apache.org Subject: Re: Wicket plugin architecture On Thu, Oct 18, 2012 at 4:21 PM, Michal Wegrzyn michal.wegr...@onior.com wrote: Thank you all for suggestions. Finally I have used Wicket's org.apache.wicket.IInitializer (as pointed Martin) together with org.apache.wicket.Application.setMetaData(MetaDataKeyT key, Object object) for configuration. Implementing more complex solution is not necessary unless you need advanced runtime plugin mechanism. For custom plugin CSS/JS I use metadata and render all extra resource references on pages. Images are mounted as shared resources. It works, but for large amount of images it will not be efficient. Question: do you know a better Wicket-way to handle custom images? Please explain how you use the shared resources and what will be not optimal with them. Then we can try to find a better solution. Best regards, Michal Wegrzyn -Original Message- From: Martin Grigorov [mailto:mgrigo...@apache.org] Sent: Tuesday, September 25, 2012 10:48 To: users@wicket.apache.org Subject: Re: Wicket plugin architecture Hi, The simplest way is to use Wicket's org.apache.wicket.IInitializer class. Just create a Jar (the plugin) that contains the plugin classes and wicket.properties in the root package and a line inside: initializer=com.example.MyInitializer MyInitializer#init(Application) will be called just before MyApp#init(). In this method you can add whatever your plugin provides to the global configuration On Tue, Sep 25, 2012 at 11:35 AM, Michal Wegrzyn michal.wegr...@onior.com wrote: Dear developers, I need to prepare plugin architecture for a Wicket based project. I've found that open source Hippo CMS ( http://svn.onehippo.org/repos/hippo/ ) does it, but I am curious if there are any other projects that do such a thing? Do you maybe know this kind of projects or frameworks? Are there any important in-depth aspects of Wicket of which should I be aware of for creating plugin architecture? Best regards, Michal Wegrzyn -- 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 -- 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: Add an invisible component to an AjaxRequestTarget target
Thijs, We've been working with wicket for a number of years now, and yes, we have two rules (that feel very natural after those years...): - Do I need to replace this component over AJAX: call setOutputMarkupId(true) - Idem, but can the component itself be hidden (usually quite visible as we override onConfigure() to control visibility): call setOutputMarkupPlaceholderTag(true). The beauty of wicket is that it is quite clear if you forget. The AJAX Debug window in the bottom right of your browser window will turn red, and once you open it, will say it cannot replace a component since it's not in the markup. Met vriendelijke groet, Kind regards, Bas Gooren Op 17-10-2012 9:52, schreef Thijs: On 17-10-2012 9:40, Martin Grigorov wrote: Hi, On Wed, Oct 17, 2012 at 9:27 AM, Thijs vonk.th...@gmail.com wrote: Revisiting this. I'm still having some troubles with this. Say I have: Label a; add(a = Label(...) { onConfigure(){setVisible(*false due to some condition*)}}); a.setOutputMarkupId(true); add(new AjaxLink(..){ onClick(AjaxRequestTarget t){t.add(a);} }; In this case the debug window will start calling mayhem as clearly label a is not on the page so it can't find the component to update. So my question is: Is it common practice to always do something like: AjaxLink(){ onClick(AjaxRequestTarget t){ if(a.isVisibleInHierarchy()) t.add(a); } } Or should I always do: add(a = Label(...) { onConfigure(){setVisible(*false due to some condition*)}}); a.setOutputMarkupId(true); showPhoto.setOutputMarkupPlaceholderTag(true); I think you need : a.setOutputMarkupPlaceholderTag(true), not sure what 'showPhoto' is. Yes correct. setOutputMarkupPlaceholderTag(true) calls setOutputMarkupId(true) for you, so there is no need to call both of them. Or could the AjaxRequestTarget be modified to do the isVisibleInHierarchy() before actually rendering the component? This is possible but it will lead to more confusion. In this case your component wont be modified at all and there wont be any indication. We can add a WARN in the logs but my experience shows that not many developers actually follow the logs. Not sure what the issue would be with this. As the component isn't visible on the anyway. But basically your answer is: Yes when you add a component to the AjaxRequestTarget that might not be visible, make sure that setOutputMarkupPlaceholderTag(true) is always called on that component?! Thanks On 6-9-2012 22:47, Thijs Vonk wrote: OK thnx will give it a try On 6/9/12 22:39, Igor Vaynberg wrote: isVisibleInHierarchy() will make sure all parents are visible as well -igor On Thu, Sep 6, 2012 at 1:27 PM, Thijs Vonk vonk.th...@gmail.com wrote: Hi, We have partial page updates all over a page. So panels and components all over the place that need Ajax updates. We're using an Interface on those components and with an IVisitor we traverse the component tree and add every component to the target that has this interface. But during development we see that we get errors in the ajax debug log when these components have an invisible state. These components themselves can have this state but some of the times, the parent component is invisible. In these cases when such a hidden component is added to the AjaxRequestTarget we get an error in the ajax debug log. Adding the isVisible check before adding the component to the target could save us in some situations but not all (as it might get visible or invisible) at a later state. How can I prevent these components from being added to the AjaxRequestTarget? Or from the error being thrown? I had hoped that a component being in an invisible state (somewhere in the tree) wouldn't get rendered. It's not really a problem in a 'deployment' situation, but it's not 'nice' either. Thijs - 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 - 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: Add an invisible component to an AjaxRequestTarget target
And to add to this: make sure you call setOutputMarkupPlaceholderTag(true) before you render the (possibly invisible) component for the first time. Suppose your component is hidden (setVisible(false)) on the first render. If you now call setOutputMarkupPlaceholderTag(true) in the ajax request that needs to repaint the component, it still won't work as there is no markup placeholder. So call setOutputMarkupPlaceholderTag(true) when you create the component :-) Met vriendelijke groet, Kind regards, Bas Gooren Op 17-10-2012 9:57, schreef Martin Grigorov: On Wed, Oct 17, 2012 at 9:52 AM, Thijs vonk.th...@gmail.com wrote: On 17-10-2012 9:40, Martin Grigorov wrote: Hi, On Wed, Oct 17, 2012 at 9:27 AM, Thijs vonk.th...@gmail.com wrote: Revisiting this. I'm still having some troubles with this. Say I have: Label a; add(a = Label(...) { onConfigure(){setVisible(*false due to some condition*)}}); a.setOutputMarkupId(true); add(new AjaxLink(..){ onClick(AjaxRequestTarget t){t.add(a);} }; In this case the debug window will start calling mayhem as clearly label a is not on the page so it can't find the component to update. So my question is: Is it common practice to always do something like: AjaxLink(){ onClick(AjaxRequestTarget t){ if(a.isVisibleInHierarchy()) t.add(a); } } Or should I always do: add(a = Label(...) { onConfigure(){setVisible(*false due to some condition*)}}); a.setOutputMarkupId(true); showPhoto.setOutputMarkupPlaceholderTag(true); I think you need : a.setOutputMarkupPlaceholderTag(true), not sure what 'showPhoto' is. Yes correct. setOutputMarkupPlaceholderTag(true) calls setOutputMarkupId(true) for you, so there is no need to call both of them. Or could the AjaxRequestTarget be modified to do the isVisibleInHierarchy() before actually rendering the component? This is possible but it will lead to more confusion. In this case your component wont be modified at all and there wont be any indication. We can add a WARN in the logs but my experience shows that not many developers actually follow the logs. Not sure what the issue would be with this. As the component isn't visible on the anyway. Exactly! The component is invisible and your logic modifies something in it and tries to repaint it. So it seems you actually want to make it visible. But with your proposal to just ignore it if it is invisible then this will be very confusing, IMO. But basically your answer is: Yes when you add a component to the AjaxRequestTarget that might not be visible, make sure that setOutputMarkupPlaceholderTag(true) is always called on that component?! Right. Thanks On 6-9-2012 22:47, Thijs Vonk wrote: OK thnx will give it a try On 6/9/12 22:39, Igor Vaynberg wrote: isVisibleInHierarchy() will make sure all parents are visible as well -igor On Thu, Sep 6, 2012 at 1:27 PM, Thijs Vonk vonk.th...@gmail.com wrote: Hi, We have partial page updates all over a page. So panels and components all over the place that need Ajax updates. We're using an Interface on those components and with an IVisitor we traverse the component tree and add every component to the target that has this interface. But during development we see that we get errors in the ajax debug log when these components have an invisible state. These components themselves can have this state but some of the times, the parent component is invisible. In these cases when such a hidden component is added to the AjaxRequestTarget we get an error in the ajax debug log. Adding the isVisible check before adding the component to the target could save us in some situations but not all (as it might get visible or invisible) at a later state. How can I prevent these components from being added to the AjaxRequestTarget? Or from the error being thrown? I had hoped that a component being in an invisible state (somewhere in the tree) wouldn't get rendered. It's not really a problem in a 'deployment' situation, but it's not 'nice' either. Thijs - 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 - 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 and file upload with blueimp jquery file upload
Hi! We use a different uploader (uploadify), but the basics are the same. What we've built for this is a behavior which renders the UI for the uploader, and handles ajax callbacks. The uploader uploads to a mounted resource (e.g. at /uploadify), which has an internal cache (UUID = FileInfo). After a successful upload, the upload resource returns the UUID; The javascript onComplete handler then calls the ajax behavior with the UUID parameter, which allows other components in the page to respond to the upload. To prevent overflow in the uploader cache we use a map with a maximum size which evicts old entries on overflow. Met vriendelijke groet, Kind regards, Bas Gooren Op 16-10-2012 12:59, schreef heapifyman: Not sure if I understand. As far as I got it, the upload plugin requires some web service that accepts POST and DELETE requests to add/remove uploaded files. Doing that is no problem, I guess. But how to I link this with the current user's wicket session so that I know which files the users uploaded when finally the form is submitted? I'm not sure if I'm using the right wording here. Hope you get the idea... 2012/10/16 Martin Grigorov mgrigo...@apache.org Hi, Is it an option to upload to a IResource and store the uploaded data the same way as if you'd do in the page ? On Tue, Oct 16, 2012 at 12:49 PM, heapifyman heapify...@gmail.com wrote: Hello, has anyone tried yet to integrate blueimp's jQuery File Upload http://blueimp.github.com/jQuery-File-Upload/ with Wicket FileUpload? Especially in combination with additional input fields input type=text I'm kind of stuck because I'm not really sure where to point the jquery file upload's url param to and how to store the uploaded files in the wicket page for saving them when the complete form is submitted. Any help would be appreciated. Thanks -- 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
Re: Wicket and file upload with blueimp jquery file upload
Behavior (wicket 1.5): http://pastebin.com/WUHsiRL2 instance.js (to initialize uploadify): http://pastebin.com/jGSwzHMN Mount it in Application.init() with: // Allow uploads through uploadify mount( new UploadifyBehavior.Uploader( /uploadify ) ); Use it like this: component.add( new UploadifyBehavior() { @Override protected void onUpload( UploadInfo info, AjaxRequestTarget target ) { // Handle upload any way you like, and replace stuff in this ajax request } } ); Met vriendelijke groet, Kind regards, Bas Gooren Op 16-10-2012 19:09, schreef heapifyman: Thanks. Would you mind sharing the mounted resource's code? I'm not completely sure how to implement that. 2012/10/16 Bas Gooren b...@iswd.nl Hi! We use a different uploader (uploadify), but the basics are the same. What we've built for this is a behavior which renders the UI for the uploader, and handles ajax callbacks. The uploader uploads to a mounted resource (e.g. at /uploadify), which has an internal cache (UUID = FileInfo). After a successful upload, the upload resource returns the UUID; The javascript onComplete handler then calls the ajax behavior with the UUID parameter, which allows other components in the page to respond to the upload. To prevent overflow in the uploader cache we use a map with a maximum size which evicts old entries on overflow. Met vriendelijke groet, Kind regards, Bas Gooren Op 16-10-2012 12:59, schreef heapifyman: Not sure if I understand. As far as I got it, the upload plugin requires some web service that accepts POST and DELETE requests to add/remove uploaded files. Doing that is no problem, I guess. But how to I link this with the current user's wicket session so that I know which files the users uploaded when finally the form is submitted? I'm not sure if I'm using the right wording here. Hope you get the idea... 2012/10/16 Martin Grigorov mgrigo...@apache.org Hi, Is it an option to upload to a IResource and store the uploaded data the same way as if you'd do in the page ? On Tue, Oct 16, 2012 at 12:49 PM, heapifyman heapify...@gmail.com wrote: Hello, has anyone tried yet to integrate blueimp's jQuery File Upload http://blueimp.github.com/**jQuery-File-Upload/http://blueimp.github.com/jQuery-File-Upload/with Wicket FileUpload? Especially in combination with additional input fields input type=text I'm kind of stuck because I'm not really sure where to point the jquery file upload's url param to and how to store the uploaded files in the wicket page for saving them when the complete form is submitted. Any help would be appreciated. Thanks -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --**--** - To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.orgusers-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Wicket 1.5 alternative to 1.4 shared resources class aliases
Hi all, A short while ago someone posted a question about this (http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-migration-questions-td4651723.html). I encountered the same problem, and found a way which is cleaner (imho) than the suggestion at the end of that thread. It does not require the developer to use page parameters when generating a resource url. Basically, what I've done is make a copy of the ResourceMapper, and change it so it handles all resources with a certain scope. This means it'll automatically handle the same resource references you are used to working with. I've put it on pastebin for those interested: http://pastebin.com/iSssGHrE Use it like so: (in app init): mount( new ClassResourcesMapper(/res/classX, ClassX.class ) ); -- Met vriendelijke groet, Kind regards, Bas Gooren
Re: Login page stateless??
It simply means there is another component on your login page which makes the page stateful. To find out which one, override onBeforeRender() in the login page (log is a slf4j Logger): @Override protected void onBeforeRender() { super.onBeforeRender(); log.debug( Stateless? {}, getSession().isTemporary() ); if( !getSession().isTemporary() log.isTraceEnabled() ) { // Print which component is stateful visitChildren( Component.class, new IVisitorComponent() { @Override public Object component( Component component ) { if( !component.isStateless() ) { log.trace( + Stateful: {}, component ); } return CONTINUE_TRAVERSAL; } } ); } } Op 24-4-2012 20:50, schreef Alfonso Quiroga: Hi, in my job we have an application, and the LoginPage is like any other page. The testing team reported that when you see the login page, a new Session is being created by wicket (they see it in jProfiler). I've used a StatelessForm, but the session is still being created. The problem is that the application will be in internet, and is VERY easy to attack if we create a session in the login page. The only workaround I am thining... is creating a plain html file (login), and then redirect to a wicket page. Any other solution? thanks!! - 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: Page Expired with Google Analytics Tracking Code
Hi Andre, Without a quickstart it's nearly impossible to help. Nevertheless, as before, I expect this has to do with either a model that loses track of it's data (could be a serialization issue?), or incorrect usage of said model. When you say that after clicking a link in the navigator the results are empty, how did you find out about that? I'd suggest doing some debugging (e.g. set some breakpoints in your code and wicket code) in your favorite IDE. Some breakpoint ideas: - Your model which contains the results: set a breakpoint in #getObject() to make sure it is called, and check what it returns - PageableListView#onPopulateItem: check if it is called (= a re-render), and what the item's model contains Bas Op 21-4-2012 1:01, schreef Andre Schütz: Hi, I tried to reproduce the error with a quickstart project but was not successful. The quickstart is running fine with Google Analytics and PageableListView. I think that the project is to complex and the error is somewhere else. The only solution I can imagine is a detailed explanation of my problem with my new findings. May be, someone had the same problem or has an idea where I could search for the error. I hope that someone reads the following explanation and has an idea. I would be very thankful. My problem: - I added Google Analytics to my page and have a PageableListView on my results page. - I have 60 results for my PageableListView and show 10 entries per page. When the page is rendered, the PageableListView is constructed and show the first 10 entries. - The PagingNavigator show 6 pages of entries. The error: - When I click on one of the links of the PagingNavigator, the entries of the PageableListView are empty. I checked the results that were delivered to the PageableListView. When the PageableListView is constructed, the 60 results are filled and not empty. After clicking on one of the links in the PagingNavigator, the results are empty! I saw the empty results in the DebugBar and with an additional System.out.println within the populateItem method of the PageableListView. I would be very thankful, if someone has an idea or knows another solution that I can try. I try to solve the error since more than 2 weeks and have no new clue. Many thanks, Andre On Tue, 17 Apr 2012 22:31:27 +0200 Andre Schützandre-p...@gmx.de wrote: Hi, I will try to complete that in the next days and attach the quickstart as an answer. Thank you for the help, Andre On Mon, 16 Apr 2012 22:57:11 +0200 Bas Goorenb...@iswd.nl wrote: Hi, Can you build a small quickstart so I can have a look at things when they are not working? So just the bare minimum where it's not working: your page that is not working with a dummy model (e.g. with hardcoded results). Bas Op 16-4-2012 20:50, schreef Andre Schütz: Hi, I tried with super.renderHead..., but the result is the same. The PageableListView is empty after clicking on one of links in the PagingNavigator. Additinally, I fodun out that the elements (listItem) are empty when I click on one of the links in the PagingNavigator. They are filled, when the PageableListView is build. Any idea why how that could happen? Andre On Fri, 13 Apr 2012 10:29:41 +0200 Bas Goorenb...@iswd.nl wrote: Hi, What happens if you change that to: @Override public void renderHead(HeaderResponse response) { super.renderHead(response); String script = var _gaq = _gaq || ...; response.renderJavaScript(script, null); } ? (note that I added a call to super.renderHead()); Bas Op 11-4-2012 23:08, schreef Andre Schütz: Hi, I implemented your version but still I get the same error, if I have the Google Analytics Code in the head. Could it be an error with the way I insert the Google Analytics Code? I do it in the following way. In my WebPage class I overwrite the following method: @Override public void renderHead(HeaderResponse response) { String script = var _gaq = _gaq || ...; response.renderJavaScript(script, null); } Andre On Wed, 11 Apr 2012 11:38:52 +0200 Bas Goorenb...@iswd.nlwrote: Well, for starters I wonder why you are using multiple LoadableDetachableModels in a Vector? What we do 99% of the time is this: - Wrap the entire resultset in a LDM - Feed that LDM to a ListView or a variant (we have a custom RepeatingView for paged database listings) - Use PropertyModels inside the repeater item(s) (or not, since the ListView will refresh itself anyway) I'm pretty sure you don't need setReuseItems(true) in this case; The only reason I've seen where it's required on a ListView is when you use it inside a form and need form validation to work. Since I don't see any form fields inside your listview I guess this is not the case. I also wonder why you had datacontainer.setVersioned(false)? E.g.: private void displayResults(IModelListDefaultSearchResult results, int entriesPerPage) { WebMarkupContainer datacontainer = new WebMarkupContainer(listviewContainer);
Re: Page Expired with Google Analytics Tracking Code
Hi, Can you build a small quickstart so I can have a look at things when they are not working? So just the bare minimum where it's not working: your page that is not working with a dummy model (e.g. with hardcoded results). Bas Op 16-4-2012 20:50, schreef Andre Schütz: Hi, I tried with super.renderHead..., but the result is the same. The PageableListView is empty after clicking on one of links in the PagingNavigator. Additinally, I fodun out that the elements (listItem) are empty when I click on one of the links in the PagingNavigator. They are filled, when the PageableListView is build. Any idea why how that could happen? Andre On Fri, 13 Apr 2012 10:29:41 +0200 Bas Goorenb...@iswd.nl wrote: Hi, What happens if you change that to: @Override public void renderHead(HeaderResponse response) { super.renderHead(response); String script = var _gaq = _gaq || ...; response.renderJavaScript(script, null); } ? (note that I added a call to super.renderHead()); Bas Op 11-4-2012 23:08, schreef Andre Schütz: Hi, I implemented your version but still I get the same error, if I have the Google Analytics Code in the head. Could it be an error with the way I insert the Google Analytics Code? I do it in the following way. In my WebPage class I overwrite the following method: @Override public void renderHead(HeaderResponse response) { String script = var _gaq = _gaq || ...; response.renderJavaScript(script, null); } Andre On Wed, 11 Apr 2012 11:38:52 +0200 Bas Goorenb...@iswd.nl wrote: Well, for starters I wonder why you are using multiple LoadableDetachableModels in a Vector? What we do 99% of the time is this: - Wrap the entire resultset in a LDM - Feed that LDM to a ListView or a variant (we have a custom RepeatingView for paged database listings) - Use PropertyModels inside the repeater item(s) (or not, since the ListView will refresh itself anyway) I'm pretty sure you don't need setReuseItems(true) in this case; The only reason I've seen where it's required on a ListView is when you use it inside a form and need form validation to work. Since I don't see any form fields inside your listview I guess this is not the case. I also wonder why you had datacontainer.setVersioned(false)? E.g.: private void displayResults(IModelListDefaultSearchResultresults, int entriesPerPage) { WebMarkupContainer datacontainer = new WebMarkupContainer(listviewContainer); datacontainer.setOutputMarkupId(true); add(datacontainer); PageableListViewDefaultSearchResultlistview = new PageableListViewDefaultSearchResult(listview, results, entriesPerPage) { StringBuilder sb; @Override protected void populateItem(ListItemDefaultSearchResultitem) { DefaultSearchResult s = item.getModelObject(); // Either (A) item.add(new ExternalLink(title, new PropertyModel(item.getModel(), title)); // Or (B) item.add(new ExternalLink(title, s.getTitle()); item.add(new Label(description, new PropertyModel(item.getModel(), description))); item.add(new Label(time, s.getTime()).setEscapeModelStrings(false)); } }; datacontainer.add(listview); AjaxPagingNavigator apn = new AjaxPagingNavigator(navigator, listview){ @Override protected void onAjaxEvent(AjaxRequestTarget target) { super.onAjaxEvent(target); target.appendJavaScript(scrollTo(0,0)); } }; datacontainer.add(apn); } Op 11-4-2012 11:22, schreef wic...@faustas.de: Hi, thank you for the answer. The they are not completely empty means the following. My results variable is a Vector that contains LoadableDetachableModel's in the form of the LoaableListingEntryModel. This model contains a class that has two variables that I access with getResults() and getTime(). The content of the getResults() variable is a class that implements the Serializable interface. The getTime() variable just has a Vector with time strings. Now comes the interesting part. When I click on one of the links from the PagingNavigator, the content of the getTime() variable is displayed in each single ListItem. The getResults() class is empty. The content of the getResults() class is only shown after a page reload and once again empty after clicking on one of the links from the PagingNavigator. That's the reason why I said it is not completely empty. I know that there are 60 results to display. The PagingNavigator shows 6 links for 10 entries per page. But after clicking on one of the links, the objects from the getResults() class are empty. Any idea? Andre - Original Message - From: b...@iswd.nl To: users@wicket.apache.org Date: 11.04.2012 00:51:38 Subject: Re: Page Expired with Google Analytics Tracking Code Hi, It sounds a lot like you are not using
Re: Page Expired with Google Analytics Tracking Code
Hi, What happens if you change that to: @Override public void renderHead(HeaderResponse response) { super.renderHead(response); String script = var _gaq = _gaq || ...; response.renderJavaScript(script, null); } ? (note that I added a call to super.renderHead()); Bas Op 11-4-2012 23:08, schreef Andre Schütz: Hi, I implemented your version but still I get the same error, if I have the Google Analytics Code in the head. Could it be an error with the way I insert the Google Analytics Code? I do it in the following way. In my WebPage class I overwrite the following method: @Override public void renderHead(HeaderResponse response) { String script = var _gaq = _gaq || ...; response.renderJavaScript(script, null); } Andre On Wed, 11 Apr 2012 11:38:52 +0200 Bas Goorenb...@iswd.nl wrote: Well, for starters I wonder why you are using multiple LoadableDetachableModels in a Vector? What we do 99% of the time is this: - Wrap the entire resultset in a LDM - Feed that LDM to a ListView or a variant (we have a custom RepeatingView for paged database listings) - Use PropertyModels inside the repeater item(s) (or not, since the ListView will refresh itself anyway) I'm pretty sure you don't need setReuseItems(true) in this case; The only reason I've seen where it's required on a ListView is when you use it inside a form and need form validation to work. Since I don't see any form fields inside your listview I guess this is not the case. I also wonder why you had datacontainer.setVersioned(false)? E.g.: private void displayResults(IModelListDefaultSearchResult results, int entriesPerPage) { WebMarkupContainer datacontainer = new WebMarkupContainer(listviewContainer); datacontainer.setOutputMarkupId(true); add(datacontainer); PageableListViewDefaultSearchResult listview = new PageableListViewDefaultSearchResult(listview, results, entriesPerPage) { StringBuilder sb; @Override protected void populateItem(ListItemDefaultSearchResult item) { DefaultSearchResult s = item.getModelObject(); // Either (A) item.add(new ExternalLink(title, new PropertyModel(item.getModel(), title)); // Or (B) item.add(new ExternalLink(title, s.getTitle()); item.add(new Label(description, new PropertyModel(item.getModel(), description))); item.add(new Label(time, s.getTime()).setEscapeModelStrings(false)); } }; datacontainer.add(listview); AjaxPagingNavigator apn = new AjaxPagingNavigator(navigator, listview){ @Override protected void onAjaxEvent(AjaxRequestTarget target) { super.onAjaxEvent(target); target.appendJavaScript(scrollTo(0,0)); } }; datacontainer.add(apn); } Op 11-4-2012 11:22, schreef wic...@faustas.de: Hi, thank you for the answer. The they are not completely empty means the following. My results variable is a Vector that contains LoadableDetachableModel's in the form of the LoaableListingEntryModel. This model contains a class that has two variables that I access with getResults() and getTime(). The content of the getResults() variable is a class that implements the Serializable interface. The getTime() variable just has a Vector with time strings. Now comes the interesting part. When I click on one of the links from the PagingNavigator, the content of the getTime() variable is displayed in each single ListItem. The getResults() class is empty. The content of the getResults() class is only shown after a page reload and once again empty after clicking on one of the links from the PagingNavigator. That's the reason why I said it is not completely empty. I know that there are 60 results to display. The PagingNavigator shows 6 links for 10 entries per page. But after clicking on one of the links, the objects from the getResults() class are empty. Any idea? Andre - Original Message - From: b...@iswd.nl To: users@wicket.apache.org Date: 11.04.2012 00:51:38 Subject: Re: Page Expired with Google Analytics Tracking Code Hi, It sounds a lot like you are not using models properly. E.g. your results method parameter has a length which overflows the page size (and thus the pagingnavigator renders page links), but on a second request the contents of results are null/empty? Try debugging PageableListView#populateItem() and check what its model points to. Can you be more specific with regard to they are not completely empty? What exactly do you see, and what do you expect? Kind regards, Bas Op 10-4-2012 22:19, schreef Andre Schütz: Hi, nobody an idea why the PageableListView is empty after clicking on one of the links from the PagingNavigator? After reloading of the page, the PageableListView is filled and once again empty when I click on oe of the links from the PagingNavigator. It seems, that the
Re: Page Expired with Google Analytics Tracking Code
Well, for starters I wonder why you are using multiple LoadableDetachableModels in a Vector? What we do 99% of the time is this: - Wrap the entire resultset in a LDM - Feed that LDM to a ListView or a variant (we have a custom RepeatingView for paged database listings) - Use PropertyModels inside the repeater item(s) (or not, since the ListView will refresh itself anyway) I'm pretty sure you don't need setReuseItems(true) in this case; The only reason I've seen where it's required on a ListView is when you use it inside a form and need form validation to work. Since I don't see any form fields inside your listview I guess this is not the case. I also wonder why you had datacontainer.setVersioned(false)? E.g.: private void displayResults(IModelListDefaultSearchResult results, int entriesPerPage) { WebMarkupContainer datacontainer = new WebMarkupContainer(listviewContainer); datacontainer.setOutputMarkupId(true); add(datacontainer); PageableListViewDefaultSearchResult listview = new PageableListViewDefaultSearchResult(listview, results, entriesPerPage) { StringBuilder sb; @Override protected void populateItem(ListItemDefaultSearchResult item) { DefaultSearchResult s = item.getModelObject(); // Either (A) item.add(new ExternalLink(title, new PropertyModel(item.getModel(), title)); // Or (B) item.add(new ExternalLink(title, s.getTitle()); item.add(new Label(description, new PropertyModel(item.getModel(), description))); item.add(new Label(time, s.getTime()).setEscapeModelStrings(false)); } }; datacontainer.add(listview); AjaxPagingNavigator apn = new AjaxPagingNavigator(navigator, listview){ @Override protected void onAjaxEvent(AjaxRequestTarget target) { super.onAjaxEvent(target); target.appendJavaScript(scrollTo(0,0)); } }; datacontainer.add(apn); } Op 11-4-2012 11:22, schreef wic...@faustas.de: Hi, thank you for the answer. The they are not completely empty means the following. My results variable is a Vector that contains LoadableDetachableModel's in the form of the LoaableListingEntryModel. This model contains a class that has two variables that I access with getResults() and getTime(). The content of the getResults() variable is a class that implements the Serializable interface. The getTime() variable just has a Vector with time strings. Now comes the interesting part. When I click on one of the links from the PagingNavigator, the content of the getTime() variable is displayed in each single ListItem. The getResults() class is empty. The content of the getResults() class is only shown after a page reload and once again empty after clicking on one of the links from the PagingNavigator. That's the reason why I said it is not completely empty. I know that there are 60 results to display. The PagingNavigator shows 6 links for 10 entries per page. But after clicking on one of the links, the objects from the getResults() class are empty. Any idea? Andre - Original Message - From: b...@iswd.nl To: users@wicket.apache.org Date: 11.04.2012 00:51:38 Subject: Re: Page Expired with Google Analytics Tracking Code Hi, It sounds a lot like you are not using models properly. E.g. your results method parameter has a length which overflows the page size (and thus the pagingnavigator renders page links), but on a second request the contents of results are null/empty? Try debugging PageableListView#populateItem() and check what its model points to. Can you be more specific with regard to they are not completely empty? What exactly do you see, and what do you expect? Kind regards, Bas Op 10-4-2012 22:19, schreef Andre Schütz: Hi, nobody an idea why the PageableListView is empty after clicking on one of the links from the PagingNavigator? After reloading of the page, the PageableListView is filled and once again empty when I click on oe of the links from the PagingNavigator. It seems, that the Listitem's are empty when I click on one of the links in the PagingNavigator. But there are definitely more items than just for one page and the PagingNavigator shows 6 possible pages. Thanks, Andre On Mon, 9 Apr 2012 19:44:34 +0200 Andre Schützwic...@faustas.de wrote: Hello, I tried your approach and could find one mistake in my code. After the stepwise adding of the components to my results page, I found an error in two of my classes that are used on that page. These two classes did not implement the Serializable interface. I added the interface to these two classes and the PageExpired error was gone. But there is still another error. My PageableListView does not display the results when I click on one of the links in the AjaxPagingNavigator. The first page is displayed but the other pages in the list are nearly empty. They are not
Re: Page Expired with Google Analytics Tracking Code
Hi, It sounds a lot like you are not using models properly. E.g. your results method parameter has a length which overflows the page size (and thus the pagingnavigator renders page links), but on a second request the contents of results are null/empty? Try debugging PageableListView#populateItem() and check what its model points to. Can you be more specific with regard to they are not completely empty? What exactly do you see, and what do you expect? Kind regards, Bas Op 10-4-2012 22:19, schreef Andre Schütz: Hi, nobody an idea why the PageableListView is empty after clicking on one of the links from the PagingNavigator? After reloading of the page, the PageableListView is filled and once again empty when I click on oe of the links from the PagingNavigator. It seems, that the Listitem's are empty when I click on one of the links in the PagingNavigator. But there are definitely more items than just for one page and the PagingNavigator shows 6 possible pages. Thanks, Andre On Mon, 9 Apr 2012 19:44:34 +0200 Andre Schützwic...@faustas.de wrote: Hello, I tried your approach and could find one mistake in my code. After the stepwise adding of the components to my results page, I found an error in two of my classes that are used on that page. These two classes did not implement the Serializable interface. I added the interface to these two classes and the PageExpired error was gone. But there is still another error. My PageableListView does not display the results when I click on one of the links in the AjaxPagingNavigator. The first page is displayed but the other pages in the list are nearly empty. They are not completely empty. I have 3 elements in an item of the PageableListView populateItem Method that must be filled in the html page. The elements are title, description and time. My code looks as follows: /*** * Code */ private void displayResults(VectorLoadableListingEntryModel results, int entriesPerPage) { WebMarkupContainer datacontainer = new WebMarkupContainer(listviewContainer); datacontainer.setOutputMarkupId(true); add(datacontainer); PageableListView listview = new PageableListView(listview, results, entriesPerPage) { StringBuilder sb; @Override protected void populateItem(ListItem item) { if (item != null) { LoadableListingEntryModel model = (LoadableListingEntryModel)item.getModelObject(); DefaultSearchResult s = model.getObject().getResult(); String description = s.getDescription(); String title = s.getTitle(); item.add(new ExternalLink(title, title)); item.add(new Label(description, description)); item.add(new Label(time, s.getTime()).setEscapeModelStrings(false)); } } }; listview.setReuseItems(true); datacontainer.add(listview); AjaxPagingNavigator apn = new AjaxPagingNavigator(navigator, listview){ @Override protected void onAjaxEvent(AjaxRequestTarget target) { super.onAjaxEvent(target); target.appendJavaScript(scrollTo(0,0)); } }; datacontainer.add(apn); datacontainer.setVersioned(false); } /*** * Code */ The LoadableListingEntryModel was one of the two classes that got the Serializable interface. When I click on one of the links of the AjaxPagingNavigator, the title and the description fields are emtpy. The time field is filled. I checked the items and have e.g. 60 items with title, description and time content. But only the time content is displayed, when I click on one of the AjaxPagingNavigator links. This error only occurs, if the Google Adsense Code is in the site. Could it be possible, that the Ajax call of the PageableListView has a problem? Thanks, Andre On Sat, 07 Apr 2012 21:46:53 +0200 Bas Goorenb...@iswd.nl wrote: Yes. Op 7-4-2012 20:37, schreef Andre Schütz: Thank you for the answer, I will try your 4 steps. Just as information. When you say, that I can make the form stateless, do you talk about the StatelessForm class? Andre On Sat, 07 Apr 2012 16:06:15 +0200 Bas Goorenb...@iswd.nl wrote: Hi, I would suggest the following: 1) add a very simple test page: TestPage extends WebPage, which only has the search form on it (nothing else!) 2) see if that works multiple times in a row 3) if that works, add your google analytics code 4) repeat steps 1-2 In other words: eliminitate all other dependencies, so you can test (in isolation) if the google analytics code (or the component you've wrapped it in) is really the issue you are facing. You say that everything works ok when you add the query parameter
Re: Page Expired with Google Analytics Tracking Code
Hi, I would suggest the following: 1) add a very simple test page: TestPage extends WebPage, which only has the search form on it (nothing else!) 2) see if that works multiple times in a row 3) if that works, add your google analytics code 4) repeat steps 1-2 In other words: eliminitate all other dependencies, so you can test (in isolation) if the google analytics code (or the component you've wrapped it in) is really the issue you are facing. You say that everything works ok when you add the query parameter for the search. Having that parameter means you have a form with method=get? That, to me, would indicate you can make the form stateless, which should prevent your search from redirecting to a stateful url. (The /wicket/page start of the url indicates a stateful page). But please start with steps 1-4 above to make sure you are looking in the right place for the cause of your PageExpiredException. Bas Op 7-4-2012 14:04, schreef Andre Schütz: Hi, I tested the page and could localize the following error: page expired: http://localhost:8080/wicket/page?7-1.IFormSubmitListener-resultsContent-searchPanel-searchForm This means. The error occurs, when I make another search via my search form which is a normal Form with a textfield and a submit button. But, when I change the keyword in the URL (represented as q=KEYWORD parameter), the search works without the error. It seems, that the Form throws the error when the Google Analytics Code is in the header. Any idea how I can solve that problem? Andre On Fri, 06 Apr 2012 19:36:28 +0200 Bas Goorenb...@iswd.nl wrote: Hi Andre, No, we have been using the tracking code for years with wicket (1.3, 1.4 and 1.5) with 0 issues. I'm certain your Page expired error is caused by something else. From your description it sounds like your search results page is stateful, but no longer available when you perform a new search. That can happen for a variety of reasons. What usually happens to narrow the problem down is to strip the page as far as possible, and see if it works. Incrementally add components until it breaks again and you will have found the culprit. Another possibility is that you have non-standard settings for wicket session (page) management. But my guess is that this is not the case. Kind regards, Bas Op 6-4-2012 19:25, schreef Andre Schütz: Hello, did nobody have the same problem with the new Google Analytics code? I added the code directly into the .html file of my WebPage class. Andre On Thu, 5 Apr 2012 14:54:50 +0200 Andre Schützwic...@faustas.de wrote: Hello, we added the actual Google Analytics Tracking Code into our Wicket application. The code is rendered on every single page directly before the closing/head tag. Our problem is the following: Page 1 with search box - search for something Page 2 is a search site where the search request is done Page 3 is the result page, where the search result is presented We do: Page 1 - search for something Page 2 appears and shows search progress Page 3 appears and displays the results Page 3 has a search box and we start another search -- Page expired error Any ideas why this happens and how we can stop that? Thanks, Andre -- Andre Schützwic...@faustas.de - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Page Expired with Google Analytics Tracking Code
Yes. Op 7-4-2012 20:37, schreef Andre Schütz: Thank you for the answer, I will try your 4 steps. Just as information. When you say, that I can make the form stateless, do you talk about the StatelessForm class? Andre On Sat, 07 Apr 2012 16:06:15 +0200 Bas Goorenb...@iswd.nl wrote: Hi, I would suggest the following: 1) add a very simple test page: TestPage extends WebPage, which only has the search form on it (nothing else!) 2) see if that works multiple times in a row 3) if that works, add your google analytics code 4) repeat steps 1-2 In other words: eliminitate all other dependencies, so you can test (in isolation) if the google analytics code (or the component you've wrapped it in) is really the issue you are facing. You say that everything works ok when you add the query parameter for the search. Having that parameter means you have a form with method=get? That, to me, would indicate you can make the form stateless, which should prevent your search from redirecting to a stateful url. (The /wicket/page start of the url indicates a stateful page). But please start with steps 1-4 above to make sure you are looking in the right place for the cause of your PageExpiredException. Bas Op 7-4-2012 14:04, schreef Andre Schütz: Hi, I tested the page and could localize the following error: page expired: http://localhost:8080/wicket/page?7-1.IFormSubmitListener-resultsContent-searchPanel-searchForm This means. The error occurs, when I make another search via my search form which is a normal Form with a textfield and a submit button. But, when I change the keyword in the URL (represented as q=KEYWORD parameter), the search works without the error. It seems, that the Form throws the error when the Google Analytics Code is in the header. Any idea how I can solve that problem? Andre On Fri, 06 Apr 2012 19:36:28 +0200 Bas Goorenb...@iswd.nl wrote: Hi Andre, No, we have been using the tracking code for years with wicket (1.3, 1.4 and 1.5) with 0 issues. I'm certain your Page expired error is caused by something else. From your description it sounds like your search results page is stateful, but no longer available when you perform a new search. That can happen for a variety of reasons. What usually happens to narrow the problem down is to strip the page as far as possible, and see if it works. Incrementally add components until it breaks again and you will have found the culprit. Another possibility is that you have non-standard settings for wicket session (page) management. But my guess is that this is not the case. Kind regards, Bas Op 6-4-2012 19:25, schreef Andre Schütz: Hello, did nobody have the same problem with the new Google Analytics code? I added the code directly into the .html file of my WebPage class. Andre On Thu, 5 Apr 2012 14:54:50 +0200 Andre Schützwic...@faustas.dewrote: Hello, we added the actual Google Analytics Tracking Code into our Wicket application. The code is rendered on every single page directly before the closing/headtag. Our problem is the following: Page 1 with search box -search for something Page 2 is a search site where the search request is done Page 3 is the result page, where the search result is presented We do: Page 1 -search for something Page 2 appears and shows search progress Page 3 appears and displays the results Page 3 has a search box and we start another search --Page expired error Any ideas why this happens and how we can stop that? Thanks, Andre -- Andre Schützwic...@faustas.de - 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: Page Expired with Google Analytics Tracking Code
Hi Andre, No, we have been using the tracking code for years with wicket (1.3, 1.4 and 1.5) with 0 issues. I'm certain your Page expired error is caused by something else. From your description it sounds like your search results page is stateful, but no longer available when you perform a new search. That can happen for a variety of reasons. What usually happens to narrow the problem down is to strip the page as far as possible, and see if it works. Incrementally add components until it breaks again and you will have found the culprit. Another possibility is that you have non-standard settings for wicket session (page) management. But my guess is that this is not the case. Kind regards, Bas Op 6-4-2012 19:25, schreef Andre Schütz: Hello, did nobody have the same problem with the new Google Analytics code? I added the code directly into the .html file of my WebPage class. Andre On Thu, 5 Apr 2012 14:54:50 +0200 Andre Schützwic...@faustas.de wrote: Hello, we added the actual Google Analytics Tracking Code into our Wicket application. The code is rendered on every single page directly before the closing/head tag. Our problem is the following: Page 1 with search box - search for something Page 2 is a search site where the search request is done Page 3 is the result page, where the search result is presented We do: Page 1 - search for something Page 2 appears and shows search progress Page 3 appears and displays the results Page 3 has a search box and we start another search -- Page expired error Any ideas why this happens and how we can stop that? Thanks, Andre -- Andre Schützwic...@faustas.de - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: After upgrading from wicket 1.5.0 to 1.5.1+ we have a simple problem
Hi, Op 25-3-2012 18:59, schreef Martin Grigorov: On Sun, Mar 25, 2012 at 7:19 PM, Bas Goorenb...@iswd.nl wrote: https://issues.apache.org/jira/browse/WICKET-4468 Thanks! We will consider it. Ok: here's whats happening: - A request comes in for /login - WebPageRenderer:264-266 stores the buffered response in the session and redirects to /login?0 - WebPageRenderer:214 redirects to /login, since that is what the target page is mounted at So because no buffered response is found, the /login?0 url is processed by the WebPageRenderer. It checks if the current url is correct for the current page. If not, it redirects to the correct url. This can be a major problem when apps have bookmarkable stateful pages which are opened by clients which do not support sessions. I encountered this bug as follows: - I have my app in the root context of my tomcat server in eclipse WTP (web tools) - when I start tomcat through eclipse, WTP checks if the server is running by requesting the / url - Eclipse WTP performs the request with a sessionless client; We also force wicket to never include jessionid in the url - since this app requires authentication, / redirects to /login - /login was (unexpectedly) stateful, due to a hidden logout link - Eclipse WTP ended up in an infinite redirect loop, until it decided after 30 seconds that tomcat was unable to start and kills the tomcat process What are the values of currentUrl and targetUrl at the top of the method body at the second request (the redirect) ? I expect current to be login?0 because this is what is requested. I also expect the target url to be login?0 because the page is stateful (thus ?pageId) and is freshly constructed (thus pageId is again 0). Is this correct ? In which if/else clause it goes after that ? After the redirect the currentUrl is login?0 and the targetUrl is login. So when a request comes in for login we fall through to the if/else at line 264 since the targetUrl2 is login?0; So only after rendering the page does wicket know it's stateful (makes sense). When the request for login?0 comes in, targetUrl is login, since wicket does not yet know the page is stateful and no buffered response is found. Thus, the if/else at line 214 is triggered, which redirects to login (targetUrl). So basically this is a chicken/egg problem: wicket won't know if the page is stateful until after it is rendered. Due to some shortcuts at the top of WebPageRenderer#respond() which ignore statefull/stateless differences we get an infinite redirect loop. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: After upgrading from wicket 1.5.0 to 1.5.1+ we have a simple problem
Hi, Op 25-3-2012 17:44, schreef Martin Grigorov: Hi, On Sat, Mar 24, 2012 at 10:44 PM, Bas Goorenb...@iswd.nl wrote: After more debugging, I learned some new things about wicket. It appears that an invisible stateful link makes a page stateful. The base page for this application contains a username label + logout link (stateful), which are in a WebMarkupContainer which is invisible if the user is not logged in. But in the end, even when it is invisble this link makes the entire page stateful. When I remove that link wicket no longer performs a redirect to /login?0. This leads me to two questions to the devs: 1) looking at this usecase, does it make sense that a stateful link which is not rendered makes the entire page stateful? This is a good point. I think Wicket's logic to decide whether something is stateful could be improved to ignore invisible and disabled components/behaviors. Those should not be reachable anyway. Please file a ticket. https://issues.apache.org/jira/browse/WICKET-4468 I've filed it as an improvement against wicket 1.5.5 since that's what we're using. 2) when a stateful page is accessed without a session (/login?0) by a client which does not support cookies, we get infinite redirects (/login?0 = /login = /login?0 = /login etc). Is this normal behavior? This assumes that only cookie-based sessions are allowed. Furthermore: (2) was not a problem in 1.5.0 (where /login?0 would not redirect back to /login if there was no session...). I understand the need for the redirect to /login?0, and love that (ajax changes are still available on back button, fantastic!). But, the redirect back from /login?0 to /login I don't get, especially when there is no session available. I'll have to debug the application to see what happens exactly. Try to debug it in org.apache.wicket.request.handler.render.WebPageRenderer#respond(). Ok: here's whats happening: - A request comes in for /login - WebPageRenderer:264-266 stores the buffered response in the session and redirects to /login?0 - WebPageRenderer:214 redirects to /login, since that is what the target page is mounted at So because no buffered response is found, the /login?0 url is processed by the WebPageRenderer. It checks if the current url is correct for the current page. If not, it redirects to the correct url. This can be a major problem when apps have bookmarkable stateful pages which are opened by clients which do not support sessions. I encountered this bug as follows: - I have my app in the root context of my tomcat server in eclipse WTP (web tools) - when I start tomcat through eclipse, WTP checks if the server is running by requesting the / url - Eclipse WTP performs the request with a sessionless client; We also force wicket to never include jessionid in the url - since this app requires authentication, / redirects to /login - /login was (unexpectedly) stateful, due to a hidden logout link - Eclipse WTP ended up in an infinite redirect loop, until it decided after 30 seconds that tomcat was unable to start and kills the tomcat process Kind regards, Sebastian Op 22-3-2012 8:00, schreef Martin Grigorov: Hi, A hint for debugging: the request to login?0 should be handled by org.apache.wicket.core.request.mapper.BufferedResponseMapper not by WebPageRenderer. Check why there is no stored response. A suggestion: try to make your login page stateless. Otherwise every hit to your application will create a new http session. I.e. an attacker can cause a denial of service. On Thu, Mar 22, 2012 at 12:17 AM, Bas Goorenb...@iswd.nlwrote: We have the following simple setup: BasePage checks if user is logged in, if not (and this is not the LoginPage), RestartResponseException(LoginPage.class); LoginPage extends BasePage; contains a form to login; The application runs in the root context. Now on 1.5.0 this works like a charm; After upgrading to 1.5.5 we get infinite redirects; testing versions in between, we've found that the problem occurs= 1.5.1; Here's what debugging shows: 1) When we hit the root url (homepage), it redirects to /login 2) When the LoginPage (mounted at /login) is hit, WebPageRenderer:266 redirects from /login to /login?0 3) When /login?0 is hit, WebPageRenderer:214 redirects from /login?0 to /login and this loops back to (2) I've also learned that this does not occur if we do not run the app in the root context, so it appears to have to do with url handling. Looking at the wicket 1.5.1 changelog I don't see anything that was changed to break this. Before doing more debugging, does anyone have a clue what might cause this? Kind regards, Sebastian - 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
Re: After upgrading from wicket 1.5.0 to 1.5.1+ we have a simple problem
Martin, Thanks for your pointer. This is indeed the reason for the loop: no buffered response is found. Something must have changed between 1.5.0 and 1.5.1 regarding (session) cookies and continueToOriginalDestination(), since it is no longer setting a session cookie. For all our public-facing apps we force a HttpServletResponseWrapper which does not allow the container to encode urls; The result in 1.5.0 was that we never get a jsessionid in the url, and there were no side-effects. Our login page is stateless; However, all other bookmarkable pages are statefull and an RestartResponseAtInterceptPageException is thrown to redirect to the login page, which creates a session. I found a thread in which you commented that one should not use a ResetResponseException (or a specialization of it) in combination with cookies. So how would that work with a login page? We log the user in as follows: private void login( User user ) { DSNSession session = getSession(); session.setUser( user ); session.bind(); System.out.println( session.getId() ); if( !continueToOriginalDestination() ) throw new RestartResponseException( getApplication().getHomePage() ); } Looking at wicket's own AuthenticatedWebSession co, it's done exactly the same there, so I wonder why it stopped working... Sebastian Op 22-3-2012 8:00, schreef Martin Grigorov: Hi, A hint for debugging: the request to login?0 should be handled by org.apache.wicket.core.request.mapper.BufferedResponseMapper not by WebPageRenderer. Check why there is no stored response. A suggestion: try to make your login page stateless. Otherwise every hit to your application will create a new http session. I.e. an attacker can cause a denial of service. On Thu, Mar 22, 2012 at 12:17 AM, Bas Goorenb...@iswd.nl wrote: We have the following simple setup: BasePage checks if user is logged in, if not (and this is not the LoginPage), RestartResponseException(LoginPage.class); LoginPage extends BasePage; contains a form to login; The application runs in the root context. Now on 1.5.0 this works like a charm; After upgrading to 1.5.5 we get infinite redirects; testing versions in between, we've found that the problem occurs= 1.5.1; Here's what debugging shows: 1) When we hit the root url (homepage), it redirects to /login 2) When the LoginPage (mounted at /login) is hit, WebPageRenderer:266 redirects from /login to /login?0 3) When /login?0 is hit, WebPageRenderer:214 redirects from /login?0 to /login and this loops back to (2) I've also learned that this does not occur if we do not run the app in the root context, so it appears to have to do with url handling. Looking at the wicket 1.5.1 changelog I don't see anything that was changed to break this. Before doing more debugging, does anyone have a clue what might cause this? Kind regards, Sebastian - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: After upgrading from wicket 1.5.0 to 1.5.1+ we have a simple problem
After more debugging, I learned some new things about wicket. It appears that an invisible stateful link makes a page stateful. The base page for this application contains a username label + logout link (stateful), which are in a WebMarkupContainer which is invisible if the user is not logged in. But in the end, even when it is invisble this link makes the entire page stateful. When I remove that link wicket no longer performs a redirect to /login?0. This leads me to two questions to the devs: 1) looking at this usecase, does it make sense that a stateful link which is not rendered makes the entire page stateful? 2) when a stateful page is accessed without a session (/login?0) by a client which does not support cookies, we get infinite redirects (/login?0 = /login = /login?0 = /login etc). Is this normal behavior? This assumes that only cookie-based sessions are allowed. Furthermore: (2) was not a problem in 1.5.0 (where /login?0 would not redirect back to /login if there was no session...). I understand the need for the redirect to /login?0, and love that (ajax changes are still available on back button, fantastic!). But, the redirect back from /login?0 to /login I don't get, especially when there is no session available. Kind regards, Sebastian Op 22-3-2012 8:00, schreef Martin Grigorov: Hi, A hint for debugging: the request to login?0 should be handled by org.apache.wicket.core.request.mapper.BufferedResponseMapper not by WebPageRenderer. Check why there is no stored response. A suggestion: try to make your login page stateless. Otherwise every hit to your application will create a new http session. I.e. an attacker can cause a denial of service. On Thu, Mar 22, 2012 at 12:17 AM, Bas Goorenb...@iswd.nl wrote: We have the following simple setup: BasePage checks if user is logged in, if not (and this is not the LoginPage), RestartResponseException(LoginPage.class); LoginPage extends BasePage; contains a form to login; The application runs in the root context. Now on 1.5.0 this works like a charm; After upgrading to 1.5.5 we get infinite redirects; testing versions in between, we've found that the problem occurs= 1.5.1; Here's what debugging shows: 1) When we hit the root url (homepage), it redirects to /login 2) When the LoginPage (mounted at /login) is hit, WebPageRenderer:266 redirects from /login to /login?0 3) When /login?0 is hit, WebPageRenderer:214 redirects from /login?0 to /login and this loops back to (2) I've also learned that this does not occur if we do not run the app in the root context, so it appears to have to do with url handling. Looking at the wicket 1.5.1 changelog I don't see anything that was changed to break this. Before doing more debugging, does anyone have a clue what might cause this? Kind regards, Sebastian - 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: [1.5] unwanted page refresh
Hi, Sounds like you have a redirect somewhere. Do you have any components on the page which at some point in time call setResponsePage or an equivalent? Bas Op 21-3-2012 12:49, schreef Pierre Goupil: Good afternoon, I have a couple of ModalWindow s in my code that respond to closing using an AjaxButton and its AjaxRequestTarget. My problem is that, in 1.5, after the page displays its components added to the target, the page refreshes itself. Which I don't want, indeed. The problem is weird since the same code used to work in 1.4 without any such side-effects. Details: Wicket 1.5.5, Firefox 11, Opera (?), Debian Linux 6, Tomcat 7.0.22. Any help will be much appreciated. Regards, Pierre Goupil - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
After upgrading from wicket 1.5.0 to 1.5.1+ we have a simple problem
We have the following simple setup: BasePage checks if user is logged in, if not (and this is not the LoginPage), RestartResponseException(LoginPage.class); LoginPage extends BasePage; contains a form to login; The application runs in the root context. Now on 1.5.0 this works like a charm; After upgrading to 1.5.5 we get infinite redirects; testing versions in between, we've found that the problem occurs = 1.5.1; Here's what debugging shows: 1) When we hit the root url (homepage), it redirects to /login 2) When the LoginPage (mounted at /login) is hit, WebPageRenderer:266 redirects from /login to /login?0 3) When /login?0 is hit, WebPageRenderer:214 redirects from /login?0 to /login and this loops back to (2) I've also learned that this does not occur if we do not run the app in the root context, so it appears to have to do with url handling. Looking at the wicket 1.5.1 changelog I don't see anything that was changed to break this. Before doing more debugging, does anyone have a clue what might cause this? Kind regards, Sebastian - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: java.util.Date cannot be cast to java.sql.Date
Declare the dob field as: @Temporal(TemporalType.Date) private (java.util.)Date dob; Op 19-3-2012 14:02, schreef Alok Pathak: I have an application in Wicket 1.4, where i am using JPA. I declared an entity (Customer) with property *dob* of type *java.sql.Date*. Now i want to migrate that application in Wicket 1.5, When I submit the registration form of the customer I get the exception: *java.util.Date cannot be cast to java.sql.Date* Kindly Help Thanks Alok Pathak -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/java-util-Date-cannot-be-cast-to-java-sql-Date-tp4484703p4484703.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: Adding a header contribution as the first in the head tag
Josh, You can use an application-wide IResponseFilter for this. Have a look at how ServerHostNameAndTimeFilter (in wicket-examples (*)) does it. *) E.g. look at http://grepcode.com/file/repo1.maven.org/maven2/org.apache.wicket/wicket-examples/1.5.3/org/apache/wicket/examples/ServerHostNameAndTimeFilter.java#ServerHostNameAndTimeFilter Op 2-3-2012 5:26, schreef Josh Chappelle: I'm trying to add an IE compatibility meta tag and it needs to be the first item in thehead tag otherwise it will not work. I have a BasePage that I can just put it in the html and that works fine for the most part but I would like a way to set it in the Application class that way any page will get the contribution. Is there any way to do this in wicket 1.5? Thanks, Josh
Re: 1.5.4 error handling with web.xml error-page issue
It's documented here: https://cwiki.apache.org/WICKET/error-pages-and-feedback-messages.html Op 17-2-2012 2:39, schreef pkc: I have no idea if this is documented and why it is needed but it works after changing web.xml to filter-mapping filter-namewicket/filter-name url-pattern/*/url-pattern dispatcherREQUEST/dispatcher dispatcherERROR/dispatcher /filter-mapping -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/1-5-4-error-handling-with-web-xml-error-page-issue-tp4395935p4396055.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
Architectural question
Hi All, I have an architectural question about wicket, DDD and the service layer. Let's say we have a simple JPA entity (Customer), and a few simple CRUDL screens. For database access, we have a DAO layer (CustomerDao) which delegates to an EntityManager, and provides some convenience methods for searching. We also like to have clear boundaries, so we have a thin service layer which wraps persist() and delete() calls in a transaction before forwarding them to the DAO layer (@Transactional, as provided by guice-persist). A wicket model fetches one or more customers (by id or by running a search), and attaches to a form. In the form we use PropertyModels which push their changes to the entity, and in onSubmit() we call service.persist(entity). This means that the actual changes to the model happen outside of the transaction (in wicket code), and within the transaction (/service layer) we merely call persist() and flush(). Then parts of the app need something a bit more advanced, so we decide to apply parts of DDD and put logic where it belongs (on the domain models). However, some logic coordinates multiple models, so we add a domain- or application-service for that. The good thing about DDD is that it's a lot more clear what happens (intent). We now realize that having a persist() method on a entity-based service now looks like a bit of a code smell, since it does not capture intent at all. Also, since the changes to the model happen in wicket, before the service layer is called, I feel that the service layer is not doing anything to act as a boundary. We might as well mark the persist() method on our daos @transactional and remove the service layer. The only clean way to fix this seems to be either: (a) using DTO's so the UI/wicket is not actually modifying domain entities upside: the state of the domain is not modified by wicket itself downside: duplication of models (actual model + DTO); downside: validation is currently set-up in wicket by scanning fields for validation annotations, so we would need to duplicate those on the DTO? (b) using a concept from CQRS: sending commands to the domain through a bus. This clearly and cleanly defines the intent and captures the exact change. upside: the state of the domain is not modified by wicket itself downside: likely overkill for what we are trying to achieve; lot of extra complexity (c) wrapping the entire request in a transaction upside: easy to implement downside: since anything in the request can fetch a dao, read some entities and modify them, this means we can lose track of what happens in a request; downside: feels like moving backwards (d) simplify by removing thin services and, where necessary, putting more logic in the dao's upside: simple api contract: want to save/update an entity? use the dao directly downside: dao's contain logic which does not really belong there downside: if at some point we really do need a service, the api contract becomes less clear: for X and Y you can use the dao, for Z you have to use a service (a) and (b) provide a way to capture a change and execute all of the change inside a transaction. So my question to the list is: what are your experiences with this? How do you deal with this in simple to moderately complex webapps? Thanks for reading!
Re: Architectural question
Ok, so you mean detaching entities when returning them to the view layer (wicket)? How do you propose updating the underlying entities? Send the detached entities back to the service layer and copying their changes to attached entities? Or ...? Op 12-2-2012 14:22, schreef Martin Makundi: Why don't you just detach the entity/data objects with deep or shallow clone or similar? Minimal duplication... ** Martin 2012/2/12 Bas Goorenb...@iswd.nl: Hi All, I have an architectural question about wicket, DDD and the service layer. Let's say we have a simple JPA entity (Customer), and a few simple CRUDL screens. For database access, we have a DAO layer (CustomerDao) which delegates to an EntityManager, and provides some convenience methods for searching. We also like to have clear boundaries, so we have a thin service layer which wraps persist() and delete() calls in a transaction before forwarding them to the DAO layer (@Transactional, as provided by guice-persist). A wicket model fetches one or more customers (by id or by running a search), and attaches to a form. In the form we use PropertyModels which push their changes to the entity, and in onSubmit() we call service.persist(entity). This means that the actual changes to the model happen outside of the transaction (in wicket code), and within the transaction (/service layer) we merely call persist() and flush(). Then parts of the app need something a bit more advanced, so we decide to apply parts of DDD and put logic where it belongs (on the domain models). However, some logic coordinates multiple models, so we add a domain- or application-service for that. The good thing about DDD is that it's a lot more clear what happens (intent). We now realize that having a persist() method on a entity-based service now looks like a bit of a code smell, since it does not capture intent at all. Also, since the changes to the model happen in wicket, before the service layer is called, I feel that the service layer is not doing anything to act as a boundary. We might as well mark the persist() method on our daos @transactional and remove the service layer. The only clean way to fix this seems to be either: (a) using DTO's so the UI/wicket is not actually modifying domain entities upside: the state of the domain is not modified by wicket itself downside: duplication of models (actual model + DTO); downside: validation is currently set-up in wicket by scanning fields for validation annotations, so we would need to duplicate those on the DTO? (b) using a concept from CQRS: sending commands to the domain through a bus. This clearly and cleanly defines the intent and captures the exact change. upside: the state of the domain is not modified by wicket itself downside: likely overkill for what we are trying to achieve; lot of extra complexity (c) wrapping the entire request in a transaction upside: easy to implement downside: since anything in the request can fetch a dao, read some entities and modify them, this means we can lose track of what happens in a request; downside: feels like moving backwards (d) simplify by removing thin services and, where necessary, putting more logic in the dao's upside: simple api contract: want to save/update an entity? use the dao directly downside: dao's contain logic which does not really belong there downside: if at some point we really do need a service, the api contract becomes less clear: for X and Y you can use the dao, for Z you have to use a service (a) and (b) provide a way to capture a change and execute all of the change inside a transaction. So my question to the list is: what are your experiences with this? How do you deal with this in simple to moderately complex webapps? Thanks for reading! - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org