Re: Iterate over Pages in Pagemap
Why not make your pages consult some kind of service that builds the navigation? And then have some a timer that get back to the server and looks for a flag newEntriesAdded and then repaint part of the page via AJAX? Another possibility is get changes pushed to your pages using reverse AJAX, but this might be a bit trickier to implement... if you want to use this last approach, I think, there is a project at wicket-stuff that targets those use cases (I think is DOJO based?)... I have used plain DWR, in combination with Wicket, for implementing similar functionalities Cheers, Ernesto On Tue, Nov 10, 2009 at 8:54 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Hi all, how to iterate over latest version of all pages in pagemap? All my Pages have the ability to reload the navigation, but to accomplish this, I need to tell the page to reload the navigation. So my first idea was to iterate over latest version of all pages in pagemap and call the needed method on it. But Session#getPageMaps returns a list of IPageMap which doesn't offer an iterator. How can a accomplish this? Greets Chris
Re: Combination CompoundPropertyModel and ChoiceRenderer on DropDownChoice gives problems
Hi Alex, Expose description and id on your model's object. If I understand what you're saying, this was the problem, we did want the Component's Model to be i.e. a String, while giving the choices an id-descr-like bean... But this is not working (must have same object type on choices and component model), so the code above returns a List of Strings as choices, and uses a suitable choiceRenderer in order to retrieve descriptions from the 'description-enhanced' choice model, which consists of a Map id, description... public final static ChoiceRenderer listRenderer = new ChoiceRenderer(description, id); If i'm not wrong, this one will work when there is no Model object but when there is one, it will throw out an exception, complaining it doesn't find property 'id' nor 'description' in class String (which will be the class of the Component's Model object).. I don't know If i got your point though, Thanks! Xavier 2009/11/9 Alex Rass a...@itbsllc.com I am a newb here, so I may be way off, but this works for me: public final static ChoiceRenderer listRenderer = new ChoiceRenderer(description, id); Expose description and id on your model's object. And just add the listRenderer to the DDChoice (last param). Seems a lot simpler than what you are doing. -Original Message- From: Xavier López [mailto:xavil...@gmail.com] Sent: Monday, November 09, 2009 9:37 AM To: users@wicket.apache.org Subject: Re: Combination CompoundPropertyModel and ChoiceRenderer on DropDownChoice gives problems Got it! Here is the code i got into. Improvements and critics are welcome ! class MappedModel extends Model { protected Map map; public String getDescription(Object id){ return (String) map.get(id); } } // Localized choices final MappedModel countryModel = new MappedModel(){ public Object getObject() { super.map = referenceData.getCountries(getLanguage()); return new ArrayList(super.map.keySet()); } }; DropDownChoice ddcCountry= new DropDownChoice(country,countryModel); ddcCountry.setChoiceRenderer(new IChoiceRenderer() { public Object getDisplayValue(Object object) { return countryModel.getDescription(object); } public String getIdValue(Object object, int index) { return object.toString(); } }); Thanks to everyone on this list not only for the heads up on this one but for many more I did not need to ask ;) 2009/11/9 Xavier López xavil...@gmail.com Hi Sven, Absolutely awesome. So sweet how problems vanish away when you know the right way to address them on Wicket: ). But, what if I had a list of countries in the database (better example than gender in this case), with its descriptions in it? Should I store a Country entity in my bean, instead of simply and Id (taking into account this entity possibly contains the descriptions and other unuseful stuff) ? Could I manage someway, using the countryId's in the ddc's choiceList model, to look for those descriptions in i.e. a memory-stored Map ? Thanks a lot! Xavier 2009/11/9 svenmeier s...@meiers.net You want to select one value from a list of values, so obviously everything has to have the same type. These 'IdDescrBeans' smell like Struts, such constructs are not needed. What's wrong with the following: ListString genders = new ArrayListString(); list.add(M); list.add(F); form.add(new DropDownChoice(gender, genders) { protected boolean localizeDisplayValues() { return true; } }); Creating an enum would be a nice alternative to strings though. Put the following keys in you page's property file: gender.M = male gender.F = female i18n for free. Sven Xavier López-2 wrote: Hi Ann, I've also encountered this problem, but with RadioChoice instead of DropDownChoice. This is the thread I started about it: http://mail-archives.apache.org/mod_mbox/wicket-users/200911.mbox/browser After all this thread, I still don't know what should I do to model, for instance, a gender radioChoice which would be backed by a String property (M of F), providing a list of choices (multilingual) with IdDescrBeans like you propose. Should I change my bean's 'String gender' property to 'IdDescrBean gender' ? Why should I store description's information on my model entity ? Although I agree with having same object's on choices and model when it's about more complex data... Possible solutions I've thought of so far: - Ideally, do not use different object types in compundpropertymodel's bean and choice List. Use same object type instead. - When using RadioChoice, it works if you substitute it with a RadioGroup
AW: Iterate over Pages in Pagemap
Well, i don't want a timer in the page. This causes unneeded checks. That's why I thought of the simplest solution. The basepage gets its navigation from session (which gets rebuild upon changes to stay up2date). Now I need a way to notify the page that navigation changed. So I implemented following method in basepage. ... public void refreshNavigation() { this.navigation.replaceWith(AuthenticatedWebSession.get().getNavi()); AjaxRequestTarget.get().addComponent(this.navigation); } ... Now all I have to do is call this method for each active page to refresh navigation (or am I wrong?). Can you tell me a bit more about reverse ajax? Greets Chris -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 10. November 2009 09:21 An: users@wicket.apache.org Betreff: Re: Iterate over Pages in Pagemap Why not make your pages consult some kind of service that builds the navigation? And then have some a timer that get back to the server and looks for a flag newEntriesAdded and then repaint part of the page via AJAX? Another possibility is get changes pushed to your pages using reverse AJAX, but this might be a bit trickier to implement... if you want to use this last approach, I think, there is a project at wicket-stuff that targets those use cases (I think is DOJO based?)... I have used plain DWR, in combination with Wicket, for implementing similar functionalities Cheers, Ernesto On Tue, Nov 10, 2009 at 8:54 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Hi all, how to iterate over latest version of all pages in pagemap? All my Pages have the ability to reload the navigation, but to accomplish this, I need to tell the page to reload the navigation. So my first idea was to iterate over latest version of all pages in pagemap and call the needed method on it. But Session#getPageMaps returns a list of IPageMap which doesn't offer an iterator. How can a accomplish this? Greets Chris - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Iterate over Pages in Pagemap
Hi, On Tue, Nov 10, 2009 at 9:36 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Well, i don't want a timer in the page. This causes unneeded checks. That's why I thought of the simplest solution. The basepage gets its navigation from session (which gets rebuild upon changes to stay up2date). Now I need a way to notify the page that navigation changed. So I implemented following method in basepage. ... public void refreshNavigation() { this.navigation.replaceWith(AuthenticatedWebSession.get().getNavi()); AjaxRequestTarget.get().addComponent(this.navigation); } ... So, your Application object will act as a factory of components? I wouldn't follow that approach myself. At most the application would contain the data for the navigation and then the navigation component will fetch that data and rebuild itself. Now all I have to do is call this method for each active page to refresh navigation (or am I wrong?). Just one question? How would a remote page know that it has to reload itself? Do you plan to do that next time user get backs to the server with an AJAX request? If so, then you don't need anything else (I guess.) But if you want this to happen even if the user do not interact with the page. Then either you need a timer or use reverse AJAX. Can you tell me a bit more about reverse ajax? Just google for reverse AJAX, comet, server push, etc and you will have enough to read... Regards, Ernesto
AW: Iterate over Pages in Pagemap
So, your Application object will act as a factory of components? I wouldn't follow that approach myself. At most the application would contain the data for the navigation and then the navigation component will fetch that data and rebuild itself. Well, no. The session holds the navigation and triggers a method on it, so the navigation rebuilds itself. I need to hold it in session cause the available navigationentries depend on user roles. But your right with reverse ajax, I think I need it. Wicket is so Swing, so I totally forgot I'm working with a webapp :) I will read more about reverse ajax. Btw, cant find any wicketstuff-push svn or project description. Greets Chris -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 10. November 2009 09:54 An: users@wicket.apache.org Betreff: Re: Iterate over Pages in Pagemap Hi, On Tue, Nov 10, 2009 at 9:36 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Well, i don't want a timer in the page. This causes unneeded checks. That's why I thought of the simplest solution. The basepage gets its navigation from session (which gets rebuild upon changes to stay up2date). Now I need a way to notify the page that navigation changed. So I implemented following method in basepage. ... public void refreshNavigation() { this.navigation.replaceWith(AuthenticatedWebSession.get().getNavi()); AjaxRequestTarget.get().addComponent(this.navigation); } ... So, your Application object will act as a factory of components? I wouldn't follow that approach myself. At most the application would contain the data for the navigation and then the navigation component will fetch that data and rebuild itself. Now all I have to do is call this method for each active page to refresh navigation (or am I wrong?). Just one question? How would a remote page know that it has to reload itself? Do you plan to do that next time user get backs to the server with an AJAX request? If so, then you don't need anything else (I guess.) But if you want this to happen even if the user do not interact with the page. Then either you need a timer or use reverse AJAX. Can you tell me a bit more about reverse ajax? Just google for reverse AJAX, comet, server push, etc and you will have enough to read... Regards, Ernesto - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Iterate over Pages in Pagemap
I haven't used wicketstuff-push myself so I can't be of much help there. I once had to implement some push functionality and I used DWR in combination with Wicket. Going the reverse AJAX can complicate things a lot (or so I believe). Thus, think carefully if what you want to achieve cannot be accomplished using other means. e.g. an AJAX timer that polls the server from time to time and if new navigation is available updates what you need to update (maybe asking the user if they want to do so;-). Regards, Ernesto On Tue, Nov 10, 2009 at 10:25 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: So, your Application object will act as a factory of components? I wouldn't follow that approach myself. At most the application would contain the data for the navigation and then the navigation component will fetch that data and rebuild itself. Well, no. The session holds the navigation and triggers a method on it, so the navigation rebuilds itself. I need to hold it in session cause the available navigationentries depend on user roles. But your right with reverse ajax, I think I need it. Wicket is so Swing, so I totally forgot I'm working with a webapp :) I will read more about reverse ajax. Btw, cant find any wicketstuff-push svn or project description. Greets Chris -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 10. November 2009 09:54 An: users@wicket.apache.org Betreff: Re: Iterate over Pages in Pagemap Hi, On Tue, Nov 10, 2009 at 9:36 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Well, i don't want a timer in the page. This causes unneeded checks. That's why I thought of the simplest solution. The basepage gets its navigation from session (which gets rebuild upon changes to stay up2date). Now I need a way to notify the page that navigation changed. So I implemented following method in basepage. ... public void refreshNavigation() { this.navigation.replaceWith(AuthenticatedWebSession.get().getNavi()); AjaxRequestTarget.get().addComponent(this.navigation); } ... So, your Application object will act as a factory of components? I wouldn't follow that approach myself. At most the application would contain the data for the navigation and then the navigation component will fetch that data and rebuild itself. Now all I have to do is call this method for each active page to refresh navigation (or am I wrong?). Just one question? How would a remote page know that it has to reload itself? Do you plan to do that next time user get backs to the server with an AJAX request? If so, then you don't need anything else (I guess.) But if you want this to happen even if the user do not interact with the page. Then either you need a timer or use reverse AJAX. Can you tell me a bit more about reverse ajax? Just google for reverse AJAX, comet, server push, etc and you will have enough to read... Regards, Ernesto - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Force page reload/re-render
if(userSetWasChanged){ target.appendJavascript(window.location.reload()); or setResponsePage(getPage()); or setResponsePage(getPage().getClass()); } On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen pieter.claas...@gmail.comwrote: I have a link on a panel that is included in many pages. When the user clicks on the link, I change something in the user settings that will affect what gets displayed on the page. However, for that to work, I need to reload the page after the user clicked on the link as by default the other components that now need to be checked for conditional visibility don't re-render (why not?). setResponsePage() requires me to pass into the panel a target page and this becomes complex when you have a mix of statefull and stateless pages as targets (and it just doesn't feel right). I am sure there must be an easier way to just re-render a page? Any tips? Thanks, pieter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pedro Henrique Oliveira dos Santos
AW: Iterate over Pages in Pagemap
I agree that i should be carefully. But, back to the timer, let's assume I have 16 versions of one page in pagemap and each of 16 versions has a timer. Then there are 16 timers polling information from server, well if there are only 16 versions of one page, the traffic is low, but if the page count increase I have much unneeded traffic. You know I mean? I will look at push but I hold timer in mind. Btw, do you come to London on 21.11 (Jweekend)? Greets Chris -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 10. November 2009 11:44 An: users@wicket.apache.org Betreff: Re: Iterate over Pages in Pagemap I haven't used wicketstuff-push myself so I can't be of much help there. I once had to implement some push functionality and I used DWR in combination with Wicket. Going the reverse AJAX can complicate things a lot (or so I believe). Thus, think carefully if what you want to achieve cannot be accomplished using other means. e.g. an AJAX timer that polls the server from time to time and if new navigation is available updates what you need to update (maybe asking the user if they want to do so;-). Regards, Ernesto On Tue, Nov 10, 2009 at 10:25 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: So, your Application object will act as a factory of components? I wouldn't follow that approach myself. At most the application would contain the data for the navigation and then the navigation component will fetch that data and rebuild itself. Well, no. The session holds the navigation and triggers a method on it, so the navigation rebuilds itself. I need to hold it in session cause the available navigationentries depend on user roles. But your right with reverse ajax, I think I need it. Wicket is so Swing, so I totally forgot I'm working with a webapp :) I will read more about reverse ajax. Btw, cant find any wicketstuff-push svn or project description. Greets Chris -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 10. November 2009 09:54 An: users@wicket.apache.org Betreff: Re: Iterate over Pages in Pagemap Hi, On Tue, Nov 10, 2009 at 9:36 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Well, i don't want a timer in the page. This causes unneeded checks. That's why I thought of the simplest solution. The basepage gets its navigation from session (which gets rebuild upon changes to stay up2date). Now I need a way to notify the page that navigation changed. So I implemented following method in basepage. ... public void refreshNavigation() { this.navigation.replaceWith(AuthenticatedWebSession.get().getNavi()); AjaxRequestTarget.get().addComponent(this.navigation); } ... So, your Application object will act as a factory of components? I wouldn't follow that approach myself. At most the application would contain the data for the navigation and then the navigation component will fetch that data and rebuild itself. Now all I have to do is call this method for each active page to refresh navigation (or am I wrong?). Just one question? How would a remote page know that it has to reload itself? Do you plan to do that next time user get backs to the server with an AJAX request? If so, then you don't need anything else (I guess.) But if you want this to happen even if the user do not interact with the page. Then either you need a timer or use reverse AJAX. Can you tell me a bit more about reverse ajax? Just google for reverse AJAX, comet, server push, etc and you will have enough to read... Regards, Ernesto - 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: Iterate over Pages in Pagemap
It all depends on how often your navigation will change? Anyway the timer could only check for a boolean (navigationChanged) and only in case you have changes do something as heavy as repainting a component... No, I'm not planning to visit London any time soon : for a start I'll need to ask for a visa... and besides that I'm a family man and I have to take care of my wife and children during weekends:-) Cheers, Ernesto Tue, Nov 10, 2009 at 12:00 PM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: I agree that i should be carefully. But, back to the timer, let's assume I have 16 versions of one page in pagemap and each of 16 versions has a timer. Then there are 16 timers polling information from server, well if there are only 16 versions of one page, the traffic is low, but if the page count increase I have much unneeded traffic. You know I mean? I will look at push but I hold timer in mind. Btw, do you come to London on 21.11 (Jweekend)? Greets Chris -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 10. November 2009 11:44 An: users@wicket.apache.org Betreff: Re: Iterate over Pages in Pagemap I haven't used wicketstuff-push myself so I can't be of much help there. I once had to implement some push functionality and I used DWR in combination with Wicket. Going the reverse AJAX can complicate things a lot (or so I believe). Thus, think carefully if what you want to achieve cannot be accomplished using other means. e.g. an AJAX timer that polls the server from time to time and if new navigation is available updates what you need to update (maybe asking the user if they want to do so;-). Regards, Ernesto On Tue, Nov 10, 2009 at 10:25 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: So, your Application object will act as a factory of components? I wouldn't follow that approach myself. At most the application would contain the data for the navigation and then the navigation component will fetch that data and rebuild itself. Well, no. The session holds the navigation and triggers a method on it, so the navigation rebuilds itself. I need to hold it in session cause the available navigationentries depend on user roles. But your right with reverse ajax, I think I need it. Wicket is so Swing, so I totally forgot I'm working with a webapp :) I will read more about reverse ajax. Btw, cant find any wicketstuff-push svn or project description. Greets Chris -Ursprüngliche Nachricht- Von: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Gesendet: Dienstag, 10. November 2009 09:54 An: users@wicket.apache.org Betreff: Re: Iterate over Pages in Pagemap Hi, On Tue, Nov 10, 2009 at 9:36 AM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Well, i don't want a timer in the page. This causes unneeded checks. That's why I thought of the simplest solution. The basepage gets its navigation from session (which gets rebuild upon changes to stay up2date). Now I need a way to notify the page that navigation changed. So I implemented following method in basepage. ... public void refreshNavigation() { this.navigation.replaceWith(AuthenticatedWebSession.get().getNavi()); AjaxRequestTarget.get().addComponent(this.navigation); } ... So, your Application object will act as a factory of components? I wouldn't follow that approach myself. At most the application would contain the data for the navigation and then the navigation component will fetch that data and rebuild itself. Now all I have to do is call this method for each active page to refresh navigation (or am I wrong?). Just one question? How would a remote page know that it has to reload itself? Do you plan to do that next time user get backs to the server with an AJAX request? If so, then you don't need anything else (I guess.) But if you want this to happen even if the user do not interact with the page. Then either you need a timer or use reverse AJAX. Can you tell me a bit more about reverse ajax? Just google for reverse AJAX, comet, server push, etc and you will have enough to read... Regards, Ernesto - 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: Getting the Choose Option on page reload
Thank you for the responses. theDropdownComponent.nullValid=Choose one worked. Regards, Vinay Karmarkar -Original Message- From: Wilhelmsen Tor Iver [mailto:toriv...@arrive.no] Sent: Monday, November 09, 2009 6:37 PM To: users@wicket.apache.org Subject: Re: Getting the Choose Option on page reload I have 2 drop-downs and a search button my page. When the page is loaded for the first time, the first option in both the drop-downs is Choose Option. Now if I select some value and click Search, the page is rendered again and the Choose Option is gone forever. But I want it back. How do I go this? It is a consequence of disabling null values; you need to tell the dropdown to accept null values which is what Choose Option represents: theDropdownComponent.setNullValid(true); You will also want to override the display value property in the .properties file: theDropdownComponent.null_valid=Not set - Tor Iver - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org Please do not print this email unless it is absolutely necessary. The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Force page reload/re-render
Hi Pedro, I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. setResponsePage(getPage().getClass()) only works for stateless pages and on most of my pages, I pass params via the constructor. The javascript option will be a last resort, but it seems to be not the most elegant solution. Rgds, On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com wrote: if(userSetWasChanged){ target.appendJavascript(window.location.reload()); or setResponsePage(getPage()); or setResponsePage(getPage().getClass()); } On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen pieter.claas...@gmail.com wrote: I have a link on a panel that is included in many pages. When the user clicks on the link, I change something in the user settings that will affect what gets displayed on the page. However, for that to work, I need to reload the page after the user clicked on the link as by default the other components that now need to be checked for conditional visibility don't re-render (why not?). setResponsePage() requires me to pass into the panel a target page and this becomes complex when you have a mix of statefull and stateless pages as targets (and it just doesn't feel right). I am sure there must be an easier way to just re-render a page? Any tips? Thanks, pieter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pedro Henrique Oliveira dos Santos -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Force page reload/re-render
Isn't AJAX refresh an option to consider here? For instance, defining some contexts which need to be re-rendered (e.g. marking them with an interface) and them having and IVisitor that collects all those contexts and add them to the AjaxRequestTarget? Best, Ernesto On Tue, Nov 10, 2009 at 8:19 AM, pieter claassen pieter.claas...@gmail.comwrote: I have a link on a panel that is included in many pages. When the user clicks on the link, I change something in the user settings that will affect what gets displayed on the page. However, for that to work, I need to reload the page after the user clicked on the link as by default the other components that now need to be checked for conditional visibility don't re-render (why not?). setResponsePage() requires me to pass into the panel a target page and this becomes complex when you have a mix of statefull and stateless pages as targets (and it just doesn't feel right). I am sure there must be an easier way to just re-render a page? Any tips? Thanks, pieter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Force page reload/re-render
Both of the suggestions I think requires me to modify the logic of the controls (either to keep track of which ones need to be updated or by placing the rendering logic in onBeforeRender()). I think this is a lot of work for something relative straight forward and also any changes to permission structures and I have to modify controls. Is there no way that I can mark a page obtained via getPage() as requiring re-rendering? I tried getPage().dirty() before the setResponsePage() but that didn't do anything. Thanks for the feedback though. P On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos pedros...@gmail.com wrote: I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. Where do you implement your control ( update logic )? Consider do it overriding Component.onBeforeRender method On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen pieter.claas...@gmail.com wrote: Hi Pedro, I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. setResponsePage(getPage().getClass()) only works for stateless pages and on most of my pages, I pass params via the constructor. The javascript option will be a last resort, but it seems to be not the most elegant solution. Rgds, On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com wrote: if(userSetWasChanged){ target.appendJavascript(window.location.reload()); or setResponsePage(getPage()); or setResponsePage(getPage().getClass()); } On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen pieter.claas...@gmail.com wrote: I have a link on a panel that is included in many pages. When the user clicks on the link, I change something in the user settings that will affect what gets displayed on the page. However, for that to work, I need to reload the page after the user clicked on the link as by default the other components that now need to be checked for conditional visibility don't re-render (why not?). setResponsePage() requires me to pass into the panel a target page and this becomes complex when you have a mix of statefull and stateless pages as targets (and it just doesn't feel right). I am sure there must be an easier way to just re-render a page? Any tips? Thanks, pieter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pedro Henrique Oliveira dos Santos -- Pieter Claassen musmato.com -- Pedro Henrique Oliveira dos Santos -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Unnecessary method calls in IDataProvider?
done: https://issues.apache.org/jira/browse/WICKET-2568 regards, igor.vaynberg wrote: jira issue please -igor On Mon, Nov 9, 2009 at 5:53 AM, Michael Sparer michael.spa...@gmx.at wrote: Hey, I could have sworn that if a IDataProvider used in a DataView returns 0 as size, the iterator(int,int) method won't be called. But that assumption proved me wrong some minutes ago. Is there any specific reason why iterator gets called when the only possible result is an empty Iterator? Wouldn't it be more sensible to assume an empty iterator if size() returns 0 and leave out the method call? regards, - 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 - Michael Sparer http://techblog.molindo.at -- View this message in context: http://old.nabble.com/Unnecessary-method-calls-in-IDataProvider--tp26266771p26282885.html Sent from the Wicket - User 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: Force page reload/re-render
Hi Ernesto, To recap, I have a control panel visible on each and every page and in that control panel, you can select the appropriate role you want to use. Based on that role some menu items will be visible or not (example below is correct). I am sure this problem has been solved before :-0 as this is a very normal usecase for context sensitive navigation. It seems that there is no way to force the page to re-render using getPage()? Thanks for the feedback so far. I keep on coming up against this issue and have not found a reasonable solution to the problem. The javascript option seems to be best so far. Pieter On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Even if you re-render your page components that are not dynamic will not change their state: unless you create a new instance of the page, I guess. By this I mean. class MyPanel { public MyPanel(id) { PanelB panelB = new Panel(B); panelB.setVisible(getSomeCondition()); } } Even if condition getSomeCondition() change, and you re-render MyPanel, or the whole page, panelB will still be not visible. So, if you want something to be dynamic you have to program it to be dynamic. Best, Ernesto On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen pieter.claas...@gmail.com wrote: Both of the suggestions I think requires me to modify the logic of the controls (either to keep track of which ones need to be updated or by placing the rendering logic in onBeforeRender()). I think this is a lot of work for something relative straight forward and also any changes to permission structures and I have to modify controls. Is there no way that I can mark a page obtained via getPage() as requiring re-rendering? I tried getPage().dirty() before the setResponsePage() but that didn't do anything. Thanks for the feedback though. P On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos pedros...@gmail.com wrote: I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. Where do you implement your control ( update logic )? Consider do it overriding Component.onBeforeRender method On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen pieter.claas...@gmail.com wrote: Hi Pedro, I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. setResponsePage(getPage().getClass()) only works for stateless pages and on most of my pages, I pass params via the constructor. The javascript option will be a last resort, but it seems to be not the most elegant solution. Rgds, On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com wrote: if(userSetWasChanged){ target.appendJavascript(window.location.reload()); or setResponsePage(getPage()); or setResponsePage(getPage().getClass()); } On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen pieter.claas...@gmail.com wrote: I have a link on a panel that is included in many pages. When the user clicks on the link, I change something in the user settings that will affect what gets displayed on the page. However, for that to work, I need to reload the page after the user clicked on the link as by default the other components that now need to be checked for conditional visibility don't re-render (why not?). setResponsePage() requires me to pass into the panel a target page and this becomes complex when you have a mix of statefull and stateless pages as targets (and it just doesn't feel right). I am sure there must be an easier way to just re-render a page? Any tips? Thanks, pieter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pedro Henrique Oliveira dos Santos -- Pieter Claassen musmato.com -- Pedro Henrique Oliveira dos Santos -- Pieter Claassen musmato.com -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Force page reload/re-render
Hi Pieter Due to the Java-Nature of Wicket, things done in the constructor are only executed once for this instance. Since F5 only re-renders the instance, the expression setVisible(whatever()) is only executed once. The most dynamic implementation would be to override isVisible() for every component that changes its visibility dynamically or if that would lead to lots of code duplication, you could write a behaviour doing exactly that and add it to every component (or container) as needed. isVisible() is evaluated during each and every rendering phase, meaning upon every F5 reload as well. This is the way we do it for dynamic content. Matt pieter claassen wrote: Hi Ernesto, To recap, I have a control panel visible on each and every page and in that control panel, you can select the appropriate role you want to use. Based on that role some menu items will be visible or not (example below is correct). I am sure this problem has been solved before :-0 as this is a very normal usecase for context sensitive navigation. It seems that there is no way to force the page to re-render using getPage()? Thanks for the feedback so far. I keep on coming up against this issue and have not found a reasonable solution to the problem. The javascript option seems to be best so far. Pieter On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Even if you re-render your page components that are not dynamic will not change their state: unless you create a new instance of the page, I guess. By this I mean. class MyPanel { public MyPanel(id) { PanelB panelB = new Panel(B); panelB.setVisible(getSomeCondition()); } } Even if condition getSomeCondition() change, and you re-render MyPanel, or the whole page, panelB will still be not visible. So, if you want something to be dynamic you have to program it to be dynamic. Best, Ernesto On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen pieter.claas...@gmail.com wrote: Both of the suggestions I think requires me to modify the logic of the controls (either to keep track of which ones need to be updated or by placing the rendering logic in onBeforeRender()). I think this is a lot of work for something relative straight forward and also any changes to permission structures and I have to modify controls. Is there no way that I can mark a page obtained via getPage() as requiring re-rendering? I tried getPage().dirty() before the setResponsePage() but that didn't do anything. Thanks for the feedback though. P On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos pedros...@gmail.com wrote: I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. Where do you implement your control ( update logic )? Consider do it overriding Component.onBeforeRender method On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen pieter.claas...@gmail.com wrote: Hi Pedro, I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. setResponsePage(getPage().getClass()) only works for stateless pages and on most of my pages, I pass params via the constructor. The javascript option will be a last resort, but it seems to be not the most elegant solution. Rgds, On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com wrote: if(userSetWasChanged){ target.appendJavascript(window.location.reload()); or setResponsePage(getPage()); or setResponsePage(getPage().getClass()); } On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen pieter.claas...@gmail.com wrote: I have a link on a panel that is included in many pages. When the user clicks on the link, I change something in the user settings that will affect what gets displayed on the page. However, for that to work, I need to reload the page after the user clicked on the link as by default the other components that now need to be checked for conditional visibility don't re-render (why not?). setResponsePage() requires me to pass into the panel a target page and this becomes complex when you have a mix of statefull and stateless pages as targets (and it just doesn't feel right). I am sure there must be an easier way to just re-render a page? Any tips? Thanks, pieter smime.p7s Description: S/MIME Cryptographic Signature
Re: Force page reload/re-render
The page will be re-rendered... Implement your menu item componentes isVisible method to return true due your context Enviado de meu iPhone Em 10/11/2009, às 11:39, pieter claassen pieter.claas...@gmail.com escreveu: Hi Ernesto, To recap, I have a control panel visible on each and every page and in that control panel, you can select the appropriate role you want to use. Based on that role some menu items will be visible or not (example below is correct). I am sure this problem has been solved before :-0 as this is a very normal usecase for context sensitive navigation. It seems that there is no way to force the page to re-render using getPage()? Thanks for the feedback so far. I keep on coming up against this issue and have not found a reasonable solution to the problem. The javascript option seems to be best so far. Pieter On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Even if you re-render your page components that are not dynamic will not change their state: unless you create a new instance of the page, I guess. By this I mean. class MyPanel { public MyPanel(id) { PanelB panelB = new Panel(B); panelB.setVisible(getSomeCondition()); } } Even if condition getSomeCondition() change, and you re-render MyPanel, or the whole page, panelB will still be not visible. So, if you want something to be dynamic you have to program it to be dynamic. Best, Ernesto On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen pieter.claas...@gmail.com wrote: Both of the suggestions I think requires me to modify the logic of the controls (either to keep track of which ones need to be updated or by placing the rendering logic in onBeforeRender()). I think this is a lot of work for something relative straight forward and also any changes to permission structures and I have to modify controls. Is there no way that I can mark a page obtained via getPage() as requiring re-rendering? I tried getPage().dirty() before the setResponsePage() but that didn't do anything. Thanks for the feedback though. P On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos pedros...@gmail.com wrote: I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. Where do you implement your control ( update logic )? Consider do it overriding Component.onBeforeRender method On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen pieter.claas...@gmail.com wrote: Hi Pedro, I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. setResponsePage(getPage().getClass()) only works for stateless pages and on most of my pages, I pass params via the constructor. The javascript option will be a last resort, but it seems to be not the most elegant solution. Rgds, On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com wrote: if(userSetWasChanged){ target.appendJavascript(window.location.reload()); or setResponsePage(getPage()); or setResponsePage(getPage().getClass()); } On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen pieter.claas...@gmail.com wrote: I have a link on a panel that is included in many pages. When the user clicks on the link, I change something in the user settings that will affect what gets displayed on the page. However, for that to work, I need to reload the page after the user clicked on the link as by default the other components that now need to be checked for conditional visibility don't re-render (why not?). setResponsePage() requires me to pass into the panel a target page and this becomes complex when you have a mix of statefull and stateless pages as targets (and it just doesn't feel right). I am sure there must be an easier way to just re-render a page? Any tips? Thanks, pieter --- --- --- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pedro Henrique Oliveira dos Santos -- Pieter Claassen musmato.com -- Pedro Henrique Oliveira dos Santos -- Pieter Claassen musmato.com -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Force page reload/re-render
Hi Pieter, Components that have .setVisible(false) will never be evaluated again automatically. You need to call .setVisible(true) on all that apply. One way would be control visibility in the base panel by overriding onBeforeRender() to handle all the cases in one place. e.g. class ControlPanel extends Panel { protected void onBeforeRender () { Role role = getModelObject(); caseOnePanel.setVisible(false); caseTwoPanel.setVisible (false); if (role instanceof CaseOne) { caseOnePanel.setVisible (true); } else if (role instanceof CaseTwo) { caseTwoPanel.setVisible (true); } } } Or you could override .isVisible() in your sub panels to control when they are visible. I like the on before render way myself because there is no performance penalty if the visibility logic is complex (Component.isVisible() is called alot during the rendering phase). Regards, Mike To recap, I have a control panel visible on each and every page and in that control panel, you can select the appropriate role you want to use. Based on that role some menu items will be visible or not (example below is correct). I am sure this problem has been solved before :-0 as this is a very normal usecase for context sensitive navigation. It seems that there is no way to force the page to re-render using getPage()? Thanks for the feedback so far. I keep on coming up against this issue and have not found a reasonable solution to the problem. The javascript option seems to be best so far. Pieter On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Even if you re-render your page components that are not dynamic will not change their state: unless you create a new instance of the page, I guess. By this I mean. class MyPanel { public MyPanel(id) { PanelB panelB = new Panel(B); panelB.setVisible(getSomeCondition()); } } Even if condition getSomeCondition() change, and you re-render MyPanel, or the whole page, panelB will still be not visible. So, if you want something to be dynamic you have to program it to be dynamic. Best, Ernesto On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen pieter.claas...@gmail.com wrote: Both of the suggestions I think requires me to modify the logic of the controls (either to keep track of which ones need to be updated or by placing the rendering logic in onBeforeRender()). I think this is a lot of work for something relative straight forward and also any changes to permission structures and I have to modify controls. Is there no way that I can mark a page obtained via getPage() as requiring re-rendering? I tried getPage().dirty() before the setResponsePage() but that didn't do anything. Thanks for the feedback though. P On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos pedros...@gmail.com wrote: I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. Where do you implement your control ( update logic )? Consider do it overriding Component.onBeforeRender method On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen pieter.claas...@gmail.com wrote: Hi Pedro, I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. setResponsePage(getPage().getClass()) only works for stateless pages and on most of my pages, I pass params via the constructor. The javascript option will be a last resort, but it seems to be not the most elegant solution. Rgds, On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com wrote: if(userSetWasChanged){ target.appendJavascript(window.location.reload()); or setResponsePage(getPage()); or setResponsePage(getPage().getClass()); } On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen pieter.claas...@gmail.com wrote: I have a link on a panel that is included in many pages. When the user clicks on the link, I change something in the user settings that will affect what gets displayed on the page. However, for that to work, I need to reload the page after the user clicked on the link as by default the other components that now need to be checked for conditional visibility don't re-render (why not?). setResponsePage() requires me to pass into the panel a target page and this becomes complex when you have a mix of statefull and stateless pages as targets (and it just doesn't feel right). I am sure there must be an easier way to just re-render a page? Any tips? Thanks, pieter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pedro Henrique Oliveira dos Santos -- Pieter Claassen musmato.com -- Pedro Henrique Oliveira dos Santos -- Pieter Claassen musmato.com
Mapping an association with Models
Hi, I'm wondering if I'm doing things straight regarding this subject. I have an Entity A with PK properties a1, a2. There is another entity B with PK properties b1, b2. Between them there is an association class AB (with PK a1, a2, b1, b2). Let's suppose I have a Form for editing A objects, in which the user can choose many B values by means of a CheckBoxMultipleChoice cbmc, with model object and choice list of type ListB. In the form's submit method, I create as many as necessary AB objects, combining selected B's id's with current A's id. class APanel extends Panel(){ private ListB selectedBs; public APanel(){ }
Re: Mapping an association with Models
Hi, Sorry, posted the previous one by error, this is what's missing in the code: class APanel extends Panel(){ private ListB selectedBs; public APanel(){ A a = getA(); ListB choices = getBChoices(); cbmc = new CheckBoxMultipleChoice(id, choices); cbmc.setModel(new PropertyModel(this, selectedBs)); Form f = new Form(form){ onSubmit(){ ListAB abs = a.getAB(); abs.removeAll(); for (B b : selectedBs){ AB ab = new AB(a, b); abs.add(ab); } // a contains properly initialized ab elements } } f.add(cbmc); } Question is, does 'selectedBs' get serialized in pageMaps ? If so, I suppose it would be better to store only selectedB's id's... Thanks, and sorry again for the double-posting inconvenience ! Xavier
Re: Force page reload/re-render
Thanks for all the feedback. onBeforeRender() works like a charm. Pieter On Tue, Nov 10, 2009 at 2:51 PM, Michael O'Cleirigh michael.ocleir...@rivulet.ca wrote: Hi Pieter, Components that have .setVisible(false) will never be evaluated again automatically. You need to call .setVisible(true) on all that apply. One way would be control visibility in the base panel by overriding onBeforeRender() to handle all the cases in one place. e.g. class ControlPanel extends Panel { protected void onBeforeRender () { Role role = getModelObject(); caseOnePanel.setVisible(false); caseTwoPanel.setVisible (false); if (role instanceof CaseOne) { caseOnePanel.setVisible (true); } else if (role instanceof CaseTwo) { caseTwoPanel.setVisible (true); } } } Or you could override .isVisible() in your sub panels to control when they are visible. I like the on before render way myself because there is no performance penalty if the visibility logic is complex (Component.isVisible() is called alot during the rendering phase). Regards, Mike To recap, I have a control panel visible on each and every page and in that control panel, you can select the appropriate role you want to use. Based on that role some menu items will be visible or not (example below is correct). I am sure this problem has been solved before :-0 as this is a very normal usecase for context sensitive navigation. It seems that there is no way to force the page to re-render using getPage()? Thanks for the feedback so far. I keep on coming up against this issue and have not found a reasonable solution to the problem. The javascript option seems to be best so far. Pieter On Tue, Nov 10, 2009 at 1:41 PM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Even if you re-render your page components that are not dynamic will not change their state: unless you create a new instance of the page, I guess. By this I mean. class MyPanel { public MyPanel(id) { PanelB panelB = new Panel(B); panelB.setVisible(getSomeCondition()); } } Even if condition getSomeCondition() change, and you re-render MyPanel, or the whole page, panelB will still be not visible. So, if you want something to be dynamic you have to program it to be dynamic. Best, Ernesto On Tue, Nov 10, 2009 at 1:20 PM, pieter claassen pieter.claas...@gmail.com wrote: Both of the suggestions I think requires me to modify the logic of the controls (either to keep track of which ones need to be updated or by placing the rendering logic in onBeforeRender()). I think this is a lot of work for something relative straight forward and also any changes to permission structures and I have to modify controls. Is there no way that I can mark a page obtained via getPage() as requiring re-rendering? I tried getPage().dirty() before the setResponsePage() but that didn't do anything. Thanks for the feedback though. P On Tue, Nov 10, 2009 at 1:10 PM, Pedro Santos pedros...@gmail.com wrote: I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. Where do you implement your control ( update logic )? Consider do it overriding Component.onBeforeRender method On Tue, Nov 10, 2009 at 10:03 AM, pieter claassen pieter.claas...@gmail.com wrote: Hi Pedro, I tried setResponsePage(getPage()) but the problem is it does not re-render controls on the page. setResponsePage(getPage().getClass()) only works for stateless pages and on most of my pages, I pass params via the constructor. The javascript option will be a last resort, but it seems to be not the most elegant solution. Rgds, On Tue, Nov 10, 2009 at 11:45 AM, Pedro Santos pedros...@gmail.com wrote: if(userSetWasChanged){ target.appendJavascript(window.location.reload()); or setResponsePage(getPage()); or setResponsePage(getPage().getClass()); } On Tue, Nov 10, 2009 at 5:19 AM, pieter claassen pieter.claas...@gmail.com wrote: I have a link on a panel that is included in many pages. When the user clicks on the link, I change something in the user settings that will affect what gets displayed on the page. However, for that to work, I need to reload the page after the user clicked on the link as by default the other components that now need to be checked for conditional visibility don't re-render (why not?). setResponsePage() requires me to pass into the panel a target page and this becomes complex when you have a mix of statefull and stateless pages as targets (and it just doesn't feel right). I am sure there must be an easier way to just re-render a page? Any tips? Thanks, pieter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org --
Re: Inheritance strips XML header
Reported WICKET-2569: https://issues.apache.org/jira/browse/WICKET-2569 . I worked around this issue by using a label to render the xml header. On Mon, Nov 9, 2009 at 5:40 PM, Neil Curzon neil.cur...@gmail.com wrote: Hi all, It seems that Wicket 1.4.3 is stripping the XML header when using page inheritance for layout. My super page defines the layout and has a ?xml header at the top. If a sub page has content, when wicket renders it, the ?xml header will be excluded. Strangely, for subclasses with no content (no html file), the ?xml header is preserved. Am I doing something wrong? If not, I have a sample application that shows this issue and would be happy to file a bug. We're actually using 1.3.7, but if this will only be fixed on 1.4, that would be a great excuse to upgrade :) Thanks, Neil
Re: Iterate over Pages in Pagemap
are you looking to build a breadcrumb-like system? -igor On Mon, Nov 9, 2009 at 11:54 PM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Hi all, how to iterate over latest version of all pages in pagemap? All my Pages have the ability to reload the navigation, but to accomplish this, I need to tell the page to reload the navigation. So my first idea was to iterate over latest version of all pages in pagemap and call the needed method on it. But Session#getPageMaps returns a list of IPageMap which doesn't offer an iterator. How can a accomplish this? Greets Chris - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Transaction error dont reach onRuntimeException(Page page, RuntimeException e) method
Hi all, I am testing transactionability in a site which I am developing. I got to roll back the app in case of a Hibernate DataException, but I couldnt reach my custom request cycle method onRutimeException @Override public Page onRuntimeException(Page page, RuntimeException e) Why is this? The roll back is done in endRequestCycle, while I had instructed a new model to be shown in the original page in case of succeded. It shows the succeded page instead the error one. Thanks in advance -- Fernando Wermus. www.linkedin.com/in/fernandowermus
column in listview that is combination of two fields
I have a ListView with a requirement that I display one one the column as combination of two fields eg. my cnameID should be cname:id. Is there a way to get the model so that it is Label is combination of two fields or do I have to create a wrapper object for this purpose. ListView = new ListView(test, testList) { @Override protected void populateItem(ListItem item) { TestObject testObj = (TestObj) item.getModelObject(); item.add(new Label(Name, new PropertyModel(testObj, name))); //second column should be cname:id item.add(new Label(cnameID, new PropertyModel(testObj, cname))); public class TestObj{ public String name; public int id; public String cname; } thank you
Re: column in listview that is combination of two fields
I think you can use an AbstractReadOnlyModel like: getObject{ return testObj.getCname()+testObj.getId(); } On Tue, Nov 10, 2009 at 4:02 PM, Swarnim Ranjitkar swarn...@hotmail.comwrote: I have a ListView with a requirement that I display one one the column as combination of two fields eg. my cnameID should be cname:id. Is there a way to get the model so that it is Label is combination of two fields or do I have to create a wrapper object for this purpose. ListView = new ListView(test, testList) { @Override protected void populateItem(ListItem item) { TestObject testObj = (TestObj) item.getModelObject(); item.add(new Label(Name, new PropertyModel(testObj, name))); //second column should be cname:id item.add(new Label(cnameID, new PropertyModel(testObj, cname))); public class TestObj{ public String name; public int id; public String cname; } thank you -- Pedro Henrique Oliveira dos Santos
org.apachewicket.protocol.http.WebRequestCycleProcessor
From wicket source code WebRequestCycleProcessor has a lock on session. (Look at the source code below). From a profiler we can easily observe that %57 of the time is spent on this function especially on lock region. Is there any way to speed it up this source code ? /** * @see org.apache.wicket.request.IRequestCycleProcessor#resolve(org.apache.wicket.RequestCycle, * org.apache.wicket.request.RequestParameters) */ public IRequestTarget resolve(final RequestCycle requestCycle, final RequestParameters requestParameters) { IRequestCodingStrategy requestCodingStrategy = requestCycle.getProcessor() .getRequestCodingStrategy(); final String path = requestParameters.getPath(); IRequestTarget target = null; // See whether this request points to a bookmarkable page if (requestParameters.getBookmarkablePageClass() != null) { target = resolveBookmarkablePage(requestCycle, requestParameters); } // See whether this request points to a rendered page else if (requestParameters.getComponentPath() != null) { // marks whether or not we will be processing this request boolean processRequest = true; synchronized (requestCycle.getSession()) { // we need to check if this request has been flagged as // process-only-if-path-is-active and if so make sure this // condition is met if (requestParameters.isOnlyProcessIfPathActive()) { // this request has indeed been flagged as // process-only-if-path-is-active Session session = Session.get(); IPageMap pageMap = session.pageMapForName(requestParameters.getPageMapName(), false); if (pageMap == null) { // requested pagemap no longer exists - ignore this // request processRequest = false; } else if (pageMap instanceof AccessStackPageMap) { AccessStackPageMap accessStackPageMap = (AccessStackPageMap)pageMap; if (accessStackPageMap.getAccessStack().size() 0) { final Access access = (Access)accessStackPageMap.getAccessStack() .peek(); final int pageId = Integer .parseInt(Strings.firstPathComponent(requestParameters .getComponentPath(), Component.PATH_SEPARATOR)); if (pageId != access.getId()) { // the page is no longer the active page // - ignore this request processRequest = false; } else { final int version = requestParameters.getVersionNumber(); if (version != Page.LATEST_VERSION version != access.getVersion()) { // version is no longer the active version - // ignore this request processRequest = false; } } } } else { // TODO also this should work.. } } } if (processRequest) { try { target = resolveRenderedPage(requestCycle, requestParameters); } catch (IgnoreAjaxRequestException e) { target = EmptyAjaxRequestTarget.getInstance(); } } else { throw new PageExpiredException(Request cannot be processed); } } // See whether this request points to a shared resource else if (requestParameters.getResourceKey() != null) { target = resolveSharedResource(requestCycle, requestParameters); } // See whether this request points to the home page else if (Strings.isEmpty(path) || (/.equals(path))) { target = resolveHomePageTarget(requestCycle, requestParameters); } // NOTE we are doing the mount check as the last item, so that it will // only be executed when everything else fails. This enables URLs like // /foo/bar/?wicket:bookmarkablePage=my.Page to be resolved, where // is either a valid mount or a non-valid mount. I (Eelco) am not // absolutely sure this is a great way to go, but it seems to have been // established as the default way of doing things. If we ever want to // tighten the algorithm up, it should be combined by going back to // unmounted paths so that requests with Wicket parameters like // 'bookmarkablePage' are always created and resolved in the same // fashion. There is a test for this in UrlMountingTest. if (target == null) { // still null? check for a mount target = requestCodingStrategy.targetForRequest(requestParameters); if (target == null requestParameters.getComponentPath() != null) { // If the target is still null and there was a component path // then the Page could not be located in the session throw new PageExpiredException( Cannot find the rendered page in session [pagemap= + requestParameters.getPageMapName() + ,componentPath= + requestParameters.getComponentPath() + ,versionNumber= + requestParameters.getVersionNumber() + ]); } } else { // a target was found, but not by looking up a mount. check whether // this is allowed if (Application.get().getSecuritySettings().getEnforceMounts()
Newbie: add spring to wicket quickstart
Hello. I just created wicket quickstart project via maven and want add Spring DI to Wicket. So I added to WicketApplication: @Override protected void init() { super.init(); addComponentInstantiationListener(new SpringComponentInjector(this)); } In web.xml I added: context-param param-namecontextConfigLocation/param-name param-value/WEB-INF/applicationContext.xml/param-value /context-param filter filter-namewicket.jobmd/filter-name filter-classorg.apache.wicket.protocol.http.WicketFilter/filter-class init-param param-nameapplicationFactoryClassName/param-name param-valueorg.apache.wicket.spring.SpringWebApplicationFactory/param-value /init-param init-param param-nameapplicationBean/param-name param-valuewicketApplication/param-value /init-param /filter listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener In pom.xml: dependency groupIdorg.apache.wicket/groupId artifactIdwicket-spring/artifactId version${wicket.version}/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring/artifactId version2.5.6/version /dependency In applicationContext.xml: bean id=wicketApplication class=com.mihailenco.WicketApplication/bean Then when I build project in latest stable NetBeans I get this error in console: Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.579 sec FAILURE! testRenderMyPage(com.mihailenco.TestHomePage) Time elapsed: 1.435 sec ERROR! java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:70) at org.apache.wicket.spring.injection.annot.SpringComponentInjector.init(SpringComponentInjector.java:72) at com.mihailenco.WicketApplication.init(WicketApplication.java:24) at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:708) at org.apache.wicket.protocol.http.MockWebApplication.init(MockWebApplication.java:168) at org.apache.wicket.util.tester.BaseWicketTester.init(BaseWicketTester.java:217) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:317) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:300) at com.mihailenco.TestHomePage.setUp(TestHomePage.java:16) at junit.framework.TestCase.runBare(TestCase.java:128) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009) Did I missed something? Thank you.
Re: Newbie: add spring to wicket quickstart
You are getting this exception from a unittest. When you use WicketTester in combination with Spring injection, you have to tweak it a bit: You have to add the spring applicationContext to the mock ServletContext: Soe here a expect that you already did construct the spring applicationContext. Creating the WicketTester: tester = new WicketTester(createWebApplication()) { @Override public ServletContext newServletContext(String path) { MockServletContext servletContext = (MockServletContext) super.newServletContext(path); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext); return servletContext; } }; tester.getWicketSession().setLocale(getLocale()); new SpringComponentInjector(tester.getApplication(), applicationContext); testerHolder = tester; That should do it: 2009/11/10 Владимир Михайленко vladimir.web...@gmail.com Hello. I just created wicket quickstart project via maven and want add Spring DI to Wicket. So I added to WicketApplication: @Override protected void init() { super.init(); addComponentInstantiationListener(new SpringComponentInjector(this)); } In web.xml I added: context-param param-namecontextConfigLocation/param-name param-value/WEB-INF/applicationContext.xml/param-value /context-param filter filter-namewicket.jobmd/filter-name filter-classorg.apache.wicket.protocol.http.WicketFilter/filter-class init-param param-nameapplicationFactoryClassName/param-name param-valueorg.apache.wicket.spring.SpringWebApplicationFactory/param-value /init-param init-param param-nameapplicationBean/param-name param-valuewicketApplication/param-value /init-param /filter listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener In pom.xml: dependency groupIdorg.apache.wicket/groupId artifactIdwicket-spring/artifactId version${wicket.version}/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring/artifactId version2.5.6/version /dependency In applicationContext.xml: bean id=wicketApplication class=com.mihailenco.WicketApplication/bean Then when I build project in latest stable NetBeans I get this error in console: Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.579 sec FAILURE! testRenderMyPage(com.mihailenco.TestHomePage) Time elapsed: 1.435 sec ERROR! java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:70) at org.apache.wicket.spring.injection.annot.SpringComponentInjector.init(SpringComponentInjector.java:72) at com.mihailenco.WicketApplication.init(WicketApplication.java:24) at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:708) at org.apache.wicket.protocol.http.MockWebApplication.init(MockWebApplication.java:168) at org.apache.wicket.util.tester.BaseWicketTester.init(BaseWicketTester.java:217) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:317) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:300) at com.mihailenco.TestHomePage.setUp(TestHomePage.java:16) at junit.framework.TestCase.runBare(TestCase.java:128) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
Re: Autogenerating HTML files ...?
Thanks All. Igor - I'm a Wicket newbie. When I get more experience I'll see if I can do something along the lines you suggest. For now I just wished to know if it would be possible / sensible. Casper - Sorry I'm a Wicket newbie as well (but I do have experience with some other Web frameworks and will have a go sometime when I understand Wicket better). Frido - Unfortunately, I don't think that is what I am looking for - I'm not looking for the rendered page, but rather what the bare source page / component HTML would look like. Cheers, Ashley. -- Ashley Aitken Perth, Western Australia mrhatken at mac dot com Skype Name: MrHatken (GMT + 8 Hours!) - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Scala, dependency injection and wicket
On 08/10/2009, at 4:42 AM, Alex Rass wrote: And so far: ajax is a pain in the ass that requires explicit work even for a simple form verification (bad architecture there). Is this true? One of my attractions to Wicket was that, hopefully, AJAX was easy (or at least easier) than other frameworks. And this other problem with url formation. What is that problem exactly? Thanks, Ashley. -- Ashley Aitken Perth, Western Australia mrhatken at mac dot com Skype Name: MrHatken (GMT + 8 Hours!) - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Scala, dependency injection and wicket
On Tue, Nov 10, 2009 at 12:42 PM, Ashley Aitken mrhat...@mac.com wrote: On 08/10/2009, at 4:42 AM, Alex Rass wrote: And so far: ajax is a pain in the ass that requires explicit work even for a simple form verification (bad architecture there). Is this true? One of my attractions to Wicket was that, hopefully, AJAX was easy (or at least easier) than other frameworks. No - it's not true. AJAX is simpler in Wicket than I've seen in ANY other application framework. You just have to know how to use it. It's also very easy to do custom AJAX things in Wicket. -- Jeremy Thomerson http://www.wickettraining.com
Proxying SSL on Apache to HTTP on Jetty + Wicket
The situation here is: https http - Apache --- Jetty Using wicket in my WicketApplication I put private static final HttpsConfig HTTPS_CONFIG = new HttpsConfig(HTTP_PORT, HTTPS_PORT); @Override protected IRequestCycleProcessor newRequestCycleProcessor() { return new HttpsRequestCycleProcessor(HTTPS_CONFIG); } And in my LoginPage.java i have @RequireHttps When i try to run the system with this config i get a error because Wicket assumes the HTTPS control and try to change the URL (port and replace http to https) How i say to wicket to just change the protocol to HTTPS? And don't change the port? Thanks - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Newbie: add spring to wicket quickstart
Thank you, now it works. On Tue, Nov 10, 2009 at 8:29 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: You are getting this exception from a unittest. When you use WicketTester in combination with Spring injection, you have to tweak it a bit: You have to add the spring applicationContext to the mock ServletContext: Soe here a expect that you already did construct the spring applicationContext. Creating the WicketTester: tester = new WicketTester(createWebApplication()) { @Override public ServletContext newServletContext(String path) { MockServletContext servletContext = (MockServletContext) super.newServletContext(path); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext); return servletContext; } }; tester.getWicketSession().setLocale(getLocale()); new SpringComponentInjector(tester.getApplication(), applicationContext); testerHolder = tester; That should do it: 2009/11/10 Владимир Михайленко vladimir.web...@gmail.com Hello. I just created wicket quickstart project via maven and want add Spring DI to Wicket. So I added to WicketApplication: @Override protected void init() { super.init(); addComponentInstantiationListener(new SpringComponentInjector(this)); } In web.xml I added: context-param param-namecontextConfigLocation/param-name param-value/WEB-INF/applicationContext.xml/param-value /context-param filter filter-namewicket.jobmd/filter-name filter-classorg.apache.wicket.protocol.http.WicketFilter/filter-class init-param param-nameapplicationFactoryClassName/param-name param-valueorg.apache.wicket.spring.SpringWebApplicationFactory/param-value /init-param init-param param-nameapplicationBean/param-name param-valuewicketApplication/param-value /init-param /filter listener listener-classorg.springframework.web.context.ContextLoaderListener/listener-class /listener In pom.xml: dependency groupIdorg.apache.wicket/groupId artifactIdwicket-spring/artifactId version${wicket.version}/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring/artifactId version2.5.6/version /dependency In applicationContext.xml: bean id=wicketApplication class=com.mihailenco.WicketApplication/bean Then when I build project in latest stable NetBeans I get this error in console: Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.579 sec FAILURE! testRenderMyPage(com.mihailenco.TestHomePage) Time elapsed: 1.435 sec ERROR! java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:70) at org.apache.wicket.spring.injection.annot.SpringComponentInjector.init(SpringComponentInjector.java:72) at com.mihailenco.WicketApplication.init(WicketApplication.java:24) at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:708) at org.apache.wicket.protocol.http.MockWebApplication.init(MockWebApplication.java:168) at org.apache.wicket.util.tester.BaseWicketTester.init(BaseWicketTester.java:217) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:317) at org.apache.wicket.util.tester.WicketTester.init(WicketTester.java:300) at com.mihailenco.TestHomePage.setUp(TestHomePage.java:16) at junit.framework.TestCase.runBare(TestCase.java:128) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) at
Re: DataTable: Can a Cell Know of Its Row or Row Number?
Igor - Thanks for the help. I couldn't find a getParent() on the item's class that took a class as a parameter. However, I wrote this, and it worked: /** * Returns the ancestor (Wicket component hierarchy ancestor, not class hierarchy ancestor) * of the specified component that is an instance of the specified class or one of its subclasses. */ public static Component getAncestor(Component component, Class? extends Component ancestorClass) { Component targetClassAncestor = null; for (Component c = component.getParent(); c != null targetClassAncestor == null; ) { if (c.getClass().isAssignableFrom(ancestorClass)) { targetClassAncestor = c; } else { c = c.getParent(); } } return targetClassAncestor; } igor.vaynberg wrote: On Fri, Nov 6, 2009 at 5:29 PM, Keith Bennett keithrbenn...@gmail.com wrote: populateitem(item item) { int col=item.getindex(); int row=item.getparent(item.class).getindex(); } -igor -- View this message in context: http://old.nabble.com/DataTable%3A-Can-a-Cell-Know-of-Its-Row-or-Row-Number--tp26241521p26288831.html Sent from the Wicket - User 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: Transaction error dont reach onRuntimeException(Page page, RuntimeException e) method
where is your exception is thrown from? also, check that its not being wrapped in another exception such as a WicketRuntimeException. -igor On Tue, Nov 10, 2009 at 9:57 AM, Fernando Wermus fernando.wer...@gmail.com wrote: Hi all, I am testing transactionability in a site which I am developing. I got to roll back the app in case of a Hibernate DataException, but I couldnt reach my custom request cycle method onRutimeException @Override public Page onRuntimeException(Page page, RuntimeException e) Why is this? The roll back is done in endRequestCycle, while I had instructed a new model to be shown in the original page in case of succeded. It shows the succeded page instead the error one. Thanks in advance -- Fernando Wermus. www.linkedin.com/in/fernandowermus - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: org.apachewicket.protocol.http.WebRequestCycleProcessor
can you submit a quickstart that reproduces this? the lock on session only blocks concurrent requests from the browser, which is usually not a big deal because most users operate one window at a time. also we do not get the same results in our wicket-threadtest project. -igor On Tue, Nov 10, 2009 at 10:17 AM, Pamir Erdem pamir.er...@gmail.com wrote: From wicket source code WebRequestCycleProcessor has a lock on session. (Look at the source code below). From a profiler we can easily observe that %57 of the time is spent on this function especially on lock region. Is there any way to speed it up this source code ? /** * @see org.apache.wicket.request.IRequestCycleProcessor#resolve(org.apache.wicket.RequestCycle, * org.apache.wicket.request.RequestParameters) */ public IRequestTarget resolve(final RequestCycle requestCycle, final RequestParameters requestParameters) { IRequestCodingStrategy requestCodingStrategy = requestCycle.getProcessor() .getRequestCodingStrategy(); final String path = requestParameters.getPath(); IRequestTarget target = null; // See whether this request points to a bookmarkable page if (requestParameters.getBookmarkablePageClass() != null) { target = resolveBookmarkablePage(requestCycle, requestParameters); } // See whether this request points to a rendered page else if (requestParameters.getComponentPath() != null) { // marks whether or not we will be processing this request boolean processRequest = true; synchronized (requestCycle.getSession()) { // we need to check if this request has been flagged as // process-only-if-path-is-active and if so make sure this // condition is met if (requestParameters.isOnlyProcessIfPathActive()) { // this request has indeed been flagged as // process-only-if-path-is-active Session session = Session.get(); IPageMap pageMap = session.pageMapForName(requestParameters.getPageMapName(), false); if (pageMap == null) { // requested pagemap no longer exists - ignore this // request processRequest = false; } else if (pageMap instanceof AccessStackPageMap) { AccessStackPageMap accessStackPageMap = (AccessStackPageMap)pageMap; if (accessStackPageMap.getAccessStack().size() 0) { final Access access = (Access)accessStackPageMap.getAccessStack() .peek(); final int pageId = Integer .parseInt(Strings.firstPathComponent(requestParameters .getComponentPath(), Component.PATH_SEPARATOR)); if (pageId != access.getId()) { // the page is no longer the active page // - ignore this request processRequest = false; } else { final int version = requestParameters.getVersionNumber(); if (version != Page.LATEST_VERSION version != access.getVersion()) { // version is no longer the active version - // ignore this request processRequest = false; } } } } else { // TODO also this should work.. } } } if (processRequest) { try { target = resolveRenderedPage(requestCycle, requestParameters); } catch (IgnoreAjaxRequestException e) { target = EmptyAjaxRequestTarget.getInstance(); } } else { throw new PageExpiredException(Request cannot be processed); } } // See whether this request points to a shared resource else if (requestParameters.getResourceKey() != null) { target = resolveSharedResource(requestCycle, requestParameters); } // See whether this request points to the home page else if (Strings.isEmpty(path) || (/.equals(path))) { target = resolveHomePageTarget(requestCycle, requestParameters); } // NOTE we are doing the mount check as the last item, so that it will // only be executed when everything else fails. This enables URLs like // /foo/bar/?wicket:bookmarkablePage=my.Page to be resolved, where // is either a valid mount or a non-valid mount. I (Eelco) am not // absolutely sure this is a great way to go, but it seems to have been // established as the default way of doing things. If we ever want to // tighten the algorithm up, it should be combined by going back to // unmounted paths so that requests with Wicket parameters like // 'bookmarkablePage' are always created and resolved in the same // fashion. There is a test for this in UrlMountingTest. if (target == null) { // still null? check for a mount target = requestCodingStrategy.targetForRequest(requestParameters); if (target == null requestParameters.getComponentPath() != null) { // If the target is still null and there was a component path // then the Page could not be located in the session throw new PageExpiredException( Cannot find the rendered page in session [pagemap= +
editing objects, backed by LoadableDetachableModels
Hi, I can't imagine that I'm the only one with the following situation. I have a page which edits an 'Employee'. Since I use hibernate and spring I use the LDM togeather with the OpenSessionInView. This works great (==No more LazyLoadExceptions at all...) But The Employee has a propertie accounts, which is a collection of Account objects. I'm showing these objects using a Listview. Now I want to add an Ajax link ('Add new account), which adds a fresh new Account object. I add the containing form to the AjaxRequestTarget so the ListView refreshes. Unfortunately, this approach never works, since my Employee is always reloaded from the database each reques. (I even think the same problem shows up when you do the same without ajax..) What is the best approach to deal with this? -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be
Re: editing objects, backed by LoadableDetachableModels
Hi Pieter, I don't use Hibernate, but db4o. The principle however might help you. I inject my factory methods into my pages using Spring (but that is a minor detail) and when I make a change to a domain object, I always store the object first before reloading the page (or in this case, rendering the ajax changes). When the page reloads, it loads the modified object from the database. This is important to also ensure your domain objects are persisted otherwise, they might still hang around in wicket, but might not be stored in the db. So you need to do something like public void onClick(AjaxRequestTarget target){ employee. addAccount(new Account()); employeeFactory.store(employee); ... } Rgds, Pieter On Tue, Nov 10, 2009 at 9:00 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Hi, I can't imagine that I'm the only one with the following situation. I have a page which edits an 'Employee'. Since I use hibernate and spring I use the LDM togeather with the OpenSessionInView. This works great (==No more LazyLoadExceptions at all...) But The Employee has a propertie accounts, which is a collection of Account objects. I'm showing these objects using a Listview. Now I want to add an Ajax link ('Add new account), which adds a fresh new Account object. I add the containing form to the AjaxRequestTarget so the ListView refreshes. Unfortunately, this approach never works, since my Employee is always reloaded from the database each reques. (I even think the same problem shows up when you do the same without ajax..) What is the best approach to deal with this? -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: editing objects, backed by LoadableDetachableModels
Thanks for your reply. In some situations your solution might be sufficient, but in my situation I'm affraid not... I cannot commit an empty Account in the db due constraint reasons. And, I actually only want to save the Employee in the database when the user presses the ' Save' button, not when he is adding/ modifying some Accounts. (So, in other words, the user can always 'Cancel' his actions... On Tue, Nov 10, 2009 at 9:16 PM, pieter claassen pieter.claas...@gmail.comwrote: Hi Pieter, I don't use Hibernate, but db4o. The principle however might help you. I inject my factory methods into my pages using Spring (but that is a minor detail) and when I make a change to a domain object, I always store the object first before reloading the page (or in this case, rendering the ajax changes). When the page reloads, it loads the modified object from the database. This is important to also ensure your domain objects are persisted otherwise, they might still hang around in wicket, but might not be stored in the db. So you need to do something like public void onClick(AjaxRequestTarget target){ employee. addAccount(new Account()); employeeFactory.store(employee); ... } Rgds, Pieter On Tue, Nov 10, 2009 at 9:00 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Hi, I can't imagine that I'm the only one with the following situation. I have a page which edits an 'Employee'. Since I use hibernate and spring I use the LDM togeather with the OpenSessionInView. This works great (==No more LazyLoadExceptions at all...) But The Employee has a propertie accounts, which is a collection of Account objects. I'm showing these objects using a Listview. Now I want to add an Ajax link ('Add new account), which adds a fresh new Account object. I add the containing form to the AjaxRequestTarget so the ListView refreshes. Unfortunately, this approach never works, since my Employee is always reloaded from the database each reques. (I even think the same problem shows up when you do the same without ajax..) What is the best approach to deal with this? -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be
Re: editing objects, backed by LoadableDetachableModels
You can keep the transient account beans in an list on your LDM, and add then to your Employee property on every load... LDM{ List transientAccounts;// get serialized with LDM load(){ Employee e = service.search(id); e.add(transientAccounts); } } On Tue, Nov 10, 2009 at 6:31 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Thanks for your reply. In some situations your solution might be sufficient, but in my situation I'm affraid not... I cannot commit an empty Account in the db due constraint reasons. And, I actually only want to save the Employee in the database when the user presses the ' Save' button, not when he is adding/ modifying some Accounts. (So, in other words, the user can always 'Cancel' his actions... On Tue, Nov 10, 2009 at 9:16 PM, pieter claassen pieter.claas...@gmail.comwrote: Hi Pieter, I don't use Hibernate, but db4o. The principle however might help you. I inject my factory methods into my pages using Spring (but that is a minor detail) and when I make a change to a domain object, I always store the object first before reloading the page (or in this case, rendering the ajax changes). When the page reloads, it loads the modified object from the database. This is important to also ensure your domain objects are persisted otherwise, they might still hang around in wicket, but might not be stored in the db. So you need to do something like public void onClick(AjaxRequestTarget target){ employee. addAccount(new Account()); employeeFactory.store(employee); ... } Rgds, Pieter On Tue, Nov 10, 2009 at 9:00 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Hi, I can't imagine that I'm the only one with the following situation. I have a page which edits an 'Employee'. Since I use hibernate and spring I use the LDM togeather with the OpenSessionInView. This works great (==No more LazyLoadExceptions at all...) But The Employee has a propertie accounts, which is a collection of Account objects. I'm showing these objects using a Listview. Now I want to add an Ajax link ('Add new account), which adds a fresh new Account object. I add the containing form to the AjaxRequestTarget so the ListView refreshes. Unfortunately, this approach never works, since my Employee is always reloaded from the database each reques. (I even think the same problem shows up when you do the same without ajax..) What is the best approach to deal with this? -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- Pedro Henrique Oliveira dos Santos
Re: editing objects, backed by LoadableDetachableModels
This is indeed a solution, but I still think I'm doing something wrong. Even simple properties of the Employee (like name) are reloaded from the database for each Ajax request I do (so, I mean: when I change first the name of the Employee and I click on the 'add Account' link, my name-change is reverted) Isn't there a 'generic' approach for this? On Tue, Nov 10, 2009 at 9:38 PM, Pedro Santos pedros...@gmail.com wrote: You can keep the transient account beans in an list on your LDM, and add then to your Employee property on every load... LDM{ List transientAccounts;// get serialized with LDM load(){ Employee e = service.search(id); e.add(transientAccounts); } } On Tue, Nov 10, 2009 at 6:31 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Thanks for your reply. In some situations your solution might be sufficient, but in my situation I'm affraid not... I cannot commit an empty Account in the db due constraint reasons. And, I actually only want to save the Employee in the database when the user presses the ' Save' button, not when he is adding/ modifying some Accounts. (So, in other words, the user can always 'Cancel' his actions... On Tue, Nov 10, 2009 at 9:16 PM, pieter claassen pieter.claas...@gmail.comwrote: Hi Pieter, I don't use Hibernate, but db4o. The principle however might help you. I inject my factory methods into my pages using Spring (but that is a minor detail) and when I make a change to a domain object, I always store the object first before reloading the page (or in this case, rendering the ajax changes). When the page reloads, it loads the modified object from the database. This is important to also ensure your domain objects are persisted otherwise, they might still hang around in wicket, but might not be stored in the db. So you need to do something like public void onClick(AjaxRequestTarget target){ employee. addAccount(new Account()); employeeFactory.store(employee); ... } Rgds, Pieter On Tue, Nov 10, 2009 at 9:00 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Hi, I can't imagine that I'm the only one with the following situation. I have a page which edits an 'Employee'. Since I use hibernate and spring I use the LDM togeather with the OpenSessionInView. This works great (==No more LazyLoadExceptions at all...) But The Employee has a propertie accounts, which is a collection of Account objects. I'm showing these objects using a Listview. Now I want to add an Ajax link ('Add new account), which adds a fresh new Account object. I add the containing form to the AjaxRequestTarget so the ListView refreshes. Unfortunately, this approach never works, since my Employee is always reloaded from the database each reques. (I even think the same problem shows up when you do the same without ajax..) What is the best approach to deal with this? -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- Pedro Henrique Oliveira dos Santos -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be
Re: Iterate over Pages in Pagemap
Why not just store the data model for the navigation in the session and render the components based on this? Basically you just change the navigation model via CustomSession.get ().getNavigation() and the navigation, breadcrumbs etc. render themselves properly ... Am 10.11.2009 um 17:49 schrieb Igor Vaynberg: are you looking to build a breadcrumb-like system? -igor On Mon, Nov 9, 2009 at 11:54 PM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Hi all, how to iterate over latest version of all pages in pagemap? All my Pages have the ability to reload the navigation, but to accomplish this, I need to tell the page to reload the navigation. So my first idea was to iterate over latest version of all pages in pagemap and call the needed method on it. But Session#getPageMaps returns a list of IPageMap which doesn't offer an iterator. How can a accomplish this? Greets Chris - 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: editing objects, backed by LoadableDetachableModels
Hi Pieter, Ok, what I do in situations like this is to create a new transient, serializable object (not stored in the DB) and pass it between wicket pages as needed. With db4o, any java object can be stored at some point by calling factory.store(object). Not sure about hibernate. Imagine you need to configure an object using multiple screens in a wizzard. Then just create the object, pass it from page to page in the constructors and in the last page, store it in the db. Rgds, Pieter On Tue, Nov 10, 2009 at 9:31 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Thanks for your reply. In some situations your solution might be sufficient, but in my situation I'm affraid not... I cannot commit an empty Account in the db due constraint reasons. And, I actually only want to save the Employee in the database when the user presses the ' Save' button, not when he is adding/ modifying some Accounts. (So, in other words, the user can always 'Cancel' his actions... On Tue, Nov 10, 2009 at 9:16 PM, pieter claassen pieter.claas...@gmail.com wrote: Hi Pieter, I don't use Hibernate, but db4o. The principle however might help you. I inject my factory methods into my pages using Spring (but that is a minor detail) and when I make a change to a domain object, I always store the object first before reloading the page (or in this case, rendering the ajax changes). When the page reloads, it loads the modified object from the database. This is important to also ensure your domain objects are persisted otherwise, they might still hang around in wicket, but might not be stored in the db. So you need to do something like public void onClick(AjaxRequestTarget target){ employee. addAccount(new Account()); employeeFactory.store(employee); ... } Rgds, Pieter On Tue, Nov 10, 2009 at 9:00 PM, Pieter Degraeuwe pieter.degrae...@systemworks.be wrote: Hi, I can't imagine that I'm the only one with the following situation. I have a page which edits an 'Employee'. Since I use hibernate and spring I use the LDM togeather with the OpenSessionInView. This works great (==No more LazyLoadExceptions at all...) But The Employee has a propertie accounts, which is a collection of Account objects. I'm showing these objects using a Listview. Now I want to add an Ajax link ('Add new account), which adds a fresh new Account object. I add the containing form to the AjaxRequestTarget so the ListView refreshes. Unfortunately, this approach never works, since my Employee is always reloaded from the database each reques. (I even think the same problem shows up when you do the same without ajax..) What is the best approach to deal with this? -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Pieter Degraeuwe Systemworks bvba Belgiëlaan 61 9070 Destelbergen GSM: +32 (0)485/68.60.85 Email: pieter.degrae...@systemworks.be visit us at http://www.systemworks.be -- Pieter Claassen musmato.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Iterate over Pages in Pagemap
nah. the problem with storing navigation in session is that it will get out of sync when the user uses the backbutton. a proper way to construct breadcrumbs is to pass the previous crumb into the new page. the crumb should contain a name and a pagereference to its page. -igor On Tue, Nov 10, 2009 at 12:56 PM, Peter Ertl pe...@gmx.org wrote: Why not just store the data model for the navigation in the session and render the components based on this? Basically you just change the navigation model via CustomSession.get().getNavigation() and the navigation, breadcrumbs etc. render themselves properly ... Am 10.11.2009 um 17:49 schrieb Igor Vaynberg: are you looking to build a breadcrumb-like system? -igor On Mon, Nov 9, 2009 at 11:54 PM, Giambalvo, Christian christian.giamba...@excelsisnet.com wrote: Hi all, how to iterate over latest version of all pages in pagemap? All my Pages have the ability to reload the navigation, but to accomplish this, I need to tell the page to reload the navigation. So my first idea was to iterate over latest version of all pages in pagemap and call the needed method on it. But Session#getPageMaps returns a list of IPageMap which doesn't offer an iterator. How can a accomplish this? Greets Chris - 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
HTTP Status 400 - There are some problems in the request: invalid URLPatternSpec
Hellou everyone, I use StatelessForm on GlassFish Ent Server 2.1 and I have this prob. When I submit form with method POST and Action url: http://xyz.sk/mymount/wicket:interface/:0:form::IFormSubmitListener:: server send me back status code 400 (There are some problems in the request: invalid URLPatternSpec). When I deploy same app in jetty or tomcat everything works fine. But my production enviroment is GlassFish. I think that prob is in character : in URL, but i dont understand because i debug that all params are decoded thrue WicketURLEncoder.PATH_INSTANCE.encode(string). Do you have some ideas ? Thanks a lot. Dave
Re: org.apachewicket.protocol.http.WebRequestCycleProcessor
Hi There are parts in web which make ajax calls. In this situtation on request blocks the piece of code till it returns a value. Do you recommend anything about ajax calls in a web page? Thanks Pamir On Tue, Nov 10, 2009 at 9:28 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote: can you submit a quickstart that reproduces this? the lock on session only blocks concurrent requests from the browser, which is usually not a big deal because most users operate one window at a time. also we do not get the same results in our wicket-threadtest project. -igor On Tue, Nov 10, 2009 at 10:17 AM, Pamir Erdem pamir.er...@gmail.com wrote: From wicket source code WebRequestCycleProcessor has a lock on session. (Look at the source code below). From a profiler we can easily observe that %57 of the time is spent on this function especially on lock region. Is there any way to speed it up this source code ? /** * @see org.apache.wicket.request.IRequestCycleProcessor#resolve(org.apache.wicket.RequestCycle, * org.apache.wicket.request.RequestParameters) */ public IRequestTarget resolve(final RequestCycle requestCycle, final RequestParameters requestParameters) { IRequestCodingStrategy requestCodingStrategy = requestCycle.getProcessor() .getRequestCodingStrategy(); final String path = requestParameters.getPath(); IRequestTarget target = null; // See whether this request points to a bookmarkable page if (requestParameters.getBookmarkablePageClass() != null) { target = resolveBookmarkablePage(requestCycle, requestParameters); } // See whether this request points to a rendered page else if (requestParameters.getComponentPath() != null) { // marks whether or not we will be processing this request boolean processRequest = true; synchronized (requestCycle.getSession()) { // we need to check if this request has been flagged as // process-only-if-path-is-active and if so make sure this // condition is met if (requestParameters.isOnlyProcessIfPathActive()) { // this request has indeed been flagged as // process-only-if-path-is-active Session session = Session.get(); IPageMap pageMap = session.pageMapForName(requestParameters.getPageMapName(), false); if (pageMap == null) { // requested pagemap no longer exists - ignore this // request processRequest = false; } else if (pageMap instanceof AccessStackPageMap) { AccessStackPageMap accessStackPageMap = (AccessStackPageMap)pageMap; if (accessStackPageMap.getAccessStack().size() 0) { final Access access = (Access)accessStackPageMap.getAccessStack() .peek(); final int pageId = Integer .parseInt(Strings.firstPathComponent(requestParameters .getComponentPath(), Component.PATH_SEPARATOR)); if (pageId != access.getId()) { // the page is no longer the active page // - ignore this request processRequest = false; } else { final int version = requestParameters.getVersionNumber(); if (version != Page.LATEST_VERSION version != access.getVersion()) { // version is no longer the active version - // ignore this request processRequest = false; } } } } else { // TODO also this should work.. } } } if (processRequest) { try { target = resolveRenderedPage(requestCycle, requestParameters); } catch (IgnoreAjaxRequestException e) { target = EmptyAjaxRequestTarget.getInstance(); } } else { throw new PageExpiredException(Request cannot be processed); } } // See whether this request points to a shared resource else if (requestParameters.getResourceKey() != null) { target = resolveSharedResource(requestCycle, requestParameters); } // See whether this request points to the home page else if (Strings.isEmpty(path) || (/.equals(path))) { target = resolveHomePageTarget(requestCycle, requestParameters); } // NOTE we are doing the mount check as the last item, so that it will // only be executed when everything else fails. This enables URLs like // /foo/bar/?wicket:bookmarkablePage=my.Page to be resolved, where // is either a valid mount or a non-valid mount. I (Eelco) am not // absolutely sure this is a great way to go, but it seems to have been // established as the default way of doing things. If we ever want to // tighten the algorithm up, it should be combined by going back to // unmounted paths so that requests with Wicket parameters like // 'bookmarkablePage' are always created and resolved in the same // fashion. There is a test for this in UrlMountingTest. if (target == null) {
getPage question
In the attachment you'll see that the regions that intersect with each other indicates that the slowest method execution on stack trace. If you look at Count Delta on getPage method you will see that it equals to 37 which means thatgetPage is executed 37 times in a request. There are too many ajax calls in the web page. Is there anything which we can do to tune that screen ? -- Pamir Erdem - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: org.apachewicket.protocol.http.WebRequestCycleProcessor
Could you please send me a link that how i can achieve this over wicket ? On Wed, Nov 11, 2009 at 1:18 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: well, its either we lock on the page, or you have to make sure all your code is threadsafe. yes, this can be a problem for a lot of concurrent ajax requests, you just have to make sure your responses are fast. eg if you have a time-consuming operation do it in a background thread and make ajax calls poll instead of block. -igor On Tue, Nov 10, 2009 at 2:09 PM, Pamir Erdem pamir.er...@gmail.com wrote: Hi There are parts in web which make ajax calls. In this situtation on request blocks the piece of code till it returns a value. Do you recommend anything about ajax calls in a web page? Thanks Pamir On Tue, Nov 10, 2009 at 9:28 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote: can you submit a quickstart that reproduces this? the lock on session only blocks concurrent requests from the browser, which is usually not a big deal because most users operate one window at a time. also we do not get the same results in our wicket-threadtest project. -igor On Tue, Nov 10, 2009 at 10:17 AM, Pamir Erdem pamir.er...@gmail.com wrote: From wicket source code WebRequestCycleProcessor has a lock on session. (Look at the source code below). From a profiler we can easily observe that %57 of the time is spent on this function especially on lock region. Is there any way to speed it up this source code ? /** * @see org.apache.wicket.request.IRequestCycleProcessor#resolve(org.apache.wicket.RequestCycle, * org.apache.wicket.request.RequestParameters) */ public IRequestTarget resolve(final RequestCycle requestCycle, final RequestParameters requestParameters) { IRequestCodingStrategy requestCodingStrategy = requestCycle.getProcessor() .getRequestCodingStrategy(); final String path = requestParameters.getPath(); IRequestTarget target = null; // See whether this request points to a bookmarkable page if (requestParameters.getBookmarkablePageClass() != null) { target = resolveBookmarkablePage(requestCycle, requestParameters); } // See whether this request points to a rendered page else if (requestParameters.getComponentPath() != null) { // marks whether or not we will be processing this request boolean processRequest = true; synchronized (requestCycle.getSession()) { // we need to check if this request has been flagged as // process-only-if-path-is-active and if so make sure this // condition is met if (requestParameters.isOnlyProcessIfPathActive()) { // this request has indeed been flagged as // process-only-if-path-is-active Session session = Session.get(); IPageMap pageMap = session.pageMapForName(requestParameters.getPageMapName(), false); if (pageMap == null) { // requested pagemap no longer exists - ignore this // request processRequest = false; } else if (pageMap instanceof AccessStackPageMap) { AccessStackPageMap accessStackPageMap = (AccessStackPageMap)pageMap; if (accessStackPageMap.getAccessStack().size() 0) { final Access access = (Access)accessStackPageMap.getAccessStack() .peek(); final int pageId = Integer .parseInt(Strings.firstPathComponent(requestParameters .getComponentPath(), Component.PATH_SEPARATOR)); if (pageId != access.getId()) { // the page is no longer the active page // - ignore this request processRequest = false; } else { final int version = requestParameters.getVersionNumber(); if (version != Page.LATEST_VERSION version != access.getVersion()) { // version is no longer the active version - // ignore this request processRequest = false; } } } } else { // TODO also this should work.. } } } if (processRequest) { try { target = resolveRenderedPage(requestCycle, requestParameters); } catch (IgnoreAjaxRequestException e) { target = EmptyAjaxRequestTarget.getInstance(); } } else { throw new PageExpiredException(Request cannot be processed); } } // See whether this request points to a shared resource else if (requestParameters.getResourceKey() != null) { target = resolveSharedResource(requestCycle, requestParameters); } // See whether this request points to the home page else if (Strings.isEmpty(path) || (/.equals(path))) { target = resolveHomePageTarget(requestCycle, requestParameters); } //
Re: Proxying SSL on Apache to HTTP on Jetty + Wicket
The unique solution that i found is extends HttpsRequestCycleProcessor to change only the protocol. Any other ideia? Thanks All. 2009/11/10 Rangel Preis rangel...@gmail.com: The situation here is: https http - Apache --- Jetty Using wicket in my WicketApplication I put private static final HttpsConfig HTTPS_CONFIG = new HttpsConfig(HTTP_PORT, HTTPS_PORT); �...@override protected IRequestCycleProcessor newRequestCycleProcessor() { return new HttpsRequestCycleProcessor(HTTPS_CONFIG); } And in my LoginPage.java i have @RequireHttps When i try to run the system with this config i get a error because Wicket assumes the HTTPS control and try to change the URL (port and replace http to https) How i say to wicket to just change the protocol to HTTPS? And don't change the port? Thanks - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: getPage question
Again it's related with ajax calls. It coud solve this issue when implementing ajax polls. Thanks On Wed, Nov 11, 2009 at 1:18 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: your attachment never made it through. -igor On Tue, Nov 10, 2009 at 3:12 PM, Pamir Erdem pamir.er...@gmail.com wrote: In the attachment you'll see that the regions that intersect with each other indicates that the slowest method execution on stack trace. If you look at Count Delta on getPage method you will see that it equals to 37 which means thatgetPage is executed 37 times in a request. There are too many ajax calls in the web page. Is there anything which we can do to tune that screen ? -- Pamir Erdem - 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 -- Pamir Erdem
Re: getPage question
37 getpage() calls should be no big deal. even a 100. -igor On Tue, Nov 10, 2009 at 3:27 PM, Pamir Erdem pamir.er...@gmail.com wrote: Again it's related with ajax calls. It coud solve this issue when implementing ajax polls. Thanks On Wed, Nov 11, 2009 at 1:18 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: your attachment never made it through. -igor On Tue, Nov 10, 2009 at 3:12 PM, Pamir Erdem pamir.er...@gmail.com wrote: In the attachment you'll see that the regions that intersect with each other indicates that the slowest method execution on stack trace. If you look at Count Delta on getPage method you will see that it equals to 37 which means thatgetPage is executed 37 times in a request. There are too many ajax calls in the web page. Is there anything which we can do to tune that screen ? -- Pamir Erdem - 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 -- Pamir Erdem - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: org.apachewicket.protocol.http.WebRequestCycleProcessor
search this list, google it. this has been answered on this list multiple times. -igor On Tue, Nov 10, 2009 at 3:22 PM, Pamir Erdem pamir.er...@gmail.com wrote: Could you please send me a link that how i can achieve this over wicket ? On Wed, Nov 11, 2009 at 1:18 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: well, its either we lock on the page, or you have to make sure all your code is threadsafe. yes, this can be a problem for a lot of concurrent ajax requests, you just have to make sure your responses are fast. eg if you have a time-consuming operation do it in a background thread and make ajax calls poll instead of block. -igor On Tue, Nov 10, 2009 at 2:09 PM, Pamir Erdem pamir.er...@gmail.com wrote: Hi There are parts in web which make ajax calls. In this situtation on request blocks the piece of code till it returns a value. Do you recommend anything about ajax calls in a web page? Thanks Pamir On Tue, Nov 10, 2009 at 9:28 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote: can you submit a quickstart that reproduces this? the lock on session only blocks concurrent requests from the browser, which is usually not a big deal because most users operate one window at a time. also we do not get the same results in our wicket-threadtest project. -igor On Tue, Nov 10, 2009 at 10:17 AM, Pamir Erdem pamir.er...@gmail.com wrote: From wicket source code WebRequestCycleProcessor has a lock on session. (Look at the source code below). From a profiler we can easily observe that %57 of the time is spent on this function especially on lock region. Is there any way to speed it up this source code ? /** * @see org.apache.wicket.request.IRequestCycleProcessor#resolve(org.apache.wicket.RequestCycle, * org.apache.wicket.request.RequestParameters) */ public IRequestTarget resolve(final RequestCycle requestCycle, final RequestParameters requestParameters) { IRequestCodingStrategy requestCodingStrategy = requestCycle.getProcessor() .getRequestCodingStrategy(); final String path = requestParameters.getPath(); IRequestTarget target = null; // See whether this request points to a bookmarkable page if (requestParameters.getBookmarkablePageClass() != null) { target = resolveBookmarkablePage(requestCycle, requestParameters); } // See whether this request points to a rendered page else if (requestParameters.getComponentPath() != null) { // marks whether or not we will be processing this request boolean processRequest = true; synchronized (requestCycle.getSession()) { // we need to check if this request has been flagged as // process-only-if-path-is-active and if so make sure this // condition is met if (requestParameters.isOnlyProcessIfPathActive()) { // this request has indeed been flagged as // process-only-if-path-is-active Session session = Session.get(); IPageMap pageMap = session.pageMapForName(requestParameters.getPageMapName(), false); if (pageMap == null) { // requested pagemap no longer exists - ignore this // request processRequest = false; } else if (pageMap instanceof AccessStackPageMap) { AccessStackPageMap accessStackPageMap = (AccessStackPageMap)pageMap; if (accessStackPageMap.getAccessStack().size() 0) { final Access access = (Access)accessStackPageMap.getAccessStack() .peek(); final int pageId = Integer .parseInt(Strings.firstPathComponent(requestParameters .getComponentPath(), Component.PATH_SEPARATOR)); if (pageId != access.getId()) { // the page is no longer the active page // - ignore this request processRequest = false; } else { final int version = requestParameters.getVersionNumber(); if (version != Page.LATEST_VERSION version != access.getVersion()) { // version is no longer the active version - // ignore this request processRequest = false; } } } } else { // TODO also this should work.. } } } if (processRequest) { try { target = resolveRenderedPage(requestCycle, requestParameters); } catch (IgnoreAjaxRequestException e) { target = EmptyAjaxRequestTarget.getInstance(); } } else { throw new PageExpiredException(Request cannot be processed); } } // See whether this request points to a shared resource else if (requestParameters.getResourceKey() != null) { target = resolveSharedResource(requestCycle, requestParameters); } // See whether this request points
Re: getPage question
your attachment never made it through. -igor On Tue, Nov 10, 2009 at 3:12 PM, Pamir Erdem pamir.er...@gmail.com wrote: In the attachment you'll see that the regions that intersect with each other indicates that the slowest method execution on stack trace. If you look at Count Delta on getPage method you will see that it equals to 37 which means thatgetPage is executed 37 times in a request. There are too many ajax calls in the web page. Is there anything which we can do to tune that screen ? -- Pamir Erdem - 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: org.apachewicket.protocol.http.WebRequestCycleProcessor
well, its either we lock on the page, or you have to make sure all your code is threadsafe. yes, this can be a problem for a lot of concurrent ajax requests, you just have to make sure your responses are fast. eg if you have a time-consuming operation do it in a background thread and make ajax calls poll instead of block. -igor On Tue, Nov 10, 2009 at 2:09 PM, Pamir Erdem pamir.er...@gmail.com wrote: Hi There are parts in web which make ajax calls. In this situtation on request blocks the piece of code till it returns a value. Do you recommend anything about ajax calls in a web page? Thanks Pamir On Tue, Nov 10, 2009 at 9:28 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote: can you submit a quickstart that reproduces this? the lock on session only blocks concurrent requests from the browser, which is usually not a big deal because most users operate one window at a time. also we do not get the same results in our wicket-threadtest project. -igor On Tue, Nov 10, 2009 at 10:17 AM, Pamir Erdem pamir.er...@gmail.com wrote: From wicket source code WebRequestCycleProcessor has a lock on session. (Look at the source code below). From a profiler we can easily observe that %57 of the time is spent on this function especially on lock region. Is there any way to speed it up this source code ? /** * @see org.apache.wicket.request.IRequestCycleProcessor#resolve(org.apache.wicket.RequestCycle, * org.apache.wicket.request.RequestParameters) */ public IRequestTarget resolve(final RequestCycle requestCycle, final RequestParameters requestParameters) { IRequestCodingStrategy requestCodingStrategy = requestCycle.getProcessor() .getRequestCodingStrategy(); final String path = requestParameters.getPath(); IRequestTarget target = null; // See whether this request points to a bookmarkable page if (requestParameters.getBookmarkablePageClass() != null) { target = resolveBookmarkablePage(requestCycle, requestParameters); } // See whether this request points to a rendered page else if (requestParameters.getComponentPath() != null) { // marks whether or not we will be processing this request boolean processRequest = true; synchronized (requestCycle.getSession()) { // we need to check if this request has been flagged as // process-only-if-path-is-active and if so make sure this // condition is met if (requestParameters.isOnlyProcessIfPathActive()) { // this request has indeed been flagged as // process-only-if-path-is-active Session session = Session.get(); IPageMap pageMap = session.pageMapForName(requestParameters.getPageMapName(), false); if (pageMap == null) { // requested pagemap no longer exists - ignore this // request processRequest = false; } else if (pageMap instanceof AccessStackPageMap) { AccessStackPageMap accessStackPageMap = (AccessStackPageMap)pageMap; if (accessStackPageMap.getAccessStack().size() 0) { final Access access = (Access)accessStackPageMap.getAccessStack() .peek(); final int pageId = Integer .parseInt(Strings.firstPathComponent(requestParameters .getComponentPath(), Component.PATH_SEPARATOR)); if (pageId != access.getId()) { // the page is no longer the active page // - ignore this request processRequest = false; } else { final int version = requestParameters.getVersionNumber(); if (version != Page.LATEST_VERSION version != access.getVersion()) { // version is no longer the active version - // ignore this request processRequest = false; } } } } else { // TODO also this should work.. } } } if (processRequest) { try { target = resolveRenderedPage(requestCycle, requestParameters); } catch (IgnoreAjaxRequestException e) { target = EmptyAjaxRequestTarget.getInstance(); } } else { throw new PageExpiredException(Request cannot be processed); } } // See whether this request points to a shared resource else if (requestParameters.getResourceKey() != null) { target = resolveSharedResource(requestCycle, requestParameters); } // See whether this request points to the home page else if (Strings.isEmpty(path) || (/.equals(path))) { target = resolveHomePageTarget(requestCycle, requestParameters); } // NOTE we are doing the mount check as the last item, so that it will // only be executed when everything else fails. This enables URLs like // /foo/bar/?wicket:bookmarkablePage=my.Page to be resolved, where // is either a valid mount or a non-valid mount. I (Eelco) am not // absolutely sure this is a
Re: HTTP Status 400 - There are some problems in the request: invalid URLPatternSpec
there should be a way for you to relax your server's checks, that is a little crazy. -igor On Tue, Nov 10, 2009 at 2:02 PM, David Skuben david.sku...@gmail.com wrote: Hellou everyone, I use StatelessForm on GlassFish Ent Server 2.1 and I have this prob. When I submit form with method POST and Action url: http://xyz.sk/mymount/wicket:interface/:0:form::IFormSubmitListener:: server send me back status code 400 (There are some problems in the request: invalid URLPatternSpec). When I deploy same app in jetty or tomcat everything works fine. But my production enviroment is GlassFish. I think that prob is in character : in URL, but i dont understand because i debug that all params are decoded thrue WicketURLEncoder.PATH_INSTANCE.encode(string). Do you have some ideas ? Thanks a lot. Dave - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
another serialization question
One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - 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: another serialization question
But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - 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
correct way to call necessary javascript initialization when a component is added via ajax
Hi, I'm implementing a control which consists of an integer field and a slider where the slider comes from jquery UI. My question is that whenever the component is refreshed via ajax, you need to call the js initialization function. I've done this by adding a behaviour which determines the request target, if it's an AjaxRequestTarget it adds the init js to the target otherwise it outputs it in the header. Is this the correct way to do it? Is there a simpler way? Here is the code that I've implemented as of today public class NumberFieldWithSliderNumber extends FormComponentPanelNumber { private TextFieldNumber field; private String slider_id; public NumberFieldWithSlider(String id) { super(id); init(); } public NumberFieldWithSlider(String id, IModelNumber model) { super(id, model); init(); } private void init() { field = new TextField(field, getModel()); add(field); WebComponent c = new WebComponent(slider); c.setOutputMarkupId(true); slider_id = c.getMarkupId(); add(c); // Write out the javascript to initialize the slider add(new AbstractBehavior() { @Override public void renderHead(IHeaderResponse response) { IRequestTarget target = RequestCycle.get().getRequestTarget(); if (target instanceof AjaxRequestTarget) { // If the target is an ajax request then we need // to execute just the slider js. AjaxRequestTarget t = (AjaxRequestTarget) target; t.appendJavascript(init_slider_js()); } else { // Otherwise render the slider when the document is ready. response.renderJavascript(init_slider_when_doc_ready_js(), null); } } }); } private String init_slider_js() { return $('# + slider_id + ').slider({min: 0, max: 1, step: 0.1});; } private String init_slider_when_doc_ready_js() { return $(document).ready(function() { + init_slider_js() + });; } } Regards, Peter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
Are you designing these value objects from scratch? Do you have control over them? Then, why are you averse to making them serializable? If you have a valid reason to not make them serializable, then why not go with the DTO pattern and just figure out a way to copy the attributes back and forth between your value objects and your DTOs? On Tue, Nov 10, 2009 at 10:17 PM, Sam Barrow s...@sambarrow.com wrote: But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
I cannot make them serializable I don't have control over them. But even if I did I couldn't because the valueobject has a reference to an entity which cannot be serializable. The project also uses db4o which would make it much harder to use a serialized version. Is dtos the best/only way? It would be a very awkward design because I have to both deal with subclasses of valueobject and converting the objects back when calling the service layer --Original Message-- From: James Carman To: users@wicket.apache.org ReplyTo: users@wicket.apache.org Subject: Re: another serialization question Sent: Nov 10, 2009 11:39 PM Are you designing these value objects from scratch? Do you have control over them? Then, why are you averse to making them serializable? If you have a valid reason to not make them serializable, then why not go with the DTO pattern and just figure out a way to copy the attributes back and forth between your value objects and your DTOs? On Tue, Nov 10, 2009 at 10:17 PM, Sam Barrow s...@sambarrow.com wrote: But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: correct way to call necessary javascript initialization when a component is added via ajax
Yes - this looks fine. There are multiple ways of accomplishing it, but this one is fine. -- Jeremy Thomerson http://www.wickettraining.com On Tue, Nov 10, 2009 at 10:38 PM, Peter Ross p...@missioncriticalit.comwrote: Hi, I'm implementing a control which consists of an integer field and a slider where the slider comes from jquery UI. My question is that whenever the component is refreshed via ajax, you need to call the js initialization function. I've done this by adding a behaviour which determines the request target, if it's an AjaxRequestTarget it adds the init js to the target otherwise it outputs it in the header. Is this the correct way to do it? Is there a simpler way? Here is the code that I've implemented as of today public class NumberFieldWithSliderNumber extends FormComponentPanelNumber { private TextFieldNumber field; private String slider_id; public NumberFieldWithSlider(String id) { super(id); init(); } public NumberFieldWithSlider(String id, IModelNumber model) { super(id, model); init(); } private void init() { field = new TextField(field, getModel()); add(field); WebComponent c = new WebComponent(slider); c.setOutputMarkupId(true); slider_id = c.getMarkupId(); add(c); // Write out the javascript to initialize the slider add(new AbstractBehavior() { @Override public void renderHead(IHeaderResponse response) { IRequestTarget target = RequestCycle.get().getRequestTarget(); if (target instanceof AjaxRequestTarget) { // If the target is an ajax request then we need // to execute just the slider js. AjaxRequestTarget t = (AjaxRequestTarget) target; t.appendJavascript(init_slider_js()); } else { // Otherwise render the slider when the document is ready. response.renderJavascript(init_slider_when_doc_ready_js(), null); } } }); } private String init_slider_js() { return $('# + slider_id + ').slider({min: 0, max: 1, step: 0.1});; } private String init_slider_when_doc_ready_js() { return $(document).ready(function() { + init_slider_js() + });; } } Regards, Peter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: correct way to call necessary javascript initialization when a component is added via ajax
On Wed, Nov 11, 2009 at 3:48 PM, Jeremy Thomerson jer...@wickettraining.com wrote: On Tue, Nov 10, 2009 at 10:38 PM, Peter Ross p...@missioncriticalit.comwrote: Hi, I'm implementing a control which consists of an integer field and a slider where the slider comes from jquery UI. My question is that whenever the component is refreshed via ajax, you need to call the js initialization function. I've done this by adding a behaviour which determines the request target, if it's an AjaxRequestTarget it adds the init js to the target otherwise it outputs it in the header. Is this the correct way to do it? Is there a simpler way? Yes - this looks fine. There are multiple ways of accomplishing it, but this one is fine. Could you elaborate on what some of the other ways are? Just enough key words so that I can do the google search would be fine :) Peter - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
Can you go through the entity to get to these objects? Meaning, can you set up and LDM to get the root entity object and then traverse to get to the value object you're interested in? If so, then you can try to come up with some property path to get you there and use that to refer to the specific value object you're wanting to edit/view. On Tue, Nov 10, 2009 at 11:46 PM, Sam Barrow s...@sambarrow.com wrote: I cannot make them serializable I don't have control over them. But even if I did I couldn't because the valueobject has a reference to an entity which cannot be serializable. The project also uses db4o which would make it much harder to use a serialized version. Is dtos the best/only way? It would be a very awkward design because I have to both deal with subclasses of valueobject and converting the objects back when calling the service layer --Original Message-- From: James Carman To: users@wicket.apache.org ReplyTo: users@wicket.apache.org Subject: Re: another serialization question Sent: Nov 10, 2009 11:39 PM Are you designing these value objects from scratch? Do you have control over them? Then, why are you averse to making them serializable? If you have a valid reason to not make them serializable, then why not go with the DTO pattern and just figure out a way to copy the attributes back and forth between your value objects and your DTOs? On Tue, Nov 10, 2009 at 10:17 PM, Sam Barrow s...@sambarrow.com wrote: But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Wicket and JQuery
On Wed, Oct 28, 2009 at 5:08 PM, Jason Novotny wrote: Martin Makundi wrote: ... and expect trouble with ajaxifying jquery plugins that skin html components. They will not work properly if you replace your components via ajax - or at least you might have to work hard on it. Bingo!! I've been hitting this wall, and pulling my hair out-- in fact I may ditch jQuery for this very reason since I can't find a suitable workaround :-( Here is the solution I used, I just emailed the list to ask if this is the correct approach: The following is some code which has an integer field with an associated slider The AbstractBehavior is the bit which determines if we are in an ajax request or not and adds the init js code in the correct place to make sure it's called. private void init() { field = new TextField(field, getModel()); add(field); WebComponent c = new WebComponent(slider); c.setOutputMarkupId(true); slider_id = c.getMarkupId(); add(c); // Write out the javascript to initialize the slider add(new AbstractBehavior() { @Override public void renderHead(IHeaderResponse response) { IRequestTarget target = RequestCycle.get().getRequestTarget(); if (target instanceof AjaxRequestTarget) { // If the target is an ajax request then we need // to execute just the slider js. AjaxRequestTarget t = (AjaxRequestTarget) target; t.appendJavascript(init_slider_js()); } else { // Otherwise render the slider when the document is ready. response.renderJavascript(init_slider_when_doc_ready_js(), null); } } }); } private String init_slider_js() { return $('# + slider_id + ').slider({min: 0, max: 1, step: 0.1});; } private String init_slider_when_doc_ready_js() { return $(document).ready(function() { + init_slider_js() + });; } - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
The value objects are not simple attributes of an entity. Let me explain what they do (a little simplified but the fundamentals are there). We have a research module that performs pricing research. ResearchItem CellPhoneResearchItem IPodResearchItem LaptopResearchItem Etc Since the identity of these research items is defined solely by their attributes they are implemented as value objects. I know this is different from your everyday value object (eg Address) Does this sound like maybe a problem that should be addressed in the domain model? Value objects were chosen since it makes it much easier in many other areas to just create a new research item, rather than call repositories to load old ones (impossible in some places). No point in loading something you know all the attributes of. The only way to get them reliably is to call ResearchItemGenerationService.generateResearchItems() -Original Message- From: James Carman jcar...@carmanconsulting.com Date: Wed, 11 Nov 2009 00:10:15 To: users@wicket.apache.org Subject: Re: another serialization question Can you go through the entity to get to these objects? Meaning, can you set up and LDM to get the root entity object and then traverse to get to the value object you're interested in? If so, then you can try to come up with some property path to get you there and use that to refer to the specific value object you're wanting to edit/view. On Tue, Nov 10, 2009 at 11:46 PM, Sam Barrow s...@sambarrow.com wrote: I cannot make them serializable I don't have control over them. But even if I did I couldn't because the valueobject has a reference to an entity which cannot be serializable. The project also uses db4o which would make it much harder to use a serialized version. Is dtos the best/only way? It would be a very awkward design because I have to both deal with subclasses of valueobject and converting the objects back when calling the service layer --Original Message-- From: James Carman To: users@wicket.apache.org ReplyTo: users@wicket.apache.org Subject: Re: another serialization question Sent: Nov 10, 2009 11:39 PM Are you designing these value objects from scratch? Do you have control over them? Then, why are you averse to making them serializable? If you have a valid reason to not make them serializable, then why not go with the DTO pattern and just figure out a way to copy the attributes back and forth between your value objects and your DTOs? On Tue, Nov 10, 2009 at 10:17 PM, Sam Barrow s...@sambarrow.com wrote: But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org