Re: Wicket 10 - not finding "el" properties
Thanks for the reply Martin. I also did some improvements in the file's contents. Here's the PR: https://github.com/apache/wicket/pull/879. Do I need to post this in the dev list as well? On Mon, May 27, 2024 at 10:50 AM Martin Grigorov wrote: > Hi Marios, > > On Mon, May 27, 2024 at 9:33 AM mscoon wrote: > > > Hi all, > > > > We have an application in greek. We recently to wicket 10 and messages > for > > the build-in validators (e.g. Required) stopped appearing in greek and > > started appearing in english. > > > > We noticed that the name of the properties file in wicket-core > > (wicket-core\src\main\java\org\apache\wicket) is > > Applcation_el.properties.utf8.properties (notice it has twice the word > > "properties"), and this seems to be the culprit. > > > > Should I submit a PR for this? > > > > Yes, please! > Thank you! > > > > > > > Thanks > > Marios > > >
Wicket 10 - not finding "el" properties
Hi all, We have an application in greek. We recently to wicket 10 and messages for the build-in validators (e.g. Required) stopped appearing in greek and started appearing in english. We noticed that the name of the properties file in wicket-core (wicket-core\src\main\java\org\apache\wicket) is Applcation_el.properties.utf8.properties (notice it has twice the word "properties"), and this seems to be the culprit. Should I submit a PR for this? Thanks Marios
Re: Opening a stateful page in a new window/tab with ajax
Thanks for the prompt answer. On Thu, Nov 21, 2019 at 6:38 PM Sven Meier wrote: > Hi, > > that's a perfectly valid usage. > > Have fun > Sven > > > On 21.11.19 13:44, mscoon wrote: > > Hi all, > > > > We are using the following code inside an ajax callback to create a new > > page and open it in a new window. Are there any gotchas with respect to > how > > we create MyPage and get the url for it? Is it guaranteed to be found in > > the user's session when the request for it comes in? > > > > void openPageInNewWindow(AjaxRequestTarget target) { > > Page pg = new MyPage(); > > String url = urlFor(new RenderPageRequestHandler(new > > PageProvider(pg))).toString(); > > target.appendJavaScript("window.open(\"" + url + "\")"); > > } > > > > Is there a better way to do this? > > > > Note that we don't want to use a BookmarkablePage page as an alternative. > > We want the new page to be instantiated inside the ajax callback. > > > > Thank you in advance, > > Marios > > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Opening a stateful page in a new window/tab with ajax
Hi all, We are using the following code inside an ajax callback to create a new page and open it in a new window. Are there any gotchas with respect to how we create MyPage and get the url for it? Is it guaranteed to be found in the user's session when the request for it comes in? void openPageInNewWindow(AjaxRequestTarget target) { Page pg = new MyPage(); String url = urlFor(new RenderPageRequestHandler(new PageProvider(pg))).toString(); target.appendJavaScript("window.open(\"" + url + "\")"); } Is there a better way to do this? Note that we don't want to use a BookmarkablePage page as an alternative. We want the new page to be instantiated inside the ajax callback. Thank you in advance, Marios
Re: Java 8 access to effectively final variables/method parameters from anonymous classes
Thomas, Thanks for the info. The domain objects not being serializable is certainly a valid option. To return to my original point, even this does not completely solve the issue with unintended serialization. Sure, you are going to get a serialization exception but this is a runtime error (hidden in the logs if I recall correctly) - much more cumbersome from the programmer's point of view compared to getting immediate visual feedback in the IDE or a compiler error. Also with view models you may end up again serializing a view model unintentionally. Granted this is usually not as bad, but still... The IntelliJ option seems to do what I want. Unfortunately we use eclipse and I wasn't able to find an equivalent option. Cheers Marios On Sun, Aug 4, 2019 at 1:07 PM Thomas Heigl wrote: > > > > Would you mind to elaborate on this a bit? What do you do in your forms? > > How do you handle state there? Do you use view models that are > > serializable? Do you keep state in local variables and propagate it to > the > > domain object in every request after it is reloaded? > > > Sure. > > We use DTOs/View Models for most of our forms. We started out with > manipulating domain objects directly, but it caused too many headaches with > serialization and detaching/re-attaching entities etc. > Domain objects are only used as Wicket (loadable detachable) models when > the manipulation is just a single step that can be persisted to the DB > right away. Your ajax link is a good example. Also single-page forms where > the final "Save/Next" button persists the changes to the DB. Whenever we > have a multi-step process (like a wizard) for creating or editing domain > objects, we use custom view models. > > Thomas > > On Sun, Aug 4, 2019 at 11:53 AM mscoon wrote: > > > Hi, > > > > If you don't mind me following up on your comment... > > > > > > > Personally, I rarely encounter serialization issues. None of our domain > > > objects implement Serializable. They can only be used with > > > LoadableDetachableModels that only store the identifier. > > > > > >> > > >> > > Would you mind to elaborate on this a bit? What do you do in your forms? > > How do you handle state there? Do you use view models that are > > serializable? Do you keep state in local variables and propagate it to > the > > domain object in every request after it is reloaded? > > > > We often use serializable domain objects so that keeping state on the > > object is simple. For example if you have an ajax link that increments a > > property of the domain object, you simply increment the property and rely > > on the object being serialized for keeping state. > > > > Cheers > > Marios > > >
Re: Java 8 access to effectively final variables/method parameters from anonymous classes
Hi, If you don't mind me following up on your comment... > Personally, I rarely encounter serialization issues. None of our domain > objects implement Serializable. They can only be used with > LoadableDetachableModels that only store the identifier. > >> >> Would you mind to elaborate on this a bit? What do you do in your forms? How do you handle state there? Do you use view models that are serializable? Do you keep state in local variables and propagate it to the domain object in every request after it is reloaded? We often use serializable domain objects so that keeping state on the object is simple. For example if you have an ajax link that increments a property of the domain object, you simply increment the property and rely on the object being serialized for keeping state. Cheers Marios
Re: Java 8 access to effectively final variables/method parameters from anonymous classes
Thank you for your answer Thomas. "Local variable or parameter can be final" inspection actually does something different. It will warn that a parameter can be made final when its value does not change, even if it not used in an anonymous class. This will result in programmers declaring all variables that they can as final and using them in the anonymous classes, which will again result in the same serialization oversights I mentioned... The same applies to checkstyle. I wonder why this is not a problem for others using wicket. Given wicket's serialization, since java 8 that allowed anonymous classes to access variables from the enclosing scope even if they are not declared final, I find there is a lot of room for unintentionally serializing stuff that you didn't want/notice is being serialized... Perhaps we are doing something wrong... On Sun, Aug 4, 2019 at 11:35 AM Thomas Heigl wrote: > Hi Marios, > > I don't think there is a way to disable this behaviour but you have other > options: > > - If you use IntelliJ, you can configure the "Local variable or parameter > can be final" inspection to raise an error instead of a warning (for > variables that are implicitly final) > - Checkstyle or similar tools that you can hook into your build process > might have similar inspections > > Best, > > Thomas > > On Sun, Aug 4, 2019 at 9:18 AM mscoon wrote: > > > Hi all, > > > > Java 8 introduced the ability to access effectively final > variables/method > > parameters from anonymous classes without having to add explicitly the > > "final" keyword. > > > > This has resulted in a lot of cases where the programmer does not notice > > that they are referencing a model object from an anonymous class, which > > results in the model object being serialized. > > > > Example: > > code inside a hypothetical MyPanel.newLink() method... > > > > Myclass obj = getModelObject(); > > return new AjaxLink("link") { > > void onClick(AjaxRequestTarget t) { > > if (obj.getId() != null) { > >// do something > > } else { > > // do something else > > } > > } > > > > In previous java versions you'd have to declare obj as final, and this > > would help you notice that it is going to be serialized. > > > > I understand that it is easy to change the code and avoid obj being > > serialized. The problem is not how to fix the code - the problem is that > > this "problem" often goes unnoticed. > > > > As far as I have searched, there is no way to disable this behavior (not > > having to explicitly declare variables as final) in java 8. > > > > Do you have any suggestions on how to handle this? > > > > Thank you in advance, > > Marios > > >
Java 8 access to effectively final variables/method parameters from anonymous classes
Hi all, Java 8 introduced the ability to access effectively final variables/method parameters from anonymous classes without having to add explicitly the "final" keyword. This has resulted in a lot of cases where the programmer does not notice that they are referencing a model object from an anonymous class, which results in the model object being serialized. Example: code inside a hypothetical MyPanel.newLink() method... Myclass obj = getModelObject(); return new AjaxLink("link") { void onClick(AjaxRequestTarget t) { if (obj.getId() != null) { // do something } else { // do something else } } In previous java versions you'd have to declare obj as final, and this would help you notice that it is going to be serialized. I understand that it is easy to change the code and avoid obj being serialized. The problem is not how to fix the code - the problem is that this "problem" often goes unnoticed. As far as I have searched, there is no way to disable this behavior (not having to explicitly declare variables as final) in java 8. Do you have any suggestions on how to handle this? Thank you in advance, Marios
Re: ExportToolbar and caching
https://issues.apache.org/jira/browse/WICKET-6655 What about ResourceStreamResource? Why is cacheDuration null by default? Thanks On Fri, Apr 12, 2019 at 9:20 PM Sven Meier wrote: > Hi Marios, > > you're right: > ExportToolbar doesn't specify any cache information, so updates to the > data are not reflected in repeated exports. > > We should improve that: > > - no caching as default > - users should be able to change this easily > > Can you create a Jira issue please? > > Thanks > Sven > > > Am 12.04.19 um 11:24 schrieb mscoon: > > Hi all, > > > > We have run into some problems when using the ExportToolbar the generated > > file seems to be cached in some browsers so that user's don't get a new > > version if the table contents change. > > > > I think there should be a way to tell the ExportToolbar to call > > setCacheDuraction(Duration.NONE) to the ResourceStreamResource that is > used > > to serve the file. > > > > There is also a related StackOverflow thread on this: > > > https://stackoverflow.com/questions/42602650/wicket-exporttoolbar-not-refreshing-on-table-update > > > > > > We've actually run several times into caching issues with > > ResourceStreamResource, and we had to explicitly set setCacheDuration to > > none. I'm not sure if this is the intended behavior and if having a null > > default value for ResourceStreamResource.cacheDuration is the right > thing... > > > > Thanks > > Marios > > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
ExportToolbar and caching
Hi all, We have run into some problems when using the ExportToolbar the generated file seems to be cached in some browsers so that user's don't get a new version if the table contents change. I think there should be a way to tell the ExportToolbar to call setCacheDuraction(Duration.NONE) to the ResourceStreamResource that is used to serve the file. There is also a related StackOverflow thread on this: https://stackoverflow.com/questions/42602650/wicket-exporttoolbar-not-refreshing-on-table-update We've actually run several times into caching issues with ResourceStreamResource, and we had to explicitly set setCacheDuration to none. I'm not sure if this is the intended behavior and if having a null default value for ResourceStreamResource.cacheDuration is the right thing... Thanks Marios
Re: AjaxDownloadBehavior with location=blob and greek filenames problems
Thank you! On Fri, Apr 5, 2019 at 1:14 PM Martin Grigorov wrote: > https://issues.apache.org/jira/browse/WICKET-6650 > > On Thu, Apr 4, 2019 at 5:29 PM Sven Meier wrote: > > > > > > > Hi, > > > > > > > > You're right, our JavaScript should decode the filename. > > > > > > > > Please open a Jira issue. > > > > > > > > Have fun > > > > Sven > > > > > > > > > > > > > > > > > > > > > > > > > > On 04.04.2019 at 14:52,wrote: > > > > > > > > > Hi all, When using the AjaxDownloadBehavior with Location=Blob and a > > greek filename, the filename is url encoded. E.g. if the file is > > "αρχείο.txt" (as defined in ResourceStreamResource.setFilename()), the > > downloaded file is "%CE%B1%CF%81%CF%87%CE%B5%CE%AF%CE%BF.txt" which is > the > > url encoded result of the original filename. This happens because > > ResourceStreamResource url encodes the filename - something that works > fine > > for Location=IFrame or Location=SameWindow. However for Location=Blob it > > seems that the javascript code that constructs the blob needs to url > decode > > the filename... Apparently this does not apply only to greek chars in > > filenames, but to all non-ascii chars... This has been tested in chrome > and > > firefox. Marios > > > > > >
AjaxDownloadBehavior with location=blob and greek filenames problems
Hi all, When using the AjaxDownloadBehavior with Location=Blob and a greek filename, the filename is url encoded. E.g. if the file is "αρχείο.txt" (as defined in ResourceStreamResource.setFilename()), the downloaded file is "%CE%B1%CF%81%CF%87%CE%B5%CE%AF%CE%BF.txt" which is the url encoded result of the original filename. This happens because ResourceStreamResource url encodes the filename - something that works fine for Location=IFrame or Location=SameWindow. However for Location=Blob it seems that the javascript code that constructs the blob needs to url decode the filename... Apparently this does not apply only to greek chars in filenames, but to all non-ascii chars... This has been tested in chrome and firefox. Marios
Re: Undesirable behavior of AutoLabelMarker
Hi Ernesto, Yes, that is possible but it opens the route for lazy initialization exceptions and such problems. Really, why is it so hard to send multiple component values with an ajax request? Maybe an AjaxFormComponentUpdating behavior which can update multiple components? On Mon, Feb 11, 2019 at 3:12 PM Ernesto Reinaldo Barreiro < reier...@gmail.com> wrote: > create an smart LDM that goes to database only once and after that keeps > value? >
Re: Undesirable behavior of AutoLabelMarker
Ηι, AutoLabelMarker is a public static final class defined inside org.apache.wicket.markup.html.form.AutoLabelResolver. What I want to achieve is the following: I have a form with five components, C1 through C5. C5 is disabled. When one of C1, C2, C3, C4 change, the value for C5 is computed (say with the sum of C1+C2+C3+C4) and the component need to be updated so that the user is shown the result before saving it to the database. There is a button "Save" in the bottom, only when this button is pressed should the information be stored in the database. C1, C2, C3 and C4 do not have required validators but they are checked in onValidateModelObjects() and if they are null, an error is shown. The form's model is a LoadableDetachableModal holding a hibernate entity. Let's assume we open the form and the initial values in the database are C1=C2=C3=C4=0. If we use AjaxFormComponentUpdatingBehavior, what happens is 1. use fills in C1 with the value 10, and presses tab, and the value sent to the server 2. the object is loaded from the database, property C1 is set with the component's value but it is not updated to the database 3. C5 is recomputed as C1+C2+C3+C4 = 10 and updated - everything fine up to here 4. the model is detached then 5. user fills in C2 with the value 20, presses tab, and the value sent to the server 6. the object is loaded from the database, property C1 is 0 because this is the value stored in the database (while the component C1 has the value 10 in the user's screen), property C2 is set with the component's value but it is not updated to the database. 7. C5 is computed C1+C2+C3+C4 = 20 which is wrong, it should be 30 8. the model is detached and so on... This is why we chose to try the AjaxFormSubmitBehavior. We want the values of C1, C2, C3 and C4 to be all sent to the back end with each ajax request so that when they are summed up to compute C5 they have the values that the user sees on the screen. However we don't want the form to be validated and any validation errors to be shown, unless the user presses Save. As it is now, because AjaxFormSubmitBehavior validates the form, what happens is: 1. User fills in C1 and presses tab 2. All values are sent to the server 3. C2, C3, C4's labels become red (AutoLabelMarker gives them error class - code is FormComponent.updateAutoLabels() called from Form.onFormSubmitted()) since onValidateObjectModel checks them and finds them empty Cheers Marios On Mon, Feb 11, 2019 at 9:08 AM Martin Grigorov wrote: > Hi, > > On Sun, Feb 10, 2019 at 10:29 PM mscoon wrote: > > > Hi Martin, > > > > The form reloads the entity from the database (it uses a kind of loadable > > detachable model) at each ajax request, so it does not remember the > values > > for the fields that have been modified in previous requests if we use > > AjaxForm[Choice]ComponentUpdatingBehavior. This is why we use > > AjaxFormSubmitBehavior. > > > > We could alter the form somehow to use AjaxForm[Choice]ComponentUpdat > > ingBehavior, but still... aren't my points valid? > > > > I do not know. There is no class AutoLabelMarker in Wicket distribution. I > have no idea what it is and how it works. > > It would be better to explain us what you want to achieve and then we can > help you implement it. > > From the information we have at the moment I think you need to keep the > entity being edited as a property of the form/panel/page. > AjaxFormComponentUpdatingBehavior will validate and modify it. At the end > when the form submit button is pressed you should do the final checks and > store it in the database. > > > > > > On Fri, Feb 8, 2019 at 9:26 PM Martin Grigorov > > wrote: > > > > > Hi, > > > > > > Why do you use AjaxFormSubmitBehavior ? It submits the whole form, i.e. > > all > > > its form components. > > > I think you want to use AjaxForm[Choice]ComponentUpdatingBehavior - it > > will > > > submit only the value of the modified field. > > > > > > On Fri, Feb 8, 2019 at 2:57 PM mscoon wrote: > > > > > > > Hi all, > > > > > > > > We have an outer form and an inner form. The inner form contains some > > > form > > > > components which all have an AjaxFormSubmitBehavior in order to > update > > > each > > > > - other when the user changes one of them. > > > > > > > > The actual submitting button is in the outer form. > > > > > > > > When the AjaxFormSubmitBehavior runs and some components are invalid, > > > > AutoLabelMarker is called and updates the label classes according to > > the > > > > component's validation state (valid/invalid) (and also > require
Re: Undesirable behavior of AutoLabelMarker
Hi Martin, The form reloads the entity from the database (it uses a kind of loadable detachable model) at each ajax request, so it does not remember the values for the fields that have been modified in previous requests if we use AjaxForm[Choice]ComponentUpdatingBehavior. This is why we use AjaxFormSubmitBehavior. We could alter the form somehow to use AjaxForm[Choice]ComponentUpdat ingBehavior, but still... aren't my points valid? On Fri, Feb 8, 2019 at 9:26 PM Martin Grigorov wrote: > Hi, > > Why do you use AjaxFormSubmitBehavior ? It submits the whole form, i.e. all > its form components. > I think you want to use AjaxForm[Choice]ComponentUpdatingBehavior - it will > submit only the value of the modified field. > > On Fri, Feb 8, 2019 at 2:57 PM mscoon wrote: > > > Hi all, > > > > We have an outer form and an inner form. The inner form contains some > form > > components which all have an AjaxFormSubmitBehavior in order to update > each > > - other when the user changes one of them. > > > > The actual submitting button is in the outer form. > > > > When the AjaxFormSubmitBehavior runs and some components are invalid, > > AutoLabelMarker is called and updates the label classes according to the > > component's validation state (valid/invalid) (and also required/enabled > > state). We do not want this to happen because the user is in the process > of > > filling in the form, and we think it's confusing to have the labels of > some > > components change color. This should only happen when the user has > clicked > > the submitting button. > > > > Whats-more the label classes are updated for all form components, > ignoring > > whether the components have been added to the AjaxRequestTarget in > > AjaxFormSubmitBehavior.onSubmit/onError. > > > > Can someone explain the reasoning behind AutoLabelMarker always updating > > all form component labels in every ajax request? Shouldn't labels be > > repainted after the ajax request only if their controls are repainted - > > i.e. added to the AjaxRequestTarget? > > > > Apparently we can remove the AutoLabelMarker from all form components. Is > > this what we should do? Isn't there a cleaner way? > > > > Thanks in advance, > > Marios > > >
Undesirable behavior of AutoLabelMarker
Hi all, We have an outer form and an inner form. The inner form contains some form components which all have an AjaxFormSubmitBehavior in order to update each - other when the user changes one of them. The actual submitting button is in the outer form. When the AjaxFormSubmitBehavior runs and some components are invalid, AutoLabelMarker is called and updates the label classes according to the component's validation state (valid/invalid) (and also required/enabled state). We do not want this to happen because the user is in the process of filling in the form, and we think it's confusing to have the labels of some components change color. This should only happen when the user has clicked the submitting button. Whats-more the label classes are updated for all form components, ignoring whether the components have been added to the AjaxRequestTarget in AjaxFormSubmitBehavior.onSubmit/onError. Can someone explain the reasoning behind AutoLabelMarker always updating all form component labels in every ajax request? Shouldn't labels be repainted after the ajax request only if their controls are repainted - i.e. added to the AjaxRequestTarget? Apparently we can remove the AutoLabelMarker from all form components. Is this what we should do? Isn't there a cleaner way? Thanks in advance, Marios
Re: How to handle "Service Unavailable" errors in ajax requests
The ajax failure handler did indeed do the trick. Thanks, Martin. On Mon, Jun 11, 2018 at 3:49 PM, Martin Grigorov wrote: > Hi, > > Have you tried with AjaxCallListener's failure handler ? > If jQuery.ajax() notifies its error listeners then it should work. > > The redirect will work only if the error page is served by something that > is still up, because "Service Unavailable" means that the web server (e.g. > Tomcat) is down. > > On Mon, Jun 11, 2018 at 3:10 PM, mscoon wrote: > > > Hi all, > > > > I have an AjaxSubmitLink which fails silently if the back-end server goes > > away. > > > > In debug mode, the ajax debug console shows: > > > > ERROR: Wicket.Ajax.Call.failure: Error while parsing response: Service > > Unavailable > > > > This is in Wicket 6.x > > > > Is there a way to catch these kinds of errors and show a message to the > > user or *try* to redirect to an error page (which will naturally lead to > an > > HTTP error)? > > > > Thanks > > Marios > > >
How to handle "Service Unavailable" errors in ajax requests
Hi all, I have an AjaxSubmitLink which fails silently if the back-end server goes away. In debug mode, the ajax debug console shows: ERROR: Wicket.Ajax.Call.failure: Error while parsing response: Service Unavailable This is in Wicket 6.x Is there a way to catch these kinds of errors and show a message to the user or *try* to redirect to an error page (which will naturally lead to an HTTP error)? Thanks Marios
wicket-rest - logging requests and responses
Hi everyone, Is there an example or some guidelines for logging requests and responses (including request and response headers and body) to resources implemented with wicket-rest-annotations? I'm looking for something low-level and cross-cutting, such as the cxf logging interceptors - i.e. something that can be turned on or off and customized without affecting the actual implementation of the resources. Thanks in advance. Marios
Wicket rest annotations - introduction
Hi all, We are considering using wicket rest annotations for extending a large existing application with a small (for now at least) rest api. Could you share your opinions on the state of the rest annotations project and also any pointers to examples and documentation? Thank you in advance Marios
Re: log4j MDC IRequestLogger
Hi, In a similar situation we have sub-classed RequestLogger and we are clearing the thread context in the end of MyRequestLogger.log(), so that the thread context is available when super.log() is called. It is not as clean as using AbstractRequestCycleListener.onDetach, but it works. Marios On Wed, Feb 17, 2016 at 3:34 PM, Francois Meillet < francois.meil...@gmail.com> wrote: > Dear All, > > I use the Mapped Diagnostic Context concept > https://logging.apache.org/log4j/2.x/manual/thread-context.html). > > Using log4j 2.x and a specific AbstractRequestCycleListener, > I overrided onBeginRequest() to perform a ThreadContext.push(id) > and onDetach(RequestCycle cycle) to perform a ThreadContext.pop();. > > So far so good for all the logs but the IRequestLogger's logs. > > I notice that the IRequestLogger # performLogging() is called after the > RequestCycle # onDetach() has been called. > > I would like it to happen before ! > Is that possible ? > > > François > > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Initializer problem - resources not being loaded
Hi all, We have a web application which is using an internal library called wicket-sol. The library is installed in our local maven repository. wicket-sol contains a property file wicket.properties which has a single entry: initializer=gr.sol.wicket.Initializer The gr.sol.wicket.Initializer class implements IInitializer. Right beside it we have two property files, Initializer.utf8.properties and Initializer_el.utf8.properties. We have the following problem: in one development machine, the initializer is never loaded. In other development machines it is loaded. Furthermore, if the problematic dev machine produces a war (via maven), and the war is deployed to our test server, the initializer is again never loaded. Wars built from other machines work fine. The wicket initializers (e.g. wicket extensions initializer) are normally loaded. We have traced the behavior down to org.apache.wicket.application.AbstractClassResolver#getResources() which uses a class loader to get the wicket.properties resources. In the problematic machine the resource file in wicket-sol.jar is not returned. We are using wicket 6.18.0. I was wondering if anyone has any ideas as to what the problem might be. Thanks in advance, Marios
Re: Initializer problem - resources not being loaded
You are actually right Sven. It is a broken pom.xml that causes the wicket.properties file to not be included in the jar file. And a broken build process that hides the problem in pom.xml in most dev machines. Apologies for bothering the list with an irrelevant issue... On Tue, May 12, 2015 at 4:26 PM, Sven Meier s...@meiers.net wrote: Hi, if the problematic dev machine produces a war (via maven), and the war is deployed to our test server, the initializer is again never loaded. Wars built from other machines work fine. mh, sounds like a build problem. Do you have a broken wicket-sol artefact in your local maven repository? Regards Sven On 12.05.2015 13:35, mscoon wrote: Hi all, We have a web application which is using an internal library called wicket-sol. The library is installed in our local maven repository. wicket-sol contains a property file wicket.properties which has a single entry: initializer=gr.sol.wicket.Initializer The gr.sol.wicket.Initializer class implements IInitializer. Right beside it we have two property files, Initializer.utf8.properties and Initializer_el.utf8.properties. We have the following problem: in one development machine, the initializer is never loaded. In other development machines it is loaded. Furthermore, if the problematic dev machine produces a war (via maven), and the war is deployed to our test server, the initializer is again never loaded. Wars built from other machines work fine. The wicket initializers (e.g. wicket extensions initializer) are normally loaded. We have traced the behavior down to org.apache.wicket.application.AbstractClassResolver#getResources() which uses a class loader to get the wicket.properties resources. In the problematic machine the resource file in wicket-sol.jar is not returned. We are using wicket 6.18.0. I was wondering if anyone has any ideas as to what the problem might be. Thanks in advance, Marios - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Checking obscure serialization bugs during development
Hi, it turns out that removing the session attribute as in Session().get(). removeAttribute(wicket:persistentPageManagerData - + Application.get().getName()) does not work because the result is that no pages are ever retrieved. Instead you need to get the attribute, which is a PageStoreManager$SessionEntry object, and nullify it's private sessionCache attribute. So this results is some ugly code accessing wicket internals but it seems to work, and since it's only for testing, it's okay. Thanks for the help, Martin. On Wed, Jan 14, 2015 at 10:32 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, There is no setting to tell Wicket to not store the page(s) used in the last request cycle in the memory (http session). But you can workaround this by null-ifying the session attribute in IRequestCycleListener#onBeginRequest() for example. You need something like: Session().get().removeAttribute(wicket:persistentPageManagerData - + Application.get().getName()) This way Wicket will always load the page from the second/third level stores (i.e. its serialized version). See http://wicket.apache.org/guide/guide/internals.html#pagestoring for some more details. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Tue, Jan 13, 2015 at 6:30 PM, mscoon msc...@gmail.com wrote: Hi all, There are some application (not wicket!) bugs that occur only when wicket serializes a page, while the same code works if the page is kept in memory during subsequent requests. For instance a == comparison may fail if either side of the expression is serialized/deserialized. These bugs often go unnoticed during development since usually the active page is kept in memory. So I was wondering if there is a way to force wicket during development to always serialize pages and never keep any pages in memory in order to make such bugs more apparent to the developer. Thanks in advance Marios
Re: Checking obscure serialization bugs during development
Heh, and a wrong carriage-return in the end makes me look like I'm trying to assume Martin's identity :) So anyway, thanks for the help Martin, as always you give very good guidance! Marios On Sun, May 3, 2015 at 7:01 PM, mscoon msc...@gmail.com wrote: Hi, it turns out that removing the session attribute as in Session().get(). removeAttribute(wicket:persistentPageManagerData - + Application.get().getName()) does not work because the result is that no pages are ever retrieved. Instead you need to get the attribute, which is a PageStoreManager$SessionEntry object, and nullify it's private sessionCache attribute. So this results is some ugly code accessing wicket internals but it seems to work, and since it's only for testing, it's okay. Thanks for the help, Martin. On Wed, Jan 14, 2015 at 10:32 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, There is no setting to tell Wicket to not store the page(s) used in the last request cycle in the memory (http session). But you can workaround this by null-ifying the session attribute in IRequestCycleListener#onBeginRequest() for example. You need something like: Session().get().removeAttribute(wicket:persistentPageManagerData - + Application.get().getName()) This way Wicket will always load the page from the second/third level stores (i.e. its serialized version). See http://wicket.apache.org/guide/guide/internals.html#pagestoring for some more details. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Tue, Jan 13, 2015 at 6:30 PM, mscoon msc...@gmail.com wrote: Hi all, There are some application (not wicket!) bugs that occur only when wicket serializes a page, while the same code works if the page is kept in memory during subsequent requests. For instance a == comparison may fail if either side of the expression is serialized/deserialized. These bugs often go unnoticed during development since usually the active page is kept in memory. So I was wondering if there is a way to force wicket during development to always serialize pages and never keep any pages in memory in order to make such bugs more apparent to the developer. Thanks in advance Marios
Re: FormComponentPanel and propagating model value to components
Well the code is a bit more complex that what I originally pasted. ComponentA is instantiated in an overridable method so that subclasses can provide a different implementation. Furthermore, the model cannot be decided at initialization time, so you can't simply call componentA.setModel() right after it is constructed. So I thought about using a behavior which can be added after the component is constructed and which can change the model whenever needed. Nonetheless, based on your feedback, I think I have found a way to refactor it such that the model is provided at initialization time. But I guess the question still stands - can Behavior#onConfigure change a component's model or is this not a valid operation? On Wed, Apr 8, 2015 at 12:13 PM, Patrick Davids patrick.dav...@nubologic.com wrote: Hi, quite unusal to me using a behavior to set a model. Why dont you delegate to your inner textfiled by implementing an own setXYZModel()-method? Or bind your inner textfield direct by providing a particular model in your Constructor of your custom MyFormComponentPanel? And no onInitialize()-method... public class MyFormComponentPanel extends FormComponentPanel { public MyFormComponentPanel(IModel myModel){ add(new TextField(id, myModel)); } } (add generics if needed) Patrick Am 08.04.2015 um 09:27 schrieb mscoon: Hi all, I have a FormComponentPanel. Is it okay if I set its components models using a behavior that overrides onConfigure() as below? public class MyFormComponentPanel extends FormComponentPanel { protected void onInitialize() { super.onInitialize(); componentA = new TextField... componentA.add(new Behavior() { @Override public void onConfigure(Component component) { componentA.setModel(...); } }); } thanks - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
FormComponentPanel and propagating model value to components
Hi all, I have a FormComponentPanel. Is it okay if I set its components models using a behavior that overrides onConfigure() as below? public class MyFormComponentPanel extends FormComponentPanel { protected void onInitialize() { super.onInitialize(); componentA = new TextField... componentA.add(new Behavior() { @Override public void onConfigure(Component component) { componentA.setModel(...); } }); } thanks
Re: Issues with multiple FeedbackPanels
Note sure what may be wrong unless you show more code. Some guesses: 1. You are refreshing the feedback panels in the ajax request target? I.e. in your ajax link's on click: void onClick(AjaxRequestTarget target) { ... do stuff, add message target.add(feedback1, feedback2); } 2. Neither of your feedback message filters accepts message 2584. On Thu, Mar 26, 2015 at 3:23 PM, avchavan avinash.cha...@yahoo.co.in wrote: Thsnk. That worked. Now have a different problem. I have an AjaxLink on its click based on some conditioned i have to show same message using feedbackMessage. if(session.getMyList().size() == 0){ myListView.getFeedbackMessages().clear(); myListView.info(funcMeldingen.getMessage(2584)); } I am doing this in my code but the message doesnt show up on the screen. call goes inside the if condition. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Issues-with-multiple-FeedbackPanels-tp4670087p4670104.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: Ajax submit form with FileUploadField
Since no-one has responded, let me try to rephrase the question: is wicket doing something different when submitting a form via ajx without and with a FileUploadField? If yes, could you please give me some pointers in the code to look at? Thanks Marios On Tue, Feb 10, 2015 at 4:36 PM, mscoon msc...@gmail.com wrote: Hi all, We are seeing strange behavior in a form that contains a FileUploadField when submitted with an AjaxSubmitLink. What happens is: 1. The form is embedded in another form, so wicket renders it as a div 2. The form is removed from it's parent element and placed within a JQuery dialog 3. The outher form contains a FileUploadField When the inner form is submitted we get the following error in the ajax debug panel: Cannot submit form with id criteria69 because there is no form element in the hierarchy. Removing the FileUploadField makes the error disappear, even though there is no form element in the hierarchy due to step (2) above. Any ideas why this is happening? Thanks Marios
Re: Ajax submit form with FileUploadField
Thank you for your answer. One more thing. Since I am trying to submit an inner form (which has been rendered as a div) and which does not contain a FileUploadField, why would wicket use an IFrame? Is the decision being made based on the outer form for all ajax submit links? On Thu, Feb 12, 2015 at 11:41 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Yes, it does. When there is a file input in the form Wicket needs to use an IFrame to be able to send the binary data because XmlHttpRequest v1 (IE 8/9/10 I think) doesn't support sending binary. The related code is at https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L623 Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Thu, Feb 12, 2015 at 11:36 PM, mscoon msc...@gmail.com wrote: Since no-one has responded, let me try to rephrase the question: is wicket doing something different when submitting a form via ajx without and with a FileUploadField? If yes, could you please give me some pointers in the code to look at? Thanks Marios On Tue, Feb 10, 2015 at 4:36 PM, mscoon msc...@gmail.com wrote: Hi all, We are seeing strange behavior in a form that contains a FileUploadField when submitted with an AjaxSubmitLink. What happens is: 1. The form is embedded in another form, so wicket renders it as a div 2. The form is removed from it's parent element and placed within a JQuery dialog 3. The outher form contains a FileUploadField When the inner form is submitted we get the following error in the ajax debug panel: Cannot submit form with id criteria69 because there is no form element in the hierarchy. Removing the FileUploadField makes the error disappear, even though there is no form element in the hierarchy due to step (2) above. Any ideas why this is happening? Thanks Marios
Ajax submit form with FileUploadField
Hi all, We are seeing strange behavior in a form that contains a FileUploadField when submitted with an AjaxSubmitLink. What happens is: 1. The form is embedded in another form, so wicket renders it as a div 2. The form is removed from it's parent element and placed within a JQuery dialog 3. The outher form contains a FileUploadField When the inner form is submitted we get the following error in the ajax debug panel: Cannot submit form with id criteria69 because there is no form element in the hierarchy. Removing the FileUploadField makes the error disappear, even though there is no form element in the hierarchy due to step (2) above. Any ideas why this is happening? Thanks Marios
Checking obscure serialization bugs during development
Hi all, There are some application (not wicket!) bugs that occur only when wicket serializes a page, while the same code works if the page is kept in memory during subsequent requests. For instance a == comparison may fail if either side of the expression is serialized/deserialized. These bugs often go unnoticed during development since usually the active page is kept in memory. So I was wondering if there is a way to force wicket during development to always serialize pages and never keep any pages in memory in order to make such bugs more apparent to the developer. Thanks in advance Marios
Wicket 7 for production use?
Hi all, Is there any estimate when wicket 7 will be ready for production use? We would really like to migrate our applications to it, and help with testing, but we are worried that we may encounter bugs in things that work in wicket 6 (such as wicket-5800 that I recently reported). Since there is no indication on the wicket site about when version 7 will be released we are worried that our project will be delayed waiting for wicket bug-fixes/releases. Marios
Re: Wicket 7.0.4M - bug related to queueing and wicket:enclosure
Thanks Andrea. On Mon, Jan 5, 2015 at 2:29 PM, andrea del bene an.delb...@gmail.com wrote: Hi, now the snapshot should work. Andrea. On 05/01/2015 11:32, mscoon wrote: Hi Martin, I just tried it with 7.0.0-SNAPSHOT and I get the same exception. I have opened https://issues.apache.org/jira/browse/WICKET-5800 with details and a quickstart. Thanks Marios On Wed, Dec 24, 2014 at 12:33 PM, Martin Grigorov mgrigo...@apache.org wrote: - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to solve this login problem?
If I recall correctly I read a description of a QR-Code login in which the page is constantly (periodically most likely) polling the server to see if the user has been authenticated. I.e.: You probably need two resources (or one with parameters): One to authenticate and one to ask if the user has been authenticated. In addition to what you currently have for authenticating with the QR code, you add some javascript code that periodically polls the later resource and if the answer is yes then it redirects to the home page. Perhaps you can do the latter with an ajax timer behavior, I'm not sure though if that may interfere with the user typing in the username/password controls. On Wed, Jan 7, 2015 at 3:49 PM, q_159 sebastian_s...@gmx.de wrote: Hi, I got my first problem where my colleagues can't help me anymore. Because I'm fairly new to Wicket, I don't know how to describe it properly, so here's the complete story: We have a login form inside a Wicket Panel, which shows up as a dialog. When the form is sent, the onSubmit method is called correctly and the user gets authenticated. That works fine. Now in my task I have to find an alternative method to login. I want to try a QR-Code and a related app for my Android Phone. The phone scans the code, solves the integrated challenge and sends it back to the panel. What I have done so far: 1) the login panel shows the QR-Code, which contains the Wicket-sessionID and a challenge 2) a smartphone app scans the code and solves the challenge 3) on Wicket side, I implemented a stateless WebResource, which will be contacted by the app to push the response 4) the resource has references to all open Wicket-Sessions, so I can get the correct session via ID from 1) 5) the resource hands the response to the login panel 5) the panel proofs the response Maybe you already guessed my problem: When I login normally, the onSubmit-method delivers the AjaxRequestTarget, which I need to close the dialog (/target.appendJavaScript($.deMailLayer.close();)/) With the QR-Code-login, I'm now somewhere in my panel, but I don't have this target. I can't get it with /RequestCycle.get().find(AjaxRequestTarget.class)/ either because there is no Request from the browser :-( How can I login my user (and force the browser to refresh if this is necessary)? If it helps: I'm using Wicket 6 and our session class extends /AbstractAuthenticatedWebSession/ - Seb PS: I answered to the mailing list registration, but got an error back, so I don't know if it worked or not. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-solve-this-login-problem-tp4668931.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 7.0.4M - bug related to queueing and wicket:enclosure
Hi Martin, I just tried it with 7.0.0-SNAPSHOT and I get the same exception. I have opened https://issues.apache.org/jira/browse/WICKET-5800 with details and a quickstart. Thanks Marios On Wed, Dec 24, 2014 at 12:33 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, I believe this is fixed in 7.0.0-SNAPSHOT. Please try it if you can. Thanks! On Dec 24, 2014 9:47 AM, mscoon msc...@gmail.com wrote: Hi, I have a component extending a FormComponentPanel which includes wicket:enclosures. It is embedded in tab in an ajax tabbed panel. I am getting the following exception when trying to change the active tab. It was working fine with wicket 6.15.0. I saw there are some issues in jira related to autocomponents and dequeing (WICKET-5730). Any ideas if this is related? org.apache.wicket.WicketRuntimeException: Detach called on component with id 'hireFek' while it had a non-empty queue: ComponentQueue{queueSize=2, queue=[[Enclosure [Component id = wicket_enclosure11]], [Enclosure [Component id = wicket_enclosure12]], null, null, null, null, null, null]} at org.apache.wicket.MarkupContainer.onDetach(MarkupContainer.java:1936) at org.apache.wicket.markup.html.form.LabeledWebMarkupContainer.onDetach(LabeledWebMarkupContainer.java:46) at org.apache.wicket.markup.html.form.FormComponent.onDetach(FormComponent.java:1409) at org.apache.wicket.Component.detach(Component.java:1160) at org.apache.wicket.MarkupContainer.detachChildren(MarkupContainer.java:1653) at org.apache.wicket.Component.detach(Component.java:1179) at org.apache.wicket.MarkupContainer.detachChildren(MarkupContainer.java:1653) at org.apache.wicket.Component.detach(Component.java:1179) at org.apache.wicket.MarkupContainer.detachChildren(MarkupContainer.java:1653) at org.apache.wicket.Component.detach(Component.java:1179) at org.apache.wicket.MarkupContainer.removedComponent(MarkupContainer.java:1356) at org.apache.wicket.MarkupContainer.replace(MarkupContainer.java:742) at org.apache.wicket.MarkupContainer.addOrReplace(MarkupContainer.java:214) at org.apache.wicket.extensions.markup.html.tabs.TabbedPanel.setCurrentTab(TabbedPanel.java:439) at org.apache.wicket.extensions.markup.html.tabs.TabbedPanel.setSelectedTab(TabbedPanel.java:397) at gr.sol.wicket.markup.html.form.tabs.FormContainerAjaxTabbedPanel$TabLink.onSubmit(FormContainerAjaxTabbedPanel.java:67) Thanks, Marios
Wicket 7.0.4M - bug related to queueing and wicket:enclosure
Hi, I have a component extending a FormComponentPanel which includes wicket:enclosures. It is embedded in tab in an ajax tabbed panel. I am getting the following exception when trying to change the active tab. It was working fine with wicket 6.15.0. I saw there are some issues in jira related to autocomponents and dequeing (WICKET-5730). Any ideas if this is related? org.apache.wicket.WicketRuntimeException: Detach called on component with id 'hireFek' while it had a non-empty queue: ComponentQueue{queueSize=2, queue=[[Enclosure [Component id = wicket_enclosure11]], [Enclosure [Component id = wicket_enclosure12]], null, null, null, null, null, null]} at org.apache.wicket.MarkupContainer.onDetach(MarkupContainer.java:1936) at org.apache.wicket.markup.html.form.LabeledWebMarkupContainer.onDetach(LabeledWebMarkupContainer.java:46) at org.apache.wicket.markup.html.form.FormComponent.onDetach(FormComponent.java:1409) at org.apache.wicket.Component.detach(Component.java:1160) at org.apache.wicket.MarkupContainer.detachChildren(MarkupContainer.java:1653) at org.apache.wicket.Component.detach(Component.java:1179) at org.apache.wicket.MarkupContainer.detachChildren(MarkupContainer.java:1653) at org.apache.wicket.Component.detach(Component.java:1179) at org.apache.wicket.MarkupContainer.detachChildren(MarkupContainer.java:1653) at org.apache.wicket.Component.detach(Component.java:1179) at org.apache.wicket.MarkupContainer.removedComponent(MarkupContainer.java:1356) at org.apache.wicket.MarkupContainer.replace(MarkupContainer.java:742) at org.apache.wicket.MarkupContainer.addOrReplace(MarkupContainer.java:214) at org.apache.wicket.extensions.markup.html.tabs.TabbedPanel.setCurrentTab(TabbedPanel.java:439) at org.apache.wicket.extensions.markup.html.tabs.TabbedPanel.setSelectedTab(TabbedPanel.java:397) at gr.sol.wicket.markup.html.form.tabs.FormContainerAjaxTabbedPanel$TabLink.onSubmit(FormContainerAjaxTabbedPanel.java:67) Thanks, Marios
Re: Should I use a (stateless) WebPage or a Resource to return a json response for an autocomplete component?
Thanks Martin for your answer. Is storing the resource reference in the application metadata once it's created and retrieving it from the metadata on subsequent uses a safe way to create it only once? On Mon, Dec 15, 2014 at 9:19 AM, Martin Grigorov mgrigo...@apache.org wrote: On Sun, Dec 14, 2014 at 12:08 AM, mscoon msc...@gmail.com wrote: Thank you both for your answers. I have reasons to roll my own autocomplete component. But I did take a look at the way wiqiery and wicket-jquery are serving the choices. As far as I can tell neither is using a stateless/lightweight way for serving the choices. Both serve them with a request to the page that contains the autocomplete component. This provides flexibility (because you can use the page state to adapt the returned choices) but also sounds quite expensive. Am I going too far here worrying about performance? Also, if I wanted to use resources as Andrea suggested, the only way to register them is via an initializer or at application start? Can't the component register them? Yes. ((WebApplication))component.getApplication()).mountResource(...) But this may register/mount the resource many times - as many as this component is used. On Sat, Dec 13, 2014 at 10:33 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, There are few very good integrations between Wicket and JQuery UI. Check https://github.com/sebfz1/wicket-jquery-ui and https://github.com/WiQuery/wiquery Both of them provide autocomplete component. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Sat, Dec 13, 2014 at 7:50 PM, Andrea Del Bene an.delb...@gmail.com wrote: Hi, I suggest you to use a resource instead of an adapted stateless page. Wicketstuff has a module with special Wicket resources to implement REST api: https://github.com/wicketstuff/core/tree/master/ jdk-1.7-parent/wicketstuff-restannotations-parent. Here you can find resources that already produce JSON in output. To configure them you might use a Wicket initializer: http://wicket.apache.org/guide/guide/single.html#advanced_3 Hi all, I am making an autocomplete component based on jquery-autocomplete. I have currently implemented the data source using a stateless web page which writes the json response. What I don't like about this is that it is a separate file/class from my autocomplete component. But I like that it's stateless. Could I achieve the same effect (statelessness) using a dynamic resource registered/created from within the autocomplete component? In other words I want the autocomplete component, upon creation, to register a resource that can be used to serve the autocomplete options. But I want the resource to be stateless and lightweight and the requests to return the autocomplete options should not have to go through the page that contains the autocomplete component. Furthermore, if I have the same autocomplete component twice in a page, the resource should be registered only once and server requests for both components. Is this possible? Can you provide some guidelines? Thanks Marios - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Should I use a (stateless) WebPage or a Resource to return a json response for an autocomplete component?
Hmm now I'm a bit confused. I have a TextTemplate that generates the JQuery autocomplete javascript. I need to pass it the url to retrieve the search results from. So I do: HashMapString, CharSequence vars = new HashMap(); CharSequence url = RequestCycle.get().urlFor(getSearchResultsResourcReference(), null); vars.put(sourceUrl, url); response.render(JavaScriptHeaderItem.forScript(template.asString(vars), jsId); where getSearchResultsResourcReference() creates (and saves in the app metadata) or retrieves the resource reference for searching. So I need a reference to the resource reference every time I use an autocomplete component. Am I missing something? Were you simply suggesting that instead of the resource I store the url in the app metadata? Does it make any difference? On Mon, Dec 15, 2014 at 10:36 PM, Martin Grigorov mgrigo...@apache.org wrote: With proper synchronization - yes. But I think you won't need to retrieve it later at all. So just make sure it is not added several times Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Dec 15, 2014 at 10:31 PM, mscoon msc...@gmail.com wrote: Thanks Martin for your answer. Is storing the resource reference in the application metadata once it's created and retrieving it from the metadata on subsequent uses a safe way to create it only once? On Mon, Dec 15, 2014 at 9:19 AM, Martin Grigorov mgrigo...@apache.org wrote: On Sun, Dec 14, 2014 at 12:08 AM, mscoon msc...@gmail.com wrote: Thank you both for your answers. I have reasons to roll my own autocomplete component. But I did take a look at the way wiqiery and wicket-jquery are serving the choices. As far as I can tell neither is using a stateless/lightweight way for serving the choices. Both serve them with a request to the page that contains the autocomplete component. This provides flexibility (because you can use the page state to adapt the returned choices) but also sounds quite expensive. Am I going too far here worrying about performance? Also, if I wanted to use resources as Andrea suggested, the only way to register them is via an initializer or at application start? Can't the component register them? Yes. ((WebApplication))component.getApplication()).mountResource(...) But this may register/mount the resource many times - as many as this component is used. On Sat, Dec 13, 2014 at 10:33 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, There are few very good integrations between Wicket and JQuery UI. Check https://github.com/sebfz1/wicket-jquery-ui and https://github.com/WiQuery/wiquery Both of them provide autocomplete component. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Sat, Dec 13, 2014 at 7:50 PM, Andrea Del Bene an.delb...@gmail.com wrote: Hi, I suggest you to use a resource instead of an adapted stateless page. Wicketstuff has a module with special Wicket resources to implement REST api: https://github.com/wicketstuff/core/tree/master/ jdk-1.7-parent/wicketstuff-restannotations-parent. Here you can find resources that already produce JSON in output. To configure them you might use a Wicket initializer: http://wicket.apache.org/guide/guide/single.html#advanced_3 Hi all, I am making an autocomplete component based on jquery-autocomplete. I have currently implemented the data source using a stateless web page which writes the json response. What I don't like about this is that it is a separate file/class from my autocomplete component. But I like that it's stateless. Could I achieve the same effect (statelessness) using a dynamic resource registered/created from within the autocomplete component? In other words I want the autocomplete component, upon creation, to register a resource that can be used to serve the autocomplete options. But I want the resource to be stateless and lightweight and the requests to return the autocomplete options should not have to go through the page that contains the autocomplete component. Furthermore, if I have the same autocomplete component twice in a page, the resource should be registered only once and server requests for both components. Is this possible? Can you provide some guidelines? Thanks Marios - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Should I use a (stateless) WebPage or a Resource to return a json response for an autocomplete component?
I am not using the same ResourceReference. getSearchResultsResourcReference() is overridden in subclasses to return a different resource reference as needed. Anyway I think now I understand how to mount the resource from within the component. Thanks! On Mon, Dec 15, 2014 at 10:57 PM, Martin Grigorov mgrigo...@apache.org wrote: 1. Since you use the same ResRef for all autocompleters then you can just mount it at start time within MyApp#init(). 2. Wicket uses ResourceReference#equals() to find the mounted ResRef so you can do: - mountResource(/some/path/, new MyResRef()) - CharSequence url = RequestCycle.get().urlFor(new MyResRef(), null); i.e. two different instances! They are matched by #equals(), not by identity Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Dec 15, 2014 at 10:46 PM, mscoon msc...@gmail.com wrote: Hmm now I'm a bit confused. I have a TextTemplate that generates the JQuery autocomplete javascript. I need to pass it the url to retrieve the search results from. So I do: HashMapString, CharSequence vars = new HashMap(); CharSequence url = RequestCycle.get().urlFor(getSearchResultsResourcReference(), null); vars.put(sourceUrl, url); response.render(JavaScriptHeaderItem.forScript(template.asString(vars), jsId); where getSearchResultsResourcReference() creates (and saves in the app metadata) or retrieves the resource reference for searching. So I need a reference to the resource reference every time I use an autocomplete component. Am I missing something? Were you simply suggesting that instead of the resource I store the url in the app metadata? Does it make any difference? On Mon, Dec 15, 2014 at 10:36 PM, Martin Grigorov mgrigo...@apache.org wrote: With proper synchronization - yes. But I think you won't need to retrieve it later at all. So just make sure it is not added several times Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Dec 15, 2014 at 10:31 PM, mscoon msc...@gmail.com wrote: Thanks Martin for your answer. Is storing the resource reference in the application metadata once it's created and retrieving it from the metadata on subsequent uses a safe way to create it only once? On Mon, Dec 15, 2014 at 9:19 AM, Martin Grigorov mgrigo...@apache.org wrote: On Sun, Dec 14, 2014 at 12:08 AM, mscoon msc...@gmail.com wrote: Thank you both for your answers. I have reasons to roll my own autocomplete component. But I did take a look at the way wiqiery and wicket-jquery are serving the choices. As far as I can tell neither is using a stateless/lightweight way for serving the choices. Both serve them with a request to the page that contains the autocomplete component. This provides flexibility (because you can use the page state to adapt the returned choices) but also sounds quite expensive. Am I going too far here worrying about performance? Also, if I wanted to use resources as Andrea suggested, the only way to register them is via an initializer or at application start? Can't the component register them? Yes. ((WebApplication))component.getApplication()).mountResource(...) But this may register/mount the resource many times - as many as this component is used. On Sat, Dec 13, 2014 at 10:33 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, There are few very good integrations between Wicket and JQuery UI. Check https://github.com/sebfz1/wicket-jquery-ui and https://github.com/WiQuery/wiquery Both of them provide autocomplete component. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Sat, Dec 13, 2014 at 7:50 PM, Andrea Del Bene an.delb...@gmail.com wrote: Hi, I suggest you to use a resource instead of an adapted stateless page. Wicketstuff has a module with special Wicket resources to implement REST api: https://github.com/wicketstuff/core/tree/master/ jdk-1.7-parent/wicketstuff-restannotations-parent. Here you can find resources that already produce JSON in output. To configure them you might use a Wicket initializer: http://wicket.apache.org/guide/guide/single.html#advanced_3 Hi all, I am making an autocomplete component based on jquery-autocomplete. I have currently implemented the data source using a stateless web page which writes the json response. What I don't like about this is that it is a separate file
Should I use a (stateless) WebPage or a Resource to return a json response for an autocomplete component?
Hi all, I am making an autocomplete component based on jquery-autocomplete. I have currently implemented the data source using a stateless web page which writes the json response. What I don't like about this is that it is a separate file/class from my autocomplete component. But I like that it's stateless. Could I achieve the same effect (statelessness) using a dynamic resource registered/created from within the autocomplete component? In other words I want the autocomplete component, upon creation, to register a resource that can be used to serve the autocomplete options. But I want the resource to be stateless and lightweight and the requests to return the autocomplete options should not have to go through the page that contains the autocomplete component. Furthermore, if I have the same autocomplete component twice in a page, the resource should be registered only once and server requests for both components. Is this possible? Can you provide some guidelines? Thanks Marios
Re: Should I use a (stateless) WebPage or a Resource to return a json response for an autocomplete component?
Thank you both for your answers. I have reasons to roll my own autocomplete component. But I did take a look at the way wiqiery and wicket-jquery are serving the choices. As far as I can tell neither is using a stateless/lightweight way for serving the choices. Both serve them with a request to the page that contains the autocomplete component. This provides flexibility (because you can use the page state to adapt the returned choices) but also sounds quite expensive. Am I going too far here worrying about performance? Also, if I wanted to use resources as Andrea suggested, the only way to register them is via an initializer or at application start? Can't the component register them? On Sat, Dec 13, 2014 at 10:33 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, There are few very good integrations between Wicket and JQuery UI. Check https://github.com/sebfz1/wicket-jquery-ui and https://github.com/WiQuery/wiquery Both of them provide autocomplete component. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Sat, Dec 13, 2014 at 7:50 PM, Andrea Del Bene an.delb...@gmail.com wrote: Hi, I suggest you to use a resource instead of an adapted stateless page. Wicketstuff has a module with special Wicket resources to implement REST api: https://github.com/wicketstuff/core/tree/master/ jdk-1.7-parent/wicketstuff-restannotations-parent. Here you can find resources that already produce JSON in output. To configure them you might use a Wicket initializer: http://wicket.apache.org/guide/guide/single.html#advanced_3 Hi all, I am making an autocomplete component based on jquery-autocomplete. I have currently implemented the data source using a stateless web page which writes the json response. What I don't like about this is that it is a separate file/class from my autocomplete component. But I like that it's stateless. Could I achieve the same effect (statelessness) using a dynamic resource registered/created from within the autocomplete component? In other words I want the autocomplete component, upon creation, to register a resource that can be used to serve the autocomplete options. But I want the resource to be stateless and lightweight and the requests to return the autocomplete options should not have to go through the page that contains the autocomplete component. Furthermore, if I have the same autocomplete component twice in a page, the resource should be registered only once and server requests for both components. Is this possible? Can you provide some guidelines? Thanks Marios - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: IComponentOnBeforeRenderListener and ListView
attachValidationErrors has nothing to do with FormErrorDecorator. It is just some code that adds validation errors to some form components. I use it because I want to show validation errors right when then form opens, and not after a submit. For instance if the user loads a record for editing, and this record has some wrong data in it, I want to immediately show the validation errors when the page renders and not have to wait until a submit. On Tue, Nov 25, 2014 at 11:50 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, On Mon, Nov 24, 2014 at 10:34 PM, mscoon msc...@gmail.com wrote: Martin, I'll try once again to explain my problem and if it's still unclear I'll make the quickstart. What you say is right, the sequence of events is as you said. My problem is that everything happens in AbstractRepeater#onBeforeRender(). So I have to put my code attachValidationErrors either before or after AbstractRepeater#onBeforeRender(). If I put it before, the form components have not yet been created (onPopulate() has not yet been called). If I put it after, the componentPostOnBeforeRenderListeners have already run so the ErrorDecorator thinks there are no errors. What I need is a way for my code to run *after* onPopulate() but *before* onBeforeRenderChildren(). There is no such hook though. Let me also expand my pseudocode a bit in case this helps: class MyPage extends WebPage { pyblic MyPage() { Form form = new Form(form, model) { override onBeforeRender() { attachValidationErrors(); Why do you need to call that here at all ? Why you want to traverse the sub-tree manually ? By using IComponentOnBeforeRenderListener you are being notified for each and every Component in the component tree. So your listener should just check whether the component is an instance of FormComponent and if its name matches (and the other complex logic you have) then report the error. onBeforeRender(); } }; add(form); ListView list = new ListView(list, model2) { public populateItem(ListItem listItem) { add(new TextField(name, new PropertyModel(model2, name))); } } form.add(list); } void attachValidationErrors() { form.visitChildren(FormComponent.class, new IVisitorFormComponent,Void() { void component(FormComponent? obj, IVisitVoid visit) { if (obj.getId().equals(name) /* and some other complex logic here */) { obj.error(Please provide a name); } } }); } I think this makes my problem quite evident. I can't find the right place to put the call to attachValidationErrors(). Or perhaps I need a different implements for FormErrorDecorator. On Mon, Nov 24, 2014 at 5:13 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Maybe I miss something from your description but I think ListView's items should have their #onBeforeRender() method called as any other component in the tree. org.apache.wicket.markup.repeater.AbstractRepeater#onBeforeRender() first calls #onPopulate() (where ListView adds its children) and then calls super.onBeforeRender() where org.apache.wicket.MarkupContainer#onBeforeRenderChildren() that calls #onBeforeRender() for all children components. So IComponentOnBeforeRenderListener should be notified. Maybe a quickstart will make it easier for understanding where is the problem. On Mon, Nov 24, 2014 at 4:52 PM, mscoon msc...@gmail.com wrote: Martin, Application#getComponentPostOnBeforeRenderListeners is how I am already registering my FormErrorDecorator. Attaching the validation errors after super.onBeforeRender() does not work even for components that are statically added and not part of a list view. Here's some psuedocode: Form form = new Form(form, model) { protected void onBeforeRender() { super.onBeforeRender(); attachValidationErrors(); } } super.onBeforeRender() calls onBeforeRender() on all children which in turn calls both the componentPreOnBeforeRenderListeners and the componentPostOnBeforeRenderListeners. So by the time attachValidationErrors() is called the error decorator has run and finished (and done nothing as it found no errors). If I move attachValidationErrors before super.onBeforeRender(), then it works for statically added form components. It does not work for components within ListViews because populateItem has not yet been called. I could move some of the error attaching logic within populateItem but this is ugly and leads to code duplication (as populateItem will not always be called because I need setReuseItems(true)). Any other ideas
Re: IComponentOnBeforeRenderListener and ListView
I don't want to use an IComponentOnBeforeRenderListener as it is an application wide facility whereas what I'm doing applies to a couple of pages only. But you suggestion gave me an idea. I am now using a behavior which I add to all form components in ListView#populateItem(). The behavior marks the components as invalid in onConfigure() which comes before onBeforeRender() and hence before the IComponentOnBeforeRenderListener. The problem with this solution is that this code is much more complicated than what I was doing originally. Now I have to put the validation errors in a transient field which is set in the form's onConfigure() method, and use this field to retrieve the errors from within Behavior#onConfigure(). What I tried to do originally was much cleaner, the model object was validated and the components invalidated from within a single method. It does seem like AbstractRepeater should have a postOnPopulate() method to allow client code to access the created components before onBeforeRender() is executed, don't you think? On Tue, Nov 25, 2014 at 4:29 PM, Martin Grigorov mgrigo...@apache.org wrote: OK, but isn't it possible to mark the form components as invalid with IComponentOnBeforeRenderListener too ? Just add the new IComponentOnBeforeRenderListener in the collection before FormErrorDecorator. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Tue, Nov 25, 2014 at 4:15 PM, mscoon msc...@gmail.com wrote: attachValidationErrors has nothing to do with FormErrorDecorator. It is just some code that adds validation errors to some form components. I use it because I want to show validation errors right when then form opens, and not after a submit. For instance if the user loads a record for editing, and this record has some wrong data in it, I want to immediately show the validation errors when the page renders and not have to wait until a submit. On Tue, Nov 25, 2014 at 11:50 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, On Mon, Nov 24, 2014 at 10:34 PM, mscoon msc...@gmail.com wrote: Martin, I'll try once again to explain my problem and if it's still unclear I'll make the quickstart. What you say is right, the sequence of events is as you said. My problem is that everything happens in AbstractRepeater#onBeforeRender(). So I have to put my code attachValidationErrors either before or after AbstractRepeater#onBeforeRender(). If I put it before, the form components have not yet been created (onPopulate() has not yet been called). If I put it after, the componentPostOnBeforeRenderListeners have already run so the ErrorDecorator thinks there are no errors. What I need is a way for my code to run *after* onPopulate() but *before* onBeforeRenderChildren(). There is no such hook though. Let me also expand my pseudocode a bit in case this helps: class MyPage extends WebPage { pyblic MyPage() { Form form = new Form(form, model) { override onBeforeRender() { attachValidationErrors(); Why do you need to call that here at all ? Why you want to traverse the sub-tree manually ? By using IComponentOnBeforeRenderListener you are being notified for each and every Component in the component tree. So your listener should just check whether the component is an instance of FormComponent and if its name matches (and the other complex logic you have) then report the error. onBeforeRender(); } }; add(form); ListView list = new ListView(list, model2) { public populateItem(ListItem listItem) { add(new TextField(name, new PropertyModel(model2, name))); } } form.add(list); } void attachValidationErrors() { form.visitChildren(FormComponent.class, new IVisitorFormComponent,Void() { void component(FormComponent? obj, IVisitVoid visit) { if (obj.getId().equals(name) /* and some other complex logic here */) { obj.error(Please provide a name); } } }); } I think this makes my problem quite evident. I can't find the right place to put the call to attachValidationErrors(). Or perhaps I need a different implements for FormErrorDecorator. On Mon, Nov 24, 2014 at 5:13 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Maybe I miss something from your description but I think ListView's items should have their #onBeforeRender() method called as any other component in the tree. org.apache.wicket.markup.repeater.AbstractRepeater#onBeforeRender() first calls #onPopulate() (where ListView adds its children) and then calls
Re: IComponentOnBeforeRenderListener and ListView
On Tue, Nov 25, 2014 at 11:40 PM, Martin Grigorov mgrigo...@apache.org wrote: On Tue, Nov 25, 2014 at 11:33 PM, mscoon msc...@gmail.com wrote: I don't want to use an IComponentOnBeforeRenderListener as it is an application wide facility whereas what I'm doing applies to a couple of pages only. But you suggestion gave me an idea. I am now using a behavior which I add to all form components in ListView#populateItem(). The behavior marks the components as invalid in onConfigure() which comes before onBeforeRender() and hence before the IComponentOnBeforeRenderListener. The problem with this solution is that this code is much more complicated than what I was doing originally. Now I have to put the validation errors in a transient field which is set in the form's onConfigure() method, and use this field to retrieve the errors from within Behavior#onConfigure(). What I tried to do originally was much cleaner, the model object was validated and the components invalidated from within a single method. It does seem like AbstractRepeater should have a postOnPopulate() method to allow client code to access the created components before onBeforeRender() is executed, don't you think? You can use populateItem() for this, no ? Not all of them at once, no. You only get to access the components within a single ListItem. But as we talk about it I see now that this is a very specific and limited use case, probably not worth considering changes to wicket for this. Thanks for your time!
IComponentOnBeforeRenderListener and ListView
Hi all, I am using a FormErrorDecorator that implements an IComponentOnBeforeRenderListener in order to automatically attach a css class to form components with validation errors (see https://cwiki.apache.org/confluence/display/WICKET/Automatic+styling+of+form+errors ). Sometimes I want to manually add errors to form components and I was doing that in onBeforeRender() before the call to super.onBeforeRender(). I do this because sometimes the object being edited is in an invalid state and I want to show the validation errors right when the form opens and not after a submit. This is working fine for most cases as the errors are attached to the form components before the FormErrorDecorator runs. However, form components inside a list view are not created until the end of ListView.onBeforeRender(). This means that I cannot attach errors before this step because the list view items don't yet exist, and if I attach them after onBeforeRender they are not picked up by the FormErrorDecorator. Any ideas? Thanks, Marios
Re: IComponentOnBeforeRenderListener and ListView
Martin, Application#getComponentPostOnBeforeRenderListeners is how I am already registering my FormErrorDecorator. Attaching the validation errors after super.onBeforeRender() does not work even for components that are statically added and not part of a list view. Here's some psuedocode: Form form = new Form(form, model) { protected void onBeforeRender() { super.onBeforeRender(); attachValidationErrors(); } } super.onBeforeRender() calls onBeforeRender() on all children which in turn calls both the componentPreOnBeforeRenderListeners and the componentPostOnBeforeRenderListeners. So by the time attachValidationErrors() is called the error decorator has run and finished (and done nothing as it found no errors). If I move attachValidationErrors before super.onBeforeRender(), then it works for statically added form components. It does not work for components within ListViews because populateItem has not yet been called. I could move some of the error attaching logic within populateItem but this is ugly and leads to code duplication (as populateItem will not always be called because I need setReuseItems(true)). Any other ideas? On Mon, Nov 24, 2014 at 3:23 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Try with org.apache.wicket.Application#getComponent*Post* OnBeforeRenderListeners() Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Nov 24, 2014 at 2:50 PM, mscoon msc...@gmail.com wrote: Hi all, I am using a FormErrorDecorator that implements an IComponentOnBeforeRenderListener in order to automatically attach a css class to form components with validation errors (see https://cwiki.apache.org/confluence/display/WICKET/Automatic+styling+of+form+errors ). Sometimes I want to manually add errors to form components and I was doing that in onBeforeRender() before the call to super.onBeforeRender(). I do this because sometimes the object being edited is in an invalid state and I want to show the validation errors right when the form opens and not after a submit. This is working fine for most cases as the errors are attached to the form components before the FormErrorDecorator runs. However, form components inside a list view are not created until the end of ListView.onBeforeRender(). This means that I cannot attach errors before this step because the list view items don't yet exist, and if I attach them after onBeforeRender they are not picked up by the FormErrorDecorator. Any ideas? Thanks, Marios
Re: IComponentOnBeforeRenderListener and ListView
Martin, I'll try once again to explain my problem and if it's still unclear I'll make the quickstart. What you say is right, the sequence of events is as you said. My problem is that everything happens in AbstractRepeater#onBeforeRender(). So I have to put my code attachValidationErrors either before or after AbstractRepeater#onBeforeRender(). If I put it before, the form components have not yet been created (onPopulate() has not yet been called). If I put it after, the componentPostOnBeforeRenderListeners have already run so the ErrorDecorator thinks there are no errors. What I need is a way for my code to run *after* onPopulate() but *before* onBeforeRenderChildren(). There is no such hook though. Let me also expand my pseudocode a bit in case this helps: class MyPage extends WebPage { pyblic MyPage() { Form form = new Form(form, model) { override onBeforeRender() { attachValidationErrors(); onBeforeRender(); } }; add(form); ListView list = new ListView(list, model2) { public populateItem(ListItem listItem) { add(new TextField(name, new PropertyModel(model2, name))); } } form.add(list); } void attachValidationErrors() { form.visitChildren(FormComponent.class, new IVisitorFormComponent,Void() { void component(FormComponent? obj, IVisitVoid visit) { if (obj.getId().equals(name) /* and some other complex logic here */) { obj.error(Please provide a name); } } }); } I think this makes my problem quite evident. I can't find the right place to put the call to attachValidationErrors(). Or perhaps I need a different implements for FormErrorDecorator. On Mon, Nov 24, 2014 at 5:13 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Maybe I miss something from your description but I think ListView's items should have their #onBeforeRender() method called as any other component in the tree. org.apache.wicket.markup.repeater.AbstractRepeater#onBeforeRender() first calls #onPopulate() (where ListView adds its children) and then calls super.onBeforeRender() where org.apache.wicket.MarkupContainer#onBeforeRenderChildren() that calls #onBeforeRender() for all children components. So IComponentOnBeforeRenderListener should be notified. Maybe a quickstart will make it easier for understanding where is the problem. On Mon, Nov 24, 2014 at 4:52 PM, mscoon msc...@gmail.com wrote: Martin, Application#getComponentPostOnBeforeRenderListeners is how I am already registering my FormErrorDecorator. Attaching the validation errors after super.onBeforeRender() does not work even for components that are statically added and not part of a list view. Here's some psuedocode: Form form = new Form(form, model) { protected void onBeforeRender() { super.onBeforeRender(); attachValidationErrors(); } } super.onBeforeRender() calls onBeforeRender() on all children which in turn calls both the componentPreOnBeforeRenderListeners and the componentPostOnBeforeRenderListeners. So by the time attachValidationErrors() is called the error decorator has run and finished (and done nothing as it found no errors). If I move attachValidationErrors before super.onBeforeRender(), then it works for statically added form components. It does not work for components within ListViews because populateItem has not yet been called. I could move some of the error attaching logic within populateItem but this is ugly and leads to code duplication (as populateItem will not always be called because I need setReuseItems(true)). Any other ideas? On Mon, Nov 24, 2014 at 3:23 PM, Martin Grigorov mgrigo...@apache.org wrote: Hi, Try with org.apache.wicket.Application#getComponent*Post* OnBeforeRenderListeners() Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Nov 24, 2014 at 2:50 PM, mscoon msc...@gmail.com wrote: Hi all, I am using a FormErrorDecorator that implements an IComponentOnBeforeRenderListener in order to automatically attach a css class to form components with validation errors (see https://cwiki.apache.org/confluence/display/WICKET/Automatic+styling+of+form+errors ). Sometimes I want to manually add errors to form components and I was doing that in onBeforeRender() before the call to super.onBeforeRender(). I do this because sometimes the object being edited is in an invalid state and I want to show the validation errors right when the form opens and not after a submit. This is working fine for most cases as the errors are attached to the form components before the FormErrorDecorator runs. However, form components inside a list view are not created until the end of ListView.onBeforeRender
Re: Auto-reloading markup during development
You are both right, thank you for your answers. I'm not sure what I was doing wrong, but I tried again and markup files are being reloaded. On Sun, Nov 23, 2014 at 11:56 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, On Sun, Nov 23, 2014 at 11:46 AM, Thorsten Schöning tschoen...@am-soft.de wrote: Guten Tag mscoon, am Samstag, 22. November 2014 um 21:44 schrieben Sie: Is it possible to set wicket to reload markup and other resources during development so that one does not need to redeploy-restart the server in order to see their changes? From my understanding this should work automatically, because properties files are added to a watcher and if you have enabled development mode templates are observed as well. What you need to make sure is that Eclipse had the time to republish the changed files and such. A short test with changes to a property and template file worked for me, though I often restarted the server in the past for various reasons as well. Right! In DEV mode Wicket tracks changes to markup files and i18n resources. DCEVM (or JRebel, or even simply running the JVM in DEBUG mode) will allow you to make changes in your *Java* code without restart. http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/settings/IResourceSettings.html#setResourcePollFrequency(org.apache.wicket.util.time.Duration) http://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/settings/IResourceSettings.html#setResourceWatcher(org.apache.wicket.util.watch.IModificationWatcher) 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
Auto-reloading markup during development
Hi all, Is it possible to set wicket to reload markup and other resources during development so that one does not need to redeploy-restart the server in order to see their changes? I have figured out how to do the equivalent for changes in java code using DCEVM but I can't seem to make it work for wicket's content files. I'm working with eclipse and tomcat. Thanks in advance, Marios
Re: turning off page versioning
Martin, I found you single-page-instance sample very interesting. I have the following question if you can spare some time: What happens if you completely remove the local map in SinglePageManager (and the associated) code? I.e. if SinglePageManager#getPage(int id) always delegates to the underlying manager and SinglePageManager#newPage() always returns a new page from the underlying factory. It seems that then you get the following: 1. Every time you hit a page either by url or navigation, you get a fresh instance, but without a version parameter in the url. Effectively you get a new version of the page but the url does not include the version number. 2. Interactions with the page affect the specific version. As long as you keep interacting with the page (e.g. Increment), you are fine. You can even have the same page in two tabs with different state. 3. If you hit F5 you go back to the page's original state I think the behavior outlined above is also valid for several use cases (e.g. facebook's profile page works like this - there are a lot of ajax interactions but if you hit F5 you go back to the page's original state). Do you see any holes? Thanks Marios
Re: turning off page versioning
Okay I see. I imagine this approach breaks if the render strategy is REDIRECT_TO_RENDER and works in ONE_PASS_RENDER and REDIRECT_TO_BUFFER. Also REDIRECT_TO_BUFFER works sort of by chance? What would happen if somehow requests from different tabs for the same page (url) were handled simultaneously? On Fri, Sep 26, 2014 at 11:58 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, What you describe is what several users currently do by using NoVersionMapper. NoVersionMapper is the thing that hides the ?pageId from the url in the address bar. The changes you suggest to be done in SinglePageManager (effectively remove SinglePageManager completely) is the current default behavior in Wicket. The hole is that F5 (page refresh) loses the state and creates a completely new page instance with its own state. Using back/forward will lose the state too. This is the reason why NoVersionMapper is not in the official Wicket distro. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Sep 26, 2014 at 10:52 AM, mscoon msc...@gmail.com wrote: Martin, I found you single-page-instance sample very interesting. I have the following question if you can spare some time: What happens if you completely remove the local map in SinglePageManager (and the associated) code? I.e. if SinglePageManager#getPage(int id) always delegates to the underlying manager and SinglePageManager#newPage() always returns a new page from the underlying factory. It seems that then you get the following: 1. Every time you hit a page either by url or navigation, you get a fresh instance, but without a version parameter in the url. Effectively you get a new version of the page but the url does not include the version number. 2. Interactions with the page affect the specific version. As long as you keep interacting with the page (e.g. Increment), you are fine. You can even have the same page in two tabs with different state. 3. If you hit F5 you go back to the page's original state I think the behavior outlined above is also valid for several use cases (e.g. facebook's profile page works like this - there are a lot of ajax interactions but if you hit F5 you go back to the page's original state). Do you see any holes? Thanks Marios
Re: turning off page versioning
I just tried your demo, it does seem to redirect (the requested url is ?0 while the current url has no version number)... But I was referring to the use of NoVersionMapper without SinglePageManager. I tried this too, and redirect to render breaks because the redirect is to http://blahblah/a and has no way of knowing which version should be used. Redirect to buffer apparently works because the response was buffered during the initial request that did include a page version in the url. On Fri, Sep 26, 2014 at 1:34 PM, Martin Grigorov mgrigo...@apache.org wrote: On Fri, Sep 26, 2014 at 12:23 PM, mscoon msc...@gmail.com wrote: Okay I see. I imagine this approach breaks if the render strategy is REDIRECT_TO_RENDER and works in ONE_PASS_RENDER and REDIRECT_TO_BUFFER. Wicket will redirect only if the requested url differs with the response url. Since the ?pageId is not in the url anymore then it depends only on the page parameters. As you can see in the demo app I haven't played with this. Also REDIRECT_TO_BUFFER works sort of by chance? What would happen if somehow requests from different tabs for the same page (url) were handled simultaneously? Wicket serializes the access to page instance. Since there is only one page instance per type then multitab support is more limited than current Wicket. Request1 will acquire the permit to use the page instance and request2 will wait on PageAccessSynchronizer. Once request1 finishes then if it is Ajax then all as before/now. But if request1 is normal (non-Ajax) then page#renderCount will be incremented and request2 will fail will StalePageException and just re-render with the last state (the one after request1). So you may see more do-nothing interactions with the page than now. On Fri, Sep 26, 2014 at 11:58 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, What you describe is what several users currently do by using NoVersionMapper. NoVersionMapper is the thing that hides the ?pageId from the url in the address bar. The changes you suggest to be done in SinglePageManager (effectively remove SinglePageManager completely) is the current default behavior in Wicket. The hole is that F5 (page refresh) loses the state and creates a completely new page instance with its own state. Using back/forward will lose the state too. This is the reason why NoVersionMapper is not in the official Wicket distro. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Sep 26, 2014 at 10:52 AM, mscoon msc...@gmail.com wrote: Martin, I found you single-page-instance sample very interesting. I have the following question if you can spare some time: What happens if you completely remove the local map in SinglePageManager (and the associated) code? I.e. if SinglePageManager#getPage(int id) always delegates to the underlying manager and SinglePageManager#newPage() always returns a new page from the underlying factory. It seems that then you get the following: 1. Every time you hit a page either by url or navigation, you get a fresh instance, but without a version parameter in the url. Effectively you get a new version of the page but the url does not include the version number. 2. Interactions with the page affect the specific version. As long as you keep interacting with the page (e.g. Increment), you are fine. You can even have the same page in two tabs with different state. 3. If you hit F5 you go back to the page's original state I think the behavior outlined above is also valid for several use cases (e.g. facebook's profile page works like this - there are a lot of ajax interactions but if you hit F5 you go back to the page's original state). Do you see any holes? Thanks Marios
Re: turning off page versioning
One last question: what code is involved in the redirect to buffer strategy? Where to start to search if using the NoVersionMapper without the SinglePageManager will have problems with redirect to buffer? Thanks a lot for your time so far. As always you rock (and so does the list) :) On Fri, Sep 26, 2014 at 2:16 PM, Martin Grigorov mgrigo...@apache.org wrote: Thanks for testing! I'm sure there will be problems to be solved. The app is just a proof of concept that it is not that hard to accomplish what Garret wanted. If someone wants to use this in production then (s)he will have to test and optimize it further. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Sep 26, 2014 at 12:58 PM, mscoon msc...@gmail.com wrote: I just tried your demo, it does seem to redirect (the requested url is ?0 while the current url has no version number)... But I was referring to the use of NoVersionMapper without SinglePageManager. I tried this too, and redirect to render breaks because the redirect is to http://blahblah/a and has no way of knowing which version should be used. Redirect to buffer apparently works because the response was buffered during the initial request that did include a page version in the url. On Fri, Sep 26, 2014 at 1:34 PM, Martin Grigorov mgrigo...@apache.org wrote: On Fri, Sep 26, 2014 at 12:23 PM, mscoon msc...@gmail.com wrote: Okay I see. I imagine this approach breaks if the render strategy is REDIRECT_TO_RENDER and works in ONE_PASS_RENDER and REDIRECT_TO_BUFFER. Wicket will redirect only if the requested url differs with the response url. Since the ?pageId is not in the url anymore then it depends only on the page parameters. As you can see in the demo app I haven't played with this. Also REDIRECT_TO_BUFFER works sort of by chance? What would happen if somehow requests from different tabs for the same page (url) were handled simultaneously? Wicket serializes the access to page instance. Since there is only one page instance per type then multitab support is more limited than current Wicket. Request1 will acquire the permit to use the page instance and request2 will wait on PageAccessSynchronizer. Once request1 finishes then if it is Ajax then all as before/now. But if request1 is normal (non-Ajax) then page#renderCount will be incremented and request2 will fail will StalePageException and just re-render with the last state (the one after request1). So you may see more do-nothing interactions with the page than now. On Fri, Sep 26, 2014 at 11:58 AM, Martin Grigorov mgrigo...@apache.org wrote: Hi, What you describe is what several users currently do by using NoVersionMapper. NoVersionMapper is the thing that hides the ?pageId from the url in the address bar. The changes you suggest to be done in SinglePageManager (effectively remove SinglePageManager completely) is the current default behavior in Wicket. The hole is that F5 (page refresh) loses the state and creates a completely new page instance with its own state. Using back/forward will lose the state too. This is the reason why NoVersionMapper is not in the official Wicket distro. Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Fri, Sep 26, 2014 at 10:52 AM, mscoon msc...@gmail.com wrote: Martin, I found you single-page-instance sample very interesting. I have the following question if you can spare some time: What happens if you completely remove the local map in SinglePageManager (and the associated) code? I.e. if SinglePageManager#getPage(int id) always delegates to the underlying manager and SinglePageManager#newPage() always returns a new page from the underlying factory. It seems that then you get the following: 1. Every time you hit a page either by url or navigation, you get a fresh instance, but without a version parameter in the url. Effectively you get a new version of the page but the url does not include the version number. 2. Interactions with the page affect the specific version. As long as you keep interacting with the page (e.g. Increment), you are fine. You can even have the same page in two tabs with different state. 3. If you hit F5 you go back to the page's original state I think the behavior outlined above is also valid for several use cases (e.g. facebook's profile page works like this - there are a lot of ajax interactions but if you hit F5 you go back to the page's original state). Do you see any holes? Thanks
Re: JQWicket - Modal/Dialog to an External URL, Or Something Like It?
Hi, You could simply put an iframe inside your dialog div: div wicket:id=dialog title=Basic dialog iframe src=.../ /div In case the url is dynamic you can attach the iframe to a wicket component and use an attribute modifier to set the src attribute. On Thu, Sep 25, 2014 at 2:04 AM, MissOvenMitts chantal.lucette.da...@gmail.com wrote: Good afternoon everybody! Can one point a dialog in JQWicket to an external URL (or just in Wicket in general..)? E.g. can I have a link that opens a modal dialog showing https://www.google.com/; in it, or something like that? I keep seeing this example over and over, but it's to some internal text you've set up on the page rather than an external site. Java: final DialogWebMarkupContainer dialog = new DialogWebMarkupContainer( dialog, new DialogOptions().modal(true).resizable(false)); add(dialog); add(new AjaxLinkVoid(dialog.open1) { @Override public void onClick(AjaxRequestTarget target) { dialog.open(target); } }); HTML: TestExternal br/ div wicket:id=dialog title=Basic dialog pThis is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon./p /div I'd appreciate any help greatly! Thanks! -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/JQWicket-Modal-Dialog-to-an-External-URL-Or-Something-Like-It-tp4667681.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: turning off page versioning
It is true that page version does seem kind of redundant or even annoying at times. If you have a wicket app that is full ajax (remember that ajax requests don't increment the page version), the only reason you need the page version is so you can have the same page open in two different tabs with different state. If having the same page open multiple times with different state is something not important for a particular application, then you may as well not have a page version at all in the url... As others have pointed out, I too think it would be nice if wicket could support this out of the box (while at the same time making clear what the drawbacks/limitations of this approach are). On Tue, Sep 23, 2014 at 6:05 PM, Thibault Kruse tibokr...@googlemail.com wrote: It is an interesting question whether other web frameworks (also outside JVM world) use any similar page versioning scheme to wicket. I am not aware of any. In any case I guess most projects using wicket would have to make design decisions based on whether the page version is acceptable in the URL or not. There is no simple way of reasonably switching it off once an application has been created without giving this some thought. I don't think every web-framework should strive to be the best choice for facebook or similar, different frameworks may have different strengths and weaknesses (performance, memory-consumption, learning-curve, maintenance-costs, prototyping-speed, etc.) On Tue, Sep 23, 2014 at 3:44 PM, Garret Wilson gar...@globalmentor.com wrote: OMG. What a sad email to wake up to. :( Let me let all that digest for a while. I never would have imagined a situation this dire. Imagine if every time you went to Facebook, it generated a new https://www.facebook.com/jdoe?124154451 version! So basically Facebook could never use Wicket without rewriting the whole page caching scheme. Or LinkedIn. Or... actually, come to think of it, I can't even think of a single site that functions like Wicket, incrementing some page version counter every time you interact with the page, so that you can go back to other versions. (Users don't want to go back to other versions! They may want to go back to other /pages/ at different URLs, but they realize that interacting with a single pages changes the state of that page---they don't expect that other versions are kept around somewhere.) Continuing my scenario I outlined earlier, I have an HTML page called MenuPage, which has wicket:linka href=StagingPage.html..., the target page of which functions as I explained below. Every time the user goes to the MenuPage and clicks on the link, you're saying that Wicket will generate a new version of StagingPage in the cache, even with setVersioned(false)? It will generate a new ...StagingPage.html?23423414 URL? There is no way to turn that off... without essentially rewriting the whole Wicket page request and caching mechanism?? This is not good news. I'm not ranting, I'm crying. Garret On 9/23/2014 8:24 AM, Martin Grigorov wrote: Hi, In short, to accomplish all this you will need several custom impls of Wicket interfaces. 1) custom IRequestMapper that just ignores PageInfo when generating the url for IPageRequestHandler. Search in the archives for NoVersionRequestMapper 2) a completely new IPageManager (interface!) that works with ClassPage instead of with Integer (pageId) So everytime a url is mapped to a page class you should use it to load the Page instance for this class In details: By design only stateless pages do not have the pageId in the url! If a request without pageId comes then a completely new page instance is created. By using something like NoVersionRequestMapper (not supported officially!) only the url for the browser address bar will miss the pageId (see PageAndComponentInfo class), but the pageId is in all link/form urls so clicking/submitting still works. But if the user refreshes the page (F5) then the state is lost! About Page#setVersioned(boolean) This tells Wicket to not increment the pageId after an interaction with the page. A pageId is associated with the page when it is instantiated, but any link click, form submit, etc. won't create a new version of the page. The final result is that every interaction (i.e. state change) with the page will lead to overriding the old one in the page stores. Wicket's IPageStore/IDataStore use API like: put(String sessionId, int pageId, byte[] serializedPage). At the end of every request cycle all rendered stateful pages are stored. If the pageId doesn't change then some old serializedPage would be overriden. For your requirements you will need an API like: put(String sessionId, ClassPage pageClass, byte[] serializedPage) and byte [] get(String sessionId, ClassPage pageClass). You can create a IPageManager wrapper that maps sessionId+pageId
Re: Unit tests that use wicket's session and spring session
Thank you both for your answers. Recent versions of Spring have their own way of creating a mock servlet context and their own mock sessions and requests (MockHttpServletRequest) and those cannot be combined with wicket (at least I didn't find a way to do it), because if you go that route there is no wicket session. I.e. annotating a test with @WebApplication and declaring an autowired field as org.springframework.mock.web.MockHttpServletRequest will give you a spring session but no wicket session. If you instead use WicketTester then it all seems to work. On Tue, Sep 2, 2014 at 4:04 PM, lucast lucastol...@hotmail.com wrote: Hi Marios, Have you had a look at the on-line wicket guide? https://wicket.apache.org/guide/guide/testingspring.html That is a really good chapter for setting up Wicket Spring testing. I hope that helps, Lucas -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Unit-tests-that-use-wicket-s-session-and-spring-session-tp4667270p4667297.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
Unit tests that use wicket's session and spring session
Hi all, Might I ask if there are any pointers to writing tests for wicket that can successfully access wicket's session (i.e. Session.get()) and spring's session (i.e. use session scoped beans either by autowiring or using the spring injector)? Thanks Marios
Dynamically changing column visibility on DataTable during ajax refresh
Hi all, Is there a way to change the visibility of one or more columns of a DataTable during an ajax refresh? The only way I've found so far is to create a new list of columns and replace the DataTable but this is a bit cumbersome compared to simply writing ajaxRequestTarget.add(dataTable); Marios
Re: Dynamically changing column visibility on DataTable during ajax refresh
Thanks Sven. I was looking into implementing a isColumnVisible(int columnIndex) method, and your suggestion makes this quite easy. On Wed, Jun 4, 2014 at 1:53 PM, Sven Meier s...@meiers.net wrote: Hi, you can alter the list of columns you have passed to the DataTable constructor: new DataTable(id, columns, ...); onConfigure() { columns.clear(); columns.addAll(...); } onClick() { target.add(dataTable); } Regards Sven On 06/04/2014 12:20 PM, mscoon wrote: Hi all, Is there a way to change the visibility of one or more columns of a DataTable during an ajax refresh? The only way I've found so far is to create a new list of columns and replace the DataTable but this is a bit cumbersome compared to simply writing ajaxRequestTarget.add(dataTable); Marios - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AjaxTabbedPanel and validation for all tabs
The reason I want to avoid client tabs is speed. The form has several components that are slow to render (drop downs filled with REST service calls). I ended up implementing this as follows: - An AjaxTabbedPanel with links that will submit the form currently shown (I look for the first child of class Form of the AjaxTabbedPanel but one could as well submit a form containing the AjaxTabbedPanel) - My own validation utility that validates objects using wicket's validation framework. This is more or less an object that allows the developer to attach validators to class properties. Then an object is validated by generating a Validatable object for each property and running the attached validators. Finally, errors are propagated to form components by matching the component id to the property name. - Validation runs on the entire object, not just one tab. So: - Every time the user tries to switch tabs, the form is submitted, and the entire object is validated. The errors relevant to the current tab are isolated and shown in a feedback panel inside the tab, and the tab-switching is cancelled. If there are no errors relevant to the current tab, the tab-switching goes ahead. - If the user clicks save, again the current form is submitted and the entire object is validated. If there are any errors, the user gets a popup message that indicates which tabs have errors. There are a few more details involved which I won't go into unless somebody wants to get the full story. Overall it's not a super clean solution, but it is not too bad either. Wicket again came through and made it possible to implement this scenario without much pain. And I'm quite happy with my object validator. Because now I get a validator that can run both on a form (by validating it's model object) and on another channel of data entry (say a REST service) that reuses wicket's validators and error messages (so it's consistent with other forms that directly use wicket's validation). Marios On Wed, May 7, 2014 at 9:43 AM, Tom Götz t...@decoded.de wrote: The easiest solution I can think of. Why do you want to avoid that? Cheers, -Tom On 06.05.2014, at 16:13, mscoon msc...@gmail.com wrote: Is there a way to solve this? Client side tabs are a solution I guess but one I'd like to avoid if possible.
Re: problem with AbstractEntityModel from Igor Vaynberg
I don't understand what these lines are doing. Are you reloading whatever is already stored in your modelObject.kunde and setting it again to your model object? Why? On Thu, May 8, 2014 at 7:50 AM, Piratenvisier hansheinrichbr...@yahoo.dewrote: If I include the folowing lines : if(NachweiseForm.this.getModelObject().getKunde()!=null) { Kunde kunde = kundeManager.get(NachweiseForm.this. getModelObject().getKunde().getId()); NachweiseForm.this.getModelObject().setKunde(kunde); kunde.addNachweis(NachweiseForm.this.getModelObject()); System.err.println(Kunde); } before the save everything is fine But I hoped to avoid such lines by AbstractEntityModel. My idea was to implant Kunde through the form. But how could you do it only by a Label. Am 05.05.2014 20:40, schrieb mscoon: Actually what I said below is wrong because this line is after the line that throws the exception. But my explanation still holds. Something before the line that is throwing the exception is causing an object with a reference to a new Nachweise to be saved while the Nachweise is still unsaved. You need to search at what is happening before the line with the exception, maybe even before the page is created. Now, a wild guess (I may well be wrong) is that the following line: nachweiseform.getModelObject().getKunde().addNachweis(nachwe iseform.getModelObject()); may be causing the problem if hibernate tries to save kunde with nachweiseform.getModelObject() which is a new object with a null id. You may try to move this line to saveNachweise(). On Mon, May 5, 2014 at 2:54 PM, Yahoo hansheinrichbr...@yahoo.de wrote: Am 05.05.2014 11:05, schrieb mscoon: In a previous message you sent the following snippets: //@XmlTransient @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false) public Kunde getKunde(){ return this.kunde; } recursive Part for Kunde @XmlTransient @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false ) when I remove this I get the error : org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: braunimmobilien.model.Nachweise at org.hibernate.engine.internal.ForeignKeys. getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249) at org.hibernate.type.EntityType.getIdentifier(EntityType.java: 459) at org.hibernate.type.ManyToOneType.nullSafeSet( ManyToOneType.java:132) at org.hibernate.persister.collection. AbstractCollectionPersister. writeElement(AbstractCollectionPersister.java:867) at org.hibernate.persister.collection. AbstractCollectionPersister. insertRows(AbstractCollectionPersister.java:1475) at org.hibernate.action.internal.CollectionUpdateAction.execute( CollectionUpdateAction.java:86) at org.hibernate.engine.spi.ActionQueue.execute( ActionQueue.java:362) at org.hibernate.engine.spi.ActionQueue.executeActions( ActionQueue.java:354) at org.hibernate.engine.spi.ActionQueue.executeActions( ActionQueue.java:278) at org.hibernate.event.internal.AbstractFlushingEventListener. performExecutions(AbstractFlushingEventListener.java:326) at org.hibernate.event.internal.DefaultFlushEventListener. onFlush( DefaultFlushEventListener.java:52) at org.hibernate.internal.SessionImpl.flush(SessionImpl. java:1213) at org.hibernate.internal.SessionImpl.managedFlush( SessionImpl.java:402) at org.hibernate.engine.transaction.internal.jdbc. JdbcTransaction. beforeTransactionCommit(JdbcTransaction.java:101) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl. commit(AbstractTransactionImpl.java:175) at org.springframework.orm.hibernate4. HibernateTransactionManager. doCommit(HibernateTransactionManager.java:554) at org.springframework.transaction.support. AbstractPlatformTransactionManager.processCommit( AbstractPlatformTransactionManager.java:755) at org.springframework.transaction.support. AbstractPlatformTransactionManager.commit( AbstractPlatformTransactionMan ager.java:724) at org.springframework.transaction.interceptor. TransactionAspectSupport.commitTransactionAfterReturnin g(TransactionAspectSupport.java:475) at org.springframework.transaction.interceptor. TransactionAspectSupport.invokeWithinTransaction( TransactionAspectSupport.java:270) at org.springframework.transaction.interceptor. TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation. proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.interceptor. ExposeInvocationInterceptor. invoke(ExposeInvocationInterceptor.java:91
AjaxTabbedPanel and validation for all tabs
Hi all, I have a complex form for editing existing objects. I am planning to use AjaxTabbedPanel with adapted ajax links for the tabs to submit the current tab when the user switches tabs. There will be a save button under the tabbed panel that will save the entire object. For new objects, I could force the user to visit all tabs before allowing them to save, to guarantee that the validators have ran for all form components and all tabs. The twist here is that the object, when loaded, may be invalid. But I don't want to force the user to visit all tabs when editing an existing object because it will very unfriendly (imagine the user wanting to update just one field in the first tab and being forced to visit all five tabs before saving). So I am looking for a way to make sure that all validators run when the user clicks save. As far as I understand there is no way to force all wicket validators to execute because the request will only contain post data for the active tab. Is there a way to solve this? Client side tabs are a solution I guess but one I'd like to avoid if possible. I did consider moving my validation logic to a server side validation method. The problem here is that you cannot leverage wicket's existing validators and error messages and also it becomes considerably harder to provide visual feedback for errors (e.g. highlight the components with errors). On the plus side, you do have a validation method that can be reused if you have alternate methods for updating the same data (e.g. via a REST service). Are there any pointers on using server side validation with wicket forms? Thanks in advance, Marios
Re: problem with AbstractEntityModel from Igor Vaynberg
In a previous message you sent the following snippets: //@XmlTransient @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false) public Kunde getKunde(){ return this.kunde; } recursive Part for Kunde @XmlTransient @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false ) public ListNachweise getNachweise() { return nachweise; } It seems like both sides of the relationship are set as insertable=false, updatable = false. This would explain why kunde becomes null after saving, though it contradicts your statement that everything is saved ok in the db. Either way the AbstractEntityModel has nothing to do with how properties of the model object are stored in the db, so I still believe the problem is somewhere else in your code. Marios On Mon, May 5, 2014 at 11:26 AM, Yahoo hansheinrichbr...@yahoo.de wrote: First I have to tell you concerning the mapping I used the wrong word the dependencies in the mapping are not recursive bur circular. Am 04.05.2014 22:24, schrieb mscoon: I'm not sure I see something wrong in your code, but then again you have omitted a lot of stuff which could be cruicial. Does nachweiseform have any components that show/update kunde? Label nachkundnr=new Label(kunde.id); add(nachkundnr); What exactly do you mean by saying after save it disappears? Has it been stored correctly in the database or is it wrong there too? Everything is stored correctly in the Database only NachKundNr is NULL Have you tried to create a minimal case where you are setting kunde to an object without having any wicket forms? I have no problems with kunde in the TestCases What is the value of kunde before saving to the db? If it is correctly set then you likely have a problem with your mapping. If it's not correctly set then something is wrong with your form. The problem is only with new Kunde() because Kunde must be preset and cannot be changed in the Form. Before using AbstractEntityModel I took all Ids of the MANYTOONE relationships in the model and loaded them from the Database and implanted them newly in Kunde before storing. My hope was to avoid this by using AbstractEntityModel.This works for all Dependencies which are set in the Form On Sun, May 4, 2014 at 1:02 PM, Yahoo hansheinrichbr...@yahoo.de wrote: I have a suspicion: I have defened all dependencies with jpa or hibernate annotation. So I have also a lot of cicular dependencies, which sometimes make problem. I will give you 2 examples. one which is OK when I use AbstractEntityModel and on which makes problem, which is not set in the form through the Model but before. 1. the hibernatemodel: @IndexedEmbedded @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY) @JoinColumn(name=NachAngNr,insertable=false, updatable=false) public Angebot getAngebot(){ return this.angebot; } recursive part in Angebot: @XmlTransient @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY) @JoinColumn(name=NachAngNr,nullable=false ) public ListNachweise getNachweise() { return nachweise; } Angebot is set by DropDownChoice in the form privateIModelList? extends Angebot makeChoicesAngebote = new AbstractReadOnlyModelList? extends Angebot() { @Override public ListAngebot getObject() { ListAngebot angebotelist=new ArrayListAngebot(); Iterator angeboteiterator= angebotManager.getAngebote().iterator(); while(angeboteiterator.hasNext()){ Angebot angebot=(Angebot)angeboteiterator.next(); if(angebot.getAngstatus().getId().longValue()==1) angebotelist.add(angebot); } return angebotelist; } }; IChoiceRendererAngebot angebotchoicerenderer= new IChoiceRendererAngebot() { public Object getDisplayValue(Angebot angebot) { return angebot.getId(); } public String getIdValue(Angebot angebot,int index) { return angebot.getId(); } }; final DropDownChoiceAngebot angebote = new DropDownChoiceAngebot( angebot, makeChoicesAngebote,angebotchoicerenderer); The recursive part is treated in NachweiseManagerImpl : public Nachweise saveNachweise(Nachweise nachweise) throws NachweiseExistsException { try { if(nachweise.getId()==null){ System.err.println(xx Id=null); if(nachweise.getMitarbeiter()!=null) { } === recursive Part for Kunde
Re: problem with AbstractEntityModel from Igor Vaynberg
This is a hibernate issue, not a wicket issue. As I said before I am now 99% sure the problem is with the way you are using hibernate. The bug you are getting is not caused by the line you highlighted. The line Kunde kunde=kundeManager.get(new Long(pars.get(kundennr).toString())); executes a select query to the database. Hibernate will try to flush all pending inserts and updates before issuing a select. So what is happening is that somewhere earlier you have updated an object (say object A) with a reference to another object (say object B) which has not been saved. For instance you did: B b = new B(); a.addtB(b); When hibernate tries to update a, it will throw this exception because b has not been saved and has no id. What you should do is: B b = new B(); session.save(b); a.addB(b); This is just an example of how hibernate works with respect to the bug you are getting. Now, a wild guess (I may well be wrong) is that the following line: nachweiseform.getModelObject().getKunde().addNachweis(nachwe iseform.getModelObject()); may be causing the problem if hibernate tries to save kunde with nachweiseform.getModelObject() which is a new object with a null id. You may try to move this line to saveNachweise(). On Mon, May 5, 2014 at 2:54 PM, Yahoo hansheinrichbr...@yahoo.de wrote: Am 05.05.2014 11:05, schrieb mscoon: In a previous message you sent the following snippets: //@XmlTransient @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false) public Kunde getKunde(){ return this.kunde; } recursive Part for Kunde @XmlTransient @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false ) when I remove this I get the error : org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: braunimmobilien.model.Nachweise at org.hibernate.engine.internal.ForeignKeys. getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:459) at org.hibernate.type.ManyToOneType.nullSafeSet( ManyToOneType.java:132) at org.hibernate.persister.collection.AbstractCollectionPersister. writeElement(AbstractCollectionPersister.java:867) at org.hibernate.persister.collection.AbstractCollectionPersister. insertRows(AbstractCollectionPersister.java:1475) at org.hibernate.action.internal.CollectionUpdateAction.execute( CollectionUpdateAction.java:86) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362) at org.hibernate.engine.spi.ActionQueue.executeActions( ActionQueue.java:354) at org.hibernate.engine.spi.ActionQueue.executeActions( ActionQueue.java:278) at org.hibernate.event.internal.AbstractFlushingEventListener. performExecutions(AbstractFlushingEventListener.java:326) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush( DefaultFlushEventListener.java:52) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213) at org.hibernate.internal.SessionImpl.managedFlush( SessionImpl.java:402) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction. beforeTransactionCommit(JdbcTransaction.java:101) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl. commit(AbstractTransactionImpl.java:175) at org.springframework.orm.hibernate4.HibernateTransactionManager. doCommit(HibernateTransactionManager.java:554) at org.springframework.transaction.support. AbstractPlatformTransactionManager.processCommit( AbstractPlatformTransactionManager.java:755) at org.springframework.transaction.support. AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionMan ager.java:724) at org.springframework.transaction.interceptor. TransactionAspectSupport.commitTransactionAfterReturnin g(TransactionAspectSupport.java:475) at org.springframework.transaction.interceptor. TransactionAspectSupport.invokeWithinTransaction( TransactionAspectSupport.java:270) at org.springframework.transaction.interceptor. TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation. proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.interceptor.ExposeInvocationInterceptor. invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation. proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy. invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy112.get(Unknown Source) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke( LazyInitProxyFactory.java:435) at com.sun.proxy
Re: problem with AbstractEntityModel from Igor Vaynberg
Actually what I said below is wrong because this line is after the line that throws the exception. But my explanation still holds. Something before the line that is throwing the exception is causing an object with a reference to a new Nachweise to be saved while the Nachweise is still unsaved. You need to search at what is happening before the line with the exception, maybe even before the page is created. Now, a wild guess (I may well be wrong) is that the following line: nachweiseform.getModelObject().getKunde().addNachweis(nachwe iseform.getModelObject()); may be causing the problem if hibernate tries to save kunde with nachweiseform.getModelObject() which is a new object with a null id. You may try to move this line to saveNachweise(). On Mon, May 5, 2014 at 2:54 PM, Yahoo hansheinrichbr...@yahoo.de wrote: Am 05.05.2014 11:05, schrieb mscoon: In a previous message you sent the following snippets: //@XmlTransient @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false) public Kunde getKunde(){ return this.kunde; } recursive Part for Kunde @XmlTransient @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false ) when I remove this I get the error : org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: braunimmobilien.model.Nachweise at org.hibernate.engine.internal.ForeignKeys. getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:459) at org.hibernate.type.ManyToOneType.nullSafeSet( ManyToOneType.java:132) at org.hibernate.persister.collection.AbstractCollectionPersister. writeElement(AbstractCollectionPersister.java:867) at org.hibernate.persister.collection.AbstractCollectionPersister. insertRows(AbstractCollectionPersister.java:1475) at org.hibernate.action.internal.CollectionUpdateAction.execute( CollectionUpdateAction.java:86) at org.hibernate.engine.spi.ActionQueue.execute( ActionQueue.java:362) at org.hibernate.engine.spi.ActionQueue.executeActions( ActionQueue.java:354) at org.hibernate.engine.spi.ActionQueue.executeActions( ActionQueue.java:278) at org.hibernate.event.internal.AbstractFlushingEventListener. performExecutions(AbstractFlushingEventListener.java:326) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush( DefaultFlushEventListener.java:52) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213) at org.hibernate.internal.SessionImpl.managedFlush( SessionImpl.java:402) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction. beforeTransactionCommit(JdbcTransaction.java:101) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl. commit(AbstractTransactionImpl.java:175) at org.springframework.orm.hibernate4.HibernateTransactionManager. doCommit(HibernateTransactionManager.java:554) at org.springframework.transaction.support. AbstractPlatformTransactionManager.processCommit( AbstractPlatformTransactionManager.java:755) at org.springframework.transaction.support. AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionMan ager.java:724) at org.springframework.transaction.interceptor. TransactionAspectSupport.commitTransactionAfterReturnin g(TransactionAspectSupport.java:475) at org.springframework.transaction.interceptor. TransactionAspectSupport.invokeWithinTransaction( TransactionAspectSupport.java:270) at org.springframework.transaction.interceptor. TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation. proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.interceptor.ExposeInvocationInterceptor. invoke(ExposeInvocationInterceptor.java:91) at org.springframework.aop.framework.ReflectiveMethodInvocation. proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy. invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy112.get(Unknown Source) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke( LazyInitProxyFactory.java:435) at com.sun.proxy.$Proxy94.get(Unknown Source) at braunimmobilien.webapp.nachweis.NachweisPanel.init( NachweisPanel.java:100) at braunimmobilien.webapp.nachweis.NachweisPage.init( NachweisPage.java:47) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.apache.wicket.session.DefaultPageFactory.newPage( DefaultPageFactory.java:171) at org.apache.wicket.session.DefaultPageFactory.newPage( DefaultPageFactory.java:99
Re: problem with AbstractEntityModel from Igor Vaynberg
Usually this is not a problem. But maybe you are doing something different that the usual. I think you will need to show us your code to help you any further. On Sun, May 4, 2014 at 9:12 AM, Yahoo hansheinrichbr...@yahoo.de wrote: It's the solution for all MANYTOONE-Fields defined in the Form I have a MANYTOONE-Field which is preset and not set in the Form. This field is not stored. Am 02.05.2014 01:24, schrieb mscoon: No you don't. The referenced objects will be serialized along with the entity you are serializing and everything should work just fine. On Thu, May 1, 2014 at 10:30 PM, Yahoo hansheinrichbr...@yahoo.de wrote: Ok,thank you, that's it. My Entity has a lot of MANYTOONE relationships which are set byDropDownChoices. In the case of a new entity, do I have to load all these Entities too and to save their ids ? Am 01.05.2014 15:01, schrieb mscoon: Heiner, You didn't tell us which dependency injection framework you you using. If you're using Spring then simply use the @SpringBean annotation to get a reference to an EntityManager or a Dao. @SpringBean automatically works only for components so you'll also need to add a call to injector to your model's constructor. public class MyModel implements IModel { @SpringBean EntityManager entityManager; public MyModel() { Injector.get().inject(this); } ... } This will take care of instantiating all @SpringBean annotated fields as well are handle their serialization/deserialization. Marios On Thu, May 1, 2014 at 3:42 PM, Yahoo hansheinrichbr...@yahoo.de wrote: I tried the AbstractEntityModel http://http://wicketinaction. com/2008/09/building-a-smart-entitymodel/ from Igor Vaynberg but I didn't get solved the @Dependency annotation from Vaynbergs salve. Is there another solution for the Hibernate integration for models. Best regards Heiner - 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: problem with AbstractEntityModel from Igor Vaynberg
= CascadeType.MERGE,fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false) public Kunde getKunde(){ return this.kunde; } recursive Part for Kunde @XmlTransient @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY) @JoinColumn(name=NachKundNr,insertable=false, updatable=false ) public ListNachweise getNachweise() { return nachweise; } Kunde ist set is set after before adding the form : final NachweiseForm nachweiseform=new NachweiseForm(form,model); if (!(pars.getPosition(nachweisnr)=0pars.get(nachweisnr).toLong()0)) { if (pars.getPosition(kundennr)=0pars.get(kundennr).toLong()0) { Kunde kunde=kundeManager.get(new Long(pars.get(kundennr). toString())); System.err.println(== set Kunde reached); nachweiseform.getModelObject().setKunde(kunde); === recursive Part for Kunde early set === nachweiseform.getModelObject().getKunde().addNachweis( nachweiseform.getModelObject()); } } after opening the form you see the Id of Kunde after save it disappears. add(nachweiseform); When I set the recursive part later same result When I try to set the recursive part later I get the same result Am 04.05.2014 08:55, schrieb mscoon: Usually this is not a problem. But maybe you are doing something different that the usual. I think you will need to show us your code to help you any further. On Sun, May 4, 2014 at 9:12 AM, Yahoo hansheinrichbr...@yahoo.de wrote: It's the solution for all MANYTOONE-Fields defined in the Form I have a MANYTOONE-Field which is preset and not set in the Form. This field is not stored. Am 02.05.2014 01:24, schrieb mscoon: No you don't. The referenced objects will be serialized along with the entity you are serializing and everything should work just fine. On Thu, May 1, 2014 at 10:30 PM, Yahoo hansheinrichbr...@yahoo.de wrote: Ok,thank you, that's it. My Entity has a lot of MANYTOONE relationships which are set byDropDownChoices. In the case of a new entity, do I have to load all these Entities too and to save their ids ? Am 01.05.2014 15:01, schrieb mscoon: Heiner, You didn't tell us which dependency injection framework you you using. If you're using Spring then simply use the @SpringBean annotation to get a reference to an EntityManager or a Dao. @SpringBean automatically works only for components so you'll also need to add a call to injector to your model's constructor. public class MyModel implements IModel { @SpringBean EntityManager entityManager; public MyModel() { Injector.get().inject(this); } ... } This will take care of instantiating all @SpringBean annotated fields as well are handle their serialization/deserialization. Marios On Thu, May 1, 2014 at 3:42 PM, Yahoo hansheinrichbr...@yahoo.de wrote: I tried the AbstractEntityModel http://http://wicketinaction. com/2008/09/building-a-smart-entitymodel/ from Igor Vaynberg but I didn't get solved the @Dependency annotation from Vaynbergs salve. Is there another solution for the Hibernate integration for models. Best regards Heiner - 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: problem with AbstractEntityModel from Igor Vaynberg
Heiner, You didn't tell us which dependency injection framework you you using. If you're using Spring then simply use the @SpringBean annotation to get a reference to an EntityManager or a Dao. @SpringBean automatically works only for components so you'll also need to add a call to injector to your model's constructor. public class MyModel implements IModel { @SpringBean EntityManager entityManager; public MyModel() { Injector.get().inject(this); } ... } This will take care of instantiating all @SpringBean annotated fields as well are handle their serialization/deserialization. Marios On Thu, May 1, 2014 at 3:42 PM, Yahoo hansheinrichbr...@yahoo.de wrote: I tried the AbstractEntityModel http://http://wicketinaction. com/2008/09/building-a-smart-entitymodel/ from Igor Vaynberg but I didn't get solved the @Dependency annotation from Vaynbergs salve. Is there another solution for the Hibernate integration for models. Best regards Heiner
Re: problem with AbstractEntityModel from Igor Vaynberg
No you don't. The referenced objects will be serialized along with the entity you are serializing and everything should work just fine. On Thu, May 1, 2014 at 10:30 PM, Yahoo hansheinrichbr...@yahoo.de wrote: Ok,thank you, that's it. My Entity has a lot of MANYTOONE relationships which are set byDropDownChoices. In the case of a new entity, do I have to load all these Entities too and to save their ids ? Am 01.05.2014 15:01, schrieb mscoon: Heiner, You didn't tell us which dependency injection framework you you using. If you're using Spring then simply use the @SpringBean annotation to get a reference to an EntityManager or a Dao. @SpringBean automatically works only for components so you'll also need to add a call to injector to your model's constructor. public class MyModel implements IModel { @SpringBean EntityManager entityManager; public MyModel() { Injector.get().inject(this); } ... } This will take care of instantiating all @SpringBean annotated fields as well are handle their serialization/deserialization. Marios On Thu, May 1, 2014 at 3:42 PM, Yahoo hansheinrichbr...@yahoo.de wrote: I tried the AbstractEntityModel http://http://wicketinaction. com/2008/09/building-a-smart-entitymodel/ from Igor Vaynberg but I didn't get solved the @Dependency annotation from Vaynbergs salve. Is there another solution for the Hibernate integration for models. Best regards Heiner - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org