Re: AJAX update and file download on Wicket 1.5
Hi, the browser sends in a separate request to fetch the resource. You cannot show any feedback from there. You can add an error to the session, and let the web page poll with ajax requests for any problems. Regards Sven On 06/13/2014 03:35 AM, msalman wrote: Hi, Suppose there is some problem or exception in the file download. Let's say in the following method: protected IResourceStream getResourceStream() { return new AbstractResourceStreamWriter() { public void write(Response output) { WebResponse response = (WebResponse)output; byte[] buffer = new byte[256]; try { int read; while((read = is.read(buffer)) != -1) { response.write(buffer, 0, read); response.flush(); } response.close(); } catch (Exception e) { response.write(e.toString().getBytes()); response.close(); } } }; } And I want to show the error in the feedback panel for the page. How can I do that? The AjaxRequestTarget is not available here. I tried to do something like the following but it did not work: parentPage.getSession().error(error); WebApplication app = (WebApplication)getComponent().getApplication(); AjaxRequestTarget target = app.newAjaxRequestTarget(parentPage); target.add(parentPage.getFeedback()); I also tried saving the AjaxRequestTarget passed in the initiate method as a member variable of the class and use it later for posting the error. Well, for one it did not work. For second, I got the non serializable error for the target in the log. Thanks -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-update-and-file-download-on-Wicket-1-5-tp4095241p4666243.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: FileDownload hides the activity indicator
Hi, For some reason google mail always send your messages to my spam folder... Answers inline On Thu, Jun 12, 2014 at 7:27 PM, msalman mohammad_sal...@yahoo.com wrote: Ernesto, Well the change seems to work. I am using a button that shows an activity indicator with a veil for the request. So now that activity indicator and veil is shown while the file is generated. But they go away when the file is downloaded and the user can start clicking the button again. When the file download is completed the requests for previous clicks start again. I do not follow you. My advise was: 1- Generate file in a different thread. 2- Add and AJAX timer that checks for file generation completion. 3- Once file generation is completed. Use same AJAX request to unblock the UI and triigger download. BTW, I just realized that my code is actually based on your code on https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow Thanks for putting it up. Really helpful. That was the idea of creating the page. By the way, many others contributed to make this example better. May be you can update it so that it will take care of the problem that I have. That is showing the activity indicator during the complete file generation and download. There are many ways to do that in Wicket. Adding that to the page would just bloat the solution maybe just creating a different example illustration the approach mentioned above will be useful. Thanks again. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/FileDownload-hides-the-activity-indicator-tp4666181p4666241.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Regards - Ernesto Reinaldo Barreiro
How to get PageClass from BufferedResponseRequestHandler ? And how to link related requests?
Hi, How to get PageClass from BufferedResponseRequestHandler ? At little background: I'm sending processing metrics to Google Analytics, mentioning the PageClass (if available), used memory, and processing time. I'm using RequestCycleListener to do the crux of this. When Wicket's using IPageClassRequestHandler, things are fine. However, on the second request (after redirect to ?pageVersion), Wicket's using BufferedResponseRequestHandler, and I can't get the PageClass. A related question is how do I link related requests? Logically, I want this to happen: 1. User navigates to /contact 2. [http-thread-1] Begin RequestGroup - sets starting mem usage, page class, etc. 3. [http-thread-1] page processing 4. Wicket redirects to /contact?0 5. [http-thread-2] page rendered 6. [http-thread-2] End RequestGroup - calculates mem usage, etc. between #2..#6 I tried to use ThreadLocal but since thread is different, the information stored in step #2 is lost. Thank you. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-get-PageClass-from-BufferedResponseRequestHandler-And-how-to-link-related-requests-tp4666247.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to get PageClass from BufferedResponseRequestHandler ? And how to link related requests?
I also tried requestCycle.setMetaData() but the metadata is also gone for the next related request. :( -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-get-PageClass-from-BufferedResponseRequestHandler-And-how-to-link-related-requests-tp4666247p4666248.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to get PageClass from BufferedResponseRequestHandler ? And how to link related requests?
Hi, BufferedResponseRequestHandler just serves BufferedWebResponse instances, it doesn't know which page has generated for the buffered response. We already had another case, where this information would be valuable, see my last comment on https://issues.apache.org/jira/browse/WICKET-5129 Regards Sven On 06/13/2014 10:18 AM, Hendy Irawan wrote: Hi, How to get PageClass from BufferedResponseRequestHandler ? At little background: I'm sending processing metrics to Google Analytics, mentioning the PageClass (if available), used memory, and processing time. I'm using RequestCycleListener to do the crux of this. When Wicket's using IPageClassRequestHandler, things are fine. However, on the second request (after redirect to ?pageVersion), Wicket's using BufferedResponseRequestHandler, and I can't get the PageClass. A related question is how do I link related requests? Logically, I want this to happen: 1. User navigates to /contact 2. [http-thread-1] Begin RequestGroup - sets starting mem usage, page class, etc. 3. [http-thread-1] page processing 4. Wicket redirects to /contact?0 5. [http-thread-2] page rendered 6. [http-thread-2] End RequestGroup - calculates mem usage, etc. between #2..#6 I tried to use ThreadLocal but since thread is different, the information stored in step #2 is lost. Thank you. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-get-PageClass-from-BufferedResponseRequestHandler-And-how-to-link-related-requests-tp4666247.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Dataview help
Hi, On Mon, Jun 9, 2014 at 7:25 PM, kumar ramanathan kumarramana...@gmail.com wrote: Hi Paul, Thanks So much i have succesfully displayed the data in table using repeating view.The code is shown below. HelloWorldApplication.java package com.lnn.app; import org.apache.wicket.Page; import org.apache.wicket.protocol.http.WebApplication; import com.lnn.page.HelloWorld; public class HelloWorldApplication extends WebApplication { @Override public Class? extends Page getHomePage() { // TODO Auto-generated method stub return HelloWorld.class; } } HelloWorld.java package com.lnn.page; import java.util.ArrayList; import java.util.List; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.repeater.data.DataView; import java.io.Serializable; import java.util.ArrayList; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.Link; import org.apache.wicket.markup.html.navigation.paging.PagingNavigator; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.RepeatingView; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; public class HelloWorld extends WebPage { public HelloWorld(){ ListPersons list = new ArrayListPersons(); list.add(new Persons(sam,one)); list.add(new Persons(ram,two)); ListDataProviderPersons listDataProvider = new ListDataProviderPersons(list); DataViewPersons dataView = new DataViewPersons(rows, listDataProvider){ protected void populateItem(ItemPersons item){ Persons person = item.getModelObject(); RepeatingView repeatingView = new RepeatingView(dataRow); repeatingView.add(new Label(repeatingView.newChildId(), person.getName())); repeatingView.add(new Label( repeatingView.newChildId(),person.getId())); item.add(repeatingView); } }; add(dataView);}} HelloWorld.html ?xml version=1.0 encoding=UTF-8? html xmlns=http://www.w3.org/1999/xhtml; xmlns:wicket=http://wicket.apache.org; body table trthName/ththId/th /tr tr wicket:id=rows td wicket:id=dataRow/td /tr /table /body /html Persons.java package com.lnn.page; import java.io.Serializable; public class Persons implements Serializable{ String name; String id; public Persons(String name,String id){ this.name=name;this.id=id; } public void setId(String id){ this.id=id; } public String getId(){ return this.id; } public void setName(String name){ this.name=name; } public String getName(){ return this.name; } } O/P: Name Id sam one ram two In the above i have displayed the id a s lable. I want ot show it as link using the following change in the code of helloworld.java public class HelloWorld extends WebPage { public HelloWorld(){ ListPersons list = new ArrayListPersons(); list.add(new Persons(sam,one)); list.add(new Persons(ram,two)); ListDataProviderPersons listDataProvider = new ListDataProviderPersons(list); DataViewPersons dataView = new DataViewPersons(rows, listDataProvider){ protected void populateItem(ItemPersons item){ Persons person = item.getModelObject(); RepeatingView repeatingView = new RepeatingView(dataRow); repeatingView.add(new Label(repeatingView.newChildId(), person.getName())); repeatingView.add(new Label( repeatingView.newChildId(),person.getId()){ Just use Link component instead of Label. repeatingView.add(new Link( repeatingView.newChildId()) { public void onClick() { setResponsePage(new Output(person.getId())); } }.setBody(Model.of(person.getId(; item.add(repeatingView); You can even optimize it by using BookmarkablePageLink and pass the person id as a page parameter. } }; add(dataView);}} no link/data in the Id column displayed. Please help.How toget the link over there. O/P: Name Id Sam Ram Thanks, Kumar On 6/9/14, Paul Bors [via Apache Wicket] ml-node+s1842946n4666157...@n4.nabble.com wrote: Have you tried one of the Repeaters from: http://www.wicket-library.com/wicket-examples/index.html Direct link: http://www.wicket-library.com/wicket-examples/repeater/ They are also explained in the Wicket Free Guide at: http://wicket.apache.org/guide/guide/single.html#repeaters Let us know if you have a more specific question. On Fri, Jun 6, 2014 at 9:29 AM, kumar ramanathan kumarramana...@gmail.com wrote: Hi Friends, I am new beginner of wicket and trying to implement the table as below using data view. name id
Re: How to get PageClass from BufferedResponseRequestHandler ? And how to link related requests?
Hi, Yes, ThreadLocal, request attribute and request cycle's metadata won't do it. You can store this data in the Session but you must be careful because you may have several requests (e.g. Ajax) in the same session simultaneously. Using the request parameters is also possible but then this data will be visible to your end users ... Yet another way (a bit more hidden) is to use a cookie but again you should be careful to not mix the data for two separate requests. You can also use the url from the second request (after the redirect) to extract which page would be responsible for it but this will add both CPU and memory to your end data. I think you can just ignore the requests that are handled by BufferedResponseRequestHandler. They are fast because they just write the buffered response (some markup in memory) to the http response. There is almost no processing here. Martin Grigorov Wicket Training and Consulting On Fri, Jun 13, 2014 at 10:51 AM, Hendy Irawan he...@soluvas.com wrote: I also tried requestCycle.setMetaData() but the metadata is also gone for the next related request. :( -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-get-PageClass-from-BufferedResponseRequestHandler-And-how-to-link-related-requests-tp4666247p4666248.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to get PageClass from BufferedResponseRequestHandler ? And how to link related requests?
Thank you Martin. Currently I went with this solution: https://github.com/soluvas/soluvas-web/blob/3c3cb8a923e06522ccee156725196a8ab15fba0b/site/src/main/java/org/soluvas/web/site/metrics/ThreadMetricsRequestCycleListener.java I'll follow your advice and just ignored it, then :) Hendy -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-get-PageClass-from-BufferedResponseRequestHandler-And-how-to-link-related-requests-tp4666247p4666252.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
ApacheCon Call for Papers closes soon (June 25)
Dear Wicket developers, As you may be aware, ApacheCon will be held this year in Budapest, on November 17-21. (See http://apachecon.eu for more info.) The Call For Papers for that conference is still open, but will be closing soon. We need you talk proposals, to represent Wicket at ApacheCon. We need all kinds of talks - deep technical talks, hands-on tutorials, introductions for beginners, or case studies about the awesome stuff you're doing with Apache Wicket. Please consider submitting a proposal, at http://events.linuxfoundation.org//events/apachecon-europe/program/cfp
Re: Dataview help
Hi Martin,I have used the link code as you have suggested as below and getting the error at setBody(Model.of(person.getId()))* The method setBody(Model) is undefined for the type new Link(){} *.Code used:repeatingView.add(new Link(repeatingView.newChildId()) { public void onClick() { setResponsePage(new Output()); } }.setBody(Model.of(person.getId(;item.add(repeatingView);So i have altered the code as below ,removed the .setbody part. But inoutput am unable to get the link in Id column ofoutput.code altered:repeatingView.add(new Link(repeatingView.newChildId()) { public void onClick() { setResponsePage(new Output()); } });item.add(repeatingView);O/p Got:Name IdSamRamNo values displayed in id column as above. Please help me. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dataview-help-tp4666151p4666255.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Dataview help
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/markup/html/link/AbstractLink.java#L124 Try harder ;-) I write the code in my mail client, so it may have errors. Use your IDE to fix them! Martin Grigorov Wicket Training and Consulting On Fri, Jun 13, 2014 at 4:59 PM, kumar ramanathan kumarramana...@gmail.com wrote: Hi Martin,I have used the link code as you have suggested as below and getting the error at setBody(Model.of(person.getId()))* The method setBody(Model) is undefined for the type new Link(){} *.Code used:repeatingView.add(new Link(repeatingView.newChildId()) { public void onClick() { setResponsePage(new Output()); } }.setBody(Model.of(person.getId(;item.add(repeatingView);So i have altered the code as below ,removed the .setbody part. But inoutput am unable to get the link in Id column ofoutput.code altered:repeatingView.add(new Link(repeatingView.newChildId()) { public void onClick() { setResponsePage(new Output()); } });item.add(repeatingView);O/p Got:Name IdSamRamNo values displayed in id column as above. Please help me. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dataview-help-tp4666151p4666255.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Ajax Form Submit via jquery plugin / javascript
Paul Bors wrote http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.html Ajax event behavior that submits a form via ajax when the event it is attached to, is invoked.” You’re attaching the submit event so who fires that? You are right, I missed that but I am still a little stumped on what to do. I am assuming the form gets submitted when calling jQuery(#selectionForm).submit() I was assuming this part add(new AjaxFormSubmitBehavior(this, onsubmit) { would be waiting for the submit of the form and then get executed. Have I understood correctly? What am I missing? Regards Vishal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-Form-Submit-via-jquery-plugin-javascript-tp4666170p4666257.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: FileDownload hides the activity indicator
Hi Ernesto, I have it like as following. @Override public void onSubmit(final AjaxRequestTarget target, Form? form) { // The veil and the activity indicator are already on when the code gets here String backupFileNameOnServer = null; try { backupFileNameOnServer = startBackup(parentPage); } catch (Exception e) { BackupTabPanel.logger.error(e); parentPage.getSession().error(e.getMessage()); target.add(parentPage.getFeedback()); } // setup for file download File sourceFile = new File(backupFileNameOnServer); String downloadFileName = backup_config_ + getServerName() + _ + getTime() + .tar; backupFileDownLoadBehaviour.initiate(sourceFile, downloadFileName, target); // after this the AjaxFileDownloadBehaviour#onResponse is called // then AjaxFileDownloadBehaviour#downloadFile (overridden in the local instance) is called // The veil and the activity indicator are gone by the time code hits AjaxFileDownloadBehaviour#onResponse. } I did not need to use another thread. Please let me know if you see any issues with this. Or a better way of doing this. Much appreciate your help. Thanks. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/FileDownload-hides-the-activity-indicator-tp4666181p4666259.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AJAX update and file download on Wicket 1.5
Thanks for your response. Can you please kindly provide an outline or a few lines of code to get me started. My particular concerns are: 1. How do I create an Ajax request and AjaxRequestTarget. Will this be another Ajaxbehaviour. Sorry I should have learned this by now but... 2. How and when do I stop this polling and end the original onSubmit call. Thanks. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-update-and-file-download-on-Wicket-1-5-tp4095241p4666260.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AJAX update and file download on Wicket 1.5
You can always redirect to an error page incase of exceptions / errors. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-update-and-file-download-on-Wicket-1-5-tp4095241p4666261.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AJAX update and file download on Wicket 1.5
Well, that is exactly what we are trying to avoid. An error page is a must fix bug. Thanks. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-update-and-file-download-on-Wicket-1-5-tp4095241p4666262.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org