Re: Best practice: JS/CSS library resource references
Hi Sebastien, Session overriding app defaults allows you to set a different theme for the session. Like a custom CSS for that session. I'm talking about simple library settings objects, like yours I put in the previous mail and like Select2's etc. I did not mean extending IJavaScriptLibrarySettings, just a brand new object that has methods like: getJQueryUICSSResourceReference() etc. I dont think it would be a good idea to start analyzing the class hierarchies of these settings objects. I originally wanted to just raise awareness about the inability to have page specific customizations in most Wicket libraries out there. I was hoping to arrive at some kind of best practice for locating library settings, which allows for per page customizations. My idea was that each library, like yours for example, would implement it independently. The more I think about it, the more it looks like a really good implementation will consist of too many parts for each library to implement independently. Martin's last email looks like he would also like the solution to be a reusable one, so that all JS libraries can gain advantage of using the settings locator. Last night I started working on some classes to implement just this idea in a re-usable way. Unfortunately, the code that came out was quite ugly. Just not a very neat solution. I'm going to continue working on this, and hopefully come up with something that is respectable. I'll create a github repo when I have something worthwhile. I have another, similar idea which I did not discuss in the last email, but which I am now thinking of doing at the same time: It's becoming less and less accurate to say a JS library depends on JQuery. More often than not, a JS library depends on specific versions or version ranges of JQuery. I would like to be able to declare dependencies on JQuery, and provide a version range. All components etc that renderHead() can then specify which versions of JQuery they can work with, and I have a custom IHeaderResponseDecorator that records what different components wants, and during close() picks a version that will work with all the components on the page. I think this, second idea will help with the concerns you raised. I haven't worked out exactly how I'm going to implement this yet, but I'm pretty sure it should be easy with subclassing HeaderItem and a custom IHeaderResponse. Will also implement some features from wicketstuff-jslibraries. I'll post once I have some code to show. Cheers, Jesse On 24/03/2014 16:46, Sebastien wrote: Hi, I like the idea too... Even, I am not sure to have understood the use-case about the Session scope here, but I trust you :) I've got one question... Imagine you are supplying 2 libraries, plugin1 and plugin2 for instance The libraries definitions would be IPlugin1LibrarySettings extends IJavaScriptLibrarySettings IPlugin2LibrarySettings extends IJavaScriptLibrarySettings Then, you define you custom script like: MyLibrarySettings extends JavaScriptLibrarySettings implements IPlugin1LibrarySettings, IPlugin2LibrarySettings By doing this, I *cannot* have the same getters for returning the plugin's JavaScriptResourceReference, ie: IPlugin1LibrarySettings#getPluginJavaScriptResourceReference IPlugin2LibrarySettings#getPluginJavaScriptResourceReference So, user wishing to provides its own library have to check all IxxxLibrarySettings interfaces to not overlap an existing getter name, even interfaces of satellite projects (but he will never do it of course...). Do you see the point? I think that, by writing a new strategy for loading/customizing javascript library resource references, it would be nice to solve this question in the meantime... (if you are waiting for my solution, I should tell you that I do not have it yet! ;) ) What so you think? Best regards, Sebastien. On Mon, Mar 24, 2014 at 12:12 PM, Martin Grigorov mgrigo...@apache.orgwrote: On Mon, Mar 24, 2014 at 12:59 PM, Jesse Long j...@unknown.za.net wrote: On 24/03/2014 12:05, Martin Grigorov wrote: Hi Jesse, On Mon, Mar 24, 2014 at 11:11 AM, Jesse Long j...@unknown.za.net wrote: Hi All, Wicket uses mostly ResourceReferences to render and manage the URLs for CSS and JavaScript files to be included in the output. When we use libraries like JQuery UI, Bootstrap etc, it is often a requirement to allow the user to provide his own customized resource references. Typically, our code that integrates Wicket with these libraries provides a settings object, which contains getters and setters for resource references, as well as some other variables that manipulate the libraries behavior. eg: https://github.com/sebfz1/wicket-jquery-ui/blob/master/ wicket-jquery-ui-core/src/main/java/com/googlecode/ wicket/jquery/core/settings/IJQueryLibrarySettings.java I want to propose some behavior regarding these settings objects, which will hopefully make our lives a little easier. Initially, I just
Re: jQuery noConflict() and wicket 6
Hi, I haven't tried it but this may work: the page should load the scripts in this order: 1) jQuery 1.11.0 (the one coming with Wicket) 2) wicket-ajax-jquery.js 3) var jQuery1_11 = jQuery.noConflict(); 4) jquery 1.4.4 5) your-custom-component.js Try it Martin Grigorov Wicket Training and Consulting On Tue, Mar 25, 2014 at 3:53 AM, trlt trl...@gmail.com wrote: I wrote a simple test program to understand how jQuery.noConflict() works with Wicket 6. The program uses 2 different jQuery libraries (jQuery 1.11.0 by Wicket 6 and jQuery 1.4.4 by someone else), and can be explained in its *.html file: !DOCTYPE html html xmlns:wicket=http://wicket.apache.org; head meta charset=utf-8 / titleApache Wicket Quickstart/title /head body p click # ( ajax link ) /p /body /html decorator.js is a program implemented by another developer. It also adds jQuery 1.4.4 dynamically to the page. To simplify the code, I only included the line that causes the problem: (function($) { $(document).ready(function() { $('head').prepend(''); }); })(jQuery); Problem: Wicket Ajax link (c1-link) no longer works (onClick() is never called). jQuery object now references version 1.4.4. In Firebug, I see the following error: TypeError: jQuery(...).on is not a function jQuery(el).on(type, data, fn); //wicket...4000.js (line 169) Question: How can I reset the jQuery object to 1.11.0 for the Wicket Ajax call? Can someone explain to me the execution order of the different jQuery libraries used in the program? I tried to reset it by calling $.noConflict() after decorator.js, but that didn't work (still points to 1.4.4). I'm not too sure how to unset it since it's added dynamically after the DOM object has been created. I can update the program to use jQuery 1.7+ in place of 1.4.4 to solve the problem, but I want to understand how 2 different libraries can be used in the same page. Hoping someone can help! -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/jQuery-noConflict-and-wicket-6-tp4665117.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
Testing a DropDownChoice without a Form with wantOnSelectionChangedNotifications=true
I have a DropDownChoice that is not within a Form and I'm trying to write a test that selects an item in that DropDownChoice. I have been trying to use WicketTester.executeUrl and give it the url in the onchange attribute of the DropDownChoice but I'm not having any luck. Even if I do get that to work, it requires me duplicating the logic of how wicket generates that url, which means my code could break if wicket changes this. Does anyone know of a good way to do this? Thanks! -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Testing-a-DropDownChoice-without-a-Form-with-wantOnSelectionChangedNotifications-true-tp4665121.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: Testing a DropDownChoice without a Form with wantOnSelectionChangedNotifications=true
Hi, See how org.apache.wicket.util.tester.FormTester#select() does it. You need to do tester.invokeListener(component, IOnChangeListener.INTERFACE); Martin Grigorov Wicket Training and Consulting On Tue, Mar 25, 2014 at 8:37 PM, jchappelle jchappe...@4redi.com wrote: I have a DropDownChoice that is not within a Form and I'm trying to write a test that selects an item in that DropDownChoice. I have been trying to use WicketTester.executeUrl and give it the url in the onchange attribute of the DropDownChoice but I'm not having any luck. Even if I do get that to work, it requires me duplicating the logic of how wicket generates that url, which means my code could break if wicket changes this. Does anyone know of a good way to do this? Thanks! -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Testing-a-DropDownChoice-without-a-Form-with-wantOnSelectionChangedNotifications-true-tp4665121.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
calling downloadLink.onClick() directly
Hello, I currently am using a downloadLink to export a csv file to the user. What I am currently doing is using a worker thread to handle the creation of the csv file while an AjaxSelfUpdatingTimerBehavior updates the GUI of its progress.. Then at completion the intent is to call downloadLink.onClick() to invoke the behind the scenes work and get the user the dialog box automatically to download the file. I get everything running fine until downloadLink.onClick() is called I get an ajax error: Wicket.Ajax.Call.failure: Error while parsing response: Error: Invalid XML: ��ࡱ�;��...`��Page 1�����=Bems_ID First_NameMiddle_NameLast_NameUser_Status it looks like the csv file is being outputted to the ajax debugger. What is the best way to invoke the onClick method automatically of the DownloadLink class? Here is a snippet of what I am doing: private void setupDownloadLink() { IModel excelFileModel = new AbstractReadOnlyModel() { public Object getObject() { if(excelFile == null) { excelFile = new File(Error getting File); } return excelFile; } }; auditDownloadlink = new DownloadLink(auditDownloadlink, excelFileModel) { public void onClick() { downLoadLinkClicked = true; if (newSearchWasInitialized) { newSearchWasInitialized = false; if (!extractionIsRunning) { worker = new CreateExcelExtractionWorker(); thread = new Thread(worker); thread.start(); extractionIsRunning = true; excelFile = null; return; } } if(!newSearchWasInitialized) { if (!extractionIsRunning) { super.onClick(); } } } }; auditDownloadlink.add(new Label(excelLabel, Excel)); auditDownloadlink.setOutputMarkupPlaceholderTag(true); auditDownloadlink.setDeleteAfterDownload(true); auditDownloadlink.setCacheDuration(Duration.ONE_SECOND); auditDownloadlink.setVisible(false); findUserForm.add(auditDownloadlink); } Here basically when the user selects the button, it starts the worker thread.. Then when completed, the AjaxSelfUpdatingTimerBehavior will call the onClick() method, where in turn after each check is made then super.onClick() is called to process the downloading of the file as normal: public void onPostProcessTarget(AjaxRequestTarget target) { System.out.println(isRunning); if(!extractionIsRunning) { if(downLoadLinkClicked) { System.out.println(refreshed); progressModel.setObject(Extraction to Excel file complete. Click Download); auditDownloadlink.addOrReplace(new Label(excelLabel, Download)); target.add(findUserForm); target.add(progress); stop(target); System.out.println(isStopped); downLoadLinkClicked = false; auditDownloadlink.onClick(); } } } }; progress.add(progressUpdateBehavior); progress.setOutputMarkupId(true); Do I have to attach it back to the requestCycle? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/calling-downloadLink-onClick-directly-tp4665125.html Sent
Re: calling downloadLink.onClick() directly
Hi, Check https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow Martin Grigorov Wicket Training and Consulting On Tue, Mar 25, 2014 at 11:56 PM, eaglei22 jchojnack...@gmail.com wrote: Hello, I currently am using a downloadLink to export a csv file to the user. What I am currently doing is using a worker thread to handle the creation of the csv file while an AjaxSelfUpdatingTimerBehavior updates the GUI of its progress.. Then at completion the intent is to call downloadLink.onClick() to invoke the behind the scenes work and get the user the dialog box automatically to download the file. I get everything running fine until downloadLink.onClick() is called I get an ajax error: Wicket.Ajax.Call.failure: Error while parsing response: Error: Invalid XML: �� ࡱ �; ��...` � � Page 1� ��� �= Bems_ID First_Name Middle_NameLast_Name User_Status it looks like the csv file is being outputted to the ajax debugger. What is the best way to invoke the onClick method automatically of the DownloadLink class? Here is a snippet of what I am doing: private void setupDownloadLink() { IModel excelFileModel = new AbstractReadOnlyModel() { public Object getObject() { if(excelFile == null) { excelFile = new File(Error getting File); } return excelFile; } }; auditDownloadlink = new DownloadLink(auditDownloadlink, excelFileModel) { public void onClick() { downLoadLinkClicked = true; if (newSearchWasInitialized) { newSearchWasInitialized = false; if (!extractionIsRunning) { worker = new CreateExcelExtractionWorker(); thread = new Thread(worker); thread.start(); extractionIsRunning = true; excelFile = null; return; } } if(!newSearchWasInitialized) { if (!extractionIsRunning) { super.onClick(); } } } }; auditDownloadlink.add(new Label(excelLabel, Excel)); auditDownloadlink.setOutputMarkupPlaceholderTag(true); auditDownloadlink.setDeleteAfterDownload(true); auditDownloadlink.setCacheDuration(Duration.ONE_SECOND); auditDownloadlink.setVisible(false); findUserForm.add(auditDownloadlink); } Here basically when the user selects the button, it starts the worker thread.. Then when completed, the AjaxSelfUpdatingTimerBehavior will call the onClick() method, where in turn after each check is made then super.onClick() is called to process the downloading of the file as normal: public void onPostProcessTarget(AjaxRequestTarget target) { System.out.println(isRunning); if(!extractionIsRunning) { if(downLoadLinkClicked) { System.out.println(refreshed); progressModel.setObject(Extraction to Excel file complete. Click Download); auditDownloadlink.addOrReplace(new Label(excelLabel, Download)); target.add(findUserForm); target.add(progress); stop(target); System.out.println(isStopped); downLoadLinkClicked = false; auditDownloadlink.onClick(); } } } }; progress.add(progressUpdateBehavior); progress.setOutputMarkupId(true); Do I have to attach it back to the requestCycle? -- View this message in context:
Re: Replace HTML Markup Dynamically
Hi, Upgrade to 6.11, then to 6.12, 6.13 and see when it starts. Then we can check together the respective changelog/release notes. Martin Grigorov Wicket Training and Consulting On Tue, Mar 25, 2014 at 11:31 PM, Jered Myers jer...@maplewoodsoftware.comwrote: We were running Wicket 6.10 with our application and after upgrading to Wicket 6.14 our help file system no longer works. The system would open a modal window and dynamically set the HTML file to use based on StringResourceModels. This allows us to set the name of the help file in a components properties file and use the same help modal window to display the help file. The problem now is that the entire page redirects to the help file instead of just the page in the modal window. Does anybody have any idea what might of changed or how I can fix this? Here is the key code in the ModalWindow's page: protected void onInitialize() { super.onInitialize(); String helpFileName = fileNameModel.getObject() + .html; // add the anchor tag if it exists if (anchorModel != null !Strings.isEmpty(anchorModel.getObject())) { helpFileName += # + anchorModel.getObject(); } getRequestCycle().scheduleRequestHandlerAfterCurrent(new RedirectRequestHandler(docs/ + helpFileName)); } Thanks for your help! -- Jered Myers
No javascript wicket 6.14.0
Hi, I have a very odd error and can't see any error messages. When Adding a Link or AjaxLink I get redirected to the previous page. If adding a label everything is ok. When looking at the source wicket isn't including any javascript. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/No-javascript-wicket-6-14-0-tp4665128.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: No javascript wicket 6.14.0
Ok, read that Jquery only is included when needed. I can't even add a simple Link? add(new LinkVoid(link){ @Override public void onClick() { setResponsePage(TestPage.class); } }); The code above redirects me to Apache root. If I comment out the add link everything works! -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/No-javascript-wicket-6-14-0-tp4665128p4665129.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