AbstractPageableView calling IDataProvider.size() when it maybe shouldn't
Hi, I noticed a possible inefficiency in AbstractPageableView's getItemModels() method: /** * This method retrieves the subset of models for items in the current page and allows * RefreshingView to generate items. * * @return iterator over models for items in the current page */ @Override protected IteratorgetItemModels() { long offset = getFirstItemOffset(); long size = getViewSize(); Iterator models = getItemModels(offset, size); models = new CappedIteratorAdapter(models, size); return models; } The getViewSize() method will issue a getRowCount() call which in DataViewBase will call the size() method of the DataProvider: public long getViewSize() { return Math.min(getItemsPerPage(), getRowCount() - getFirstItemOffset()); } As far as I can see, this happens so that the call to getItemModels(offset, size) would not ask for more items, than there is in the underlying provider. However, ListDataProvider defends against getting more items than present in the list: @Override public Iterator iterator(final long first, final long count) { List list = getData(); long toIndex = first + count; if (toIndex > list.size()) { toIndex = list.size(); } return list.subList((int)first, (int)toIndex).listIterator(); } Also databases can handle a LIMIT clause that asks for more rows than present in the dataset. The reason I was looking at this code is a DataView element I'm using on the front page of a public web application that fetches and displays the N most recent entries from a comment table without any paging components added to the DataView and I was seeing a simple "SELECT count(id) FROM comment"-like query taking 9% of all sql time according to JavaMelody for the last few days. I've changed the implementation by overriding the getItemModels() method to call directly getItemsPerPage instead of getViewSize and it got rid of the count selects and everything else seems to be working fine. I'm wondering if there is maybe some other reason why getItemModels() is calling getViewSize instead of getItemsPerPage that I've missed. If not should I create a ticket in jira? Thanks, Janos -- pilar.hu - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Opening modal window at file upload completion
You can try using Uploadify from code.google.com/p/jqwicket/, which lets you put event handlers on successful completion. You need to write a separate servlet to handle upload though, but it's quite straightforward. One small trick is overriding getEventHandler() so you can pass the javascript generated to call the behaviour from other javascript components. The example below uses a uuid to communicate between the upload form and the servlet. // ajax behaviour added to parent as bogus onNever event handler OnComplete onComplete = new OnComplete(onNever, ip, uuid); wmc.add(onComplete); wmc.add(new UploadifyWebMarkupContainer(upload, new UploadifyOptions().auto(true).multi(false).scriptAccess(always). script(getRequest().getRelativePathPrefixToContextRoot() + upload?uuid= + uuid).onCompleteEvent(onComplete.getEventHandler(; ... /** * AJAX behaviour fired when upload is ready */ public class OnComplete extends AjaxEventBehavior { Picture picture; String uuid; public OnComplete(String event, Picture picture, String uuid) { super(event); this.picture = picture; this.uuid = uuid; } public String getUuid() { return uuid; } @Override protected void onEvent(AjaxRequestTarget target) { // servlet stores uploaded image byte[] bytes = UploadifyServlet.getAndRemoveBytes(uuid); if (bytes != null) { PhotoUtil.handleImageUpload(bytes, picture); } target.addComponent(getComponent().getParent().getParent()); } // need to be public @Override public CharSequence getEventHandler() { return super.getEventHandler(); } } On Sat, Aug 27, 2011 at 4:40 AM, Chris Colman chr...@stepaheadsoftware.comwrote: Is it possible to open a modal window after file upload completion. Even though I'm using the AJAX file upload which shows the progress bar the submit handler doesn't contain a 'target' parameter required to bring up a modal. protected void onSubmit() { final FileUpload upload = fileUploadField.getFileUpload(); if (upload != null) { // Create a new file . } The reason is that I do some processing of the file after uploading and I want to display to the user the results of that processing. Any ideas?
String not serializable exception coming for interned strings from Model with JRockit/Weblogic
Hi, The following seems to be a bug with JRockit or Weblogic, but maybe someone on this list has seen it before and has a better workaround/solution. We have been developing a Wicket application for a government agency that is going to be used by 15k users. The application will be deployed on a Weblogic cluster running on JRockit and Red Hat. We have been experiencing strange Model object not serializable exceptions coming from Model and traced it back to interned (by the compiler) String objects becoming not serializable after hitting the server with a few hundred parallel users. Once the exception occurs for a given String reference it keeps coming consistently for that reference. The current workaround is a custom Model class that has an overrided setObject method which checks the object if it's instanceof Serializable and if the check fails it sets new String(object) on the Model. This eliminates the exceptions but would like a better solution to the problem. Has anyone seen anything like this? Thanks and regards, Janos - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: wicketstuff.org down?
http://wicketstuff.org/maven/repository says now: Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. 2009/11/8 Martijn Dashorst martijn.dasho...@gmail.com: dns has been updated (about an hour ago) so things should get back to working order soon as the update trickles through internet. Martijn On Sat, Nov 7, 2009 at 11:40 PM, Martijn Dashorst martijn.dasho...@gmail.com wrote: THE server had been moves to another ip. I havent had time to update dns Martijn On Saturday, November 7, 2009, Janos Cserep cser...@metaprime.hu wrote: Yes. 2009/11/7 Ilja Pavkovic ilja.pavko...@binaere-bauten.de: Hi, I cannot reach wicketstuff.org anymore. Anyone else experiencing this problem? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.4 increases type safety for web applications Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.0 -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.4 increases type safety for web applications Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.0 - 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: wicketstuff.org down?
Yes. 2009/11/7 Ilja Pavkovic ilja.pavko...@binaere-bauten.de: Hi, I cannot reach wicketstuff.org anymore. Anyone else experiencing this problem? - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: wicketstuff.org down?
At least this gives me a reason and time now to setup Nexus to proxy wicketstuff.org until my builds are broken:) Any estimate when the dns change would be visible? Thanks, Janos 2009/11/7 Martijn Dashorst martijn.dasho...@gmail.com: THE server had been moves to another ip. I havent had time to update dns Martijn - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Could TinyMCE Upload pictures or files
I'm using the following custom tinymce javascript initialization (I don't use the default which comes with wicket-tinymce, but put this together manually). I override the image button of tinymce so the callback can change the whole panel and display a selector one. The user can use the selector panel to upload new pictures as well, but that's handled by wicket at that point. public class FormTinyMceRow extends FormTextAreaRow { private static final long serialVersionUID = 1L; public static final ResourceReference REFERENCE_MIN = new CompressedResourceReference( InPlaceEditBehavior.class, tiny_mce/tiny_mce.js); public FormTinyMceRow(String id, String selector) { super(id, selector); get(component).setOutputMarkupId(true); add(JavascriptPackageResource.getHeaderContribution(REFERENCE_MIN)); final AjaxFormSubmitBehaviorImpl b = new AjaxFormSubmitBehaviorImpl(onNever); add(b); add(new Label(script, new ModelString() { @Override public String getObject() { String siteCss = CmsConfig.getSiteById(((CmsSession)getSession()).getSiteId()).getCss(); return tinyMCE.init({ + mode : \exact\, + elements : \ + FormTinyMceRow.this.get(component).getMarkupId() + \, + language : \hu\, + theme : \advanced\, + plugins : \paste, searchreplace, preview, table, emotions\, + theme_advanced_buttons1 : \bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect\, + theme_advanced_buttons2 : \cut,copy,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,preview,|,forecolor\, + theme_advanced_buttons3 : \tablecontrols,|,blockquote,removeformat,visualaid,|,sub,sup,|,charmap,emotions,hr,advhr,fullscreen\, + theme_advanced_buttons4 : '', + theme_advanced_toolbar_location : \top\, + theme_advanced_statusbar_location : \bottom\, + theme_advanced_toolbar_align : \left\, + theme_advanced_resizing : true, + entity_encoding : \raw\, + content_css : \ + siteCss + \, + verify_css_classes : true, + verify_html : true, + setup : function(ed) { + ed.addButton('image', { + onclick : function() {\n + tinyMCE.execCommand('mceInsertContent', false, '%%IMAGE%%'); \n+ tinyMCE.triggerSave(true,true);\n + + b.getEventHandler() + \n } + }); + } });; } }).setEscapeModelStrings(false)); } Unfotunately I couldn't get the javascript functions to insert the image at the right position, so I'm using a string substitution pattern to do it. My base pages can handle pushing (to display a new dialog) and popping (to get back to previous content) components into the main area of my layout: private class AjaxFormSubmitBehaviorImpl extends AjaxFormSubmitBehavior { public AjaxFormSubmitBehaviorImpl(String event) { super(event); } @Override public void onSubmit(AjaxRequestTarget target) { CmsPage page = (CmsPage) getPage(); ContentSelector selector = new ContentSelector(page.getMainId(), new Model(), Photo.class) { @Override public void close(AjaxRequestTarget target) { Photo photo = (Photo) getDefaultModelObject(); String replacement = ; if (photo != null) { Image image = photo.getThumbnail(); if (image != null) { replacement = ImageView.contentImageUrl(image.getId(), 1, null, photo.getTitle()).toString(); } } IModel model = FormTinyMceRow.this.get(component).getDefaultModel(); model.setObject(model.getObject().toString().replaceAll(%%IMAGE%%, replacement)); ((CmsPage) getPage()).popMainContent(target); } }; page.pushMainContent(selector, target); } @Override protected void onError(AjaxRequestTarget target) { } // have to make it public @Override public CharSequence getEventHandler() { return super.getEventHandler(); } @Override protected CharSequence
Re: FW: need help urgent......Change label dynamicly
AFAIR a button's label comes from it's Model. So you should do: new AjaxButton(preview){ public void onSubmit(AjaxRequestTarget target, Form form){ String label = getModelObject(); // or getDefaultModelObject(); if 1.4 if (click.equals(label) { getModel().setObject(unclick); // or getDefaultModel().setObject(unclick) in case you're at 1.4 } } }.setModel(click); On Wed, May 6, 2009 at 11:44 AM, nino martinez wael nino.martinez.w...@gmail.com wrote: Maybe to it with an attribute modifier.. I cant remember ajaxbutton.. 2009/5/6 Per Newgro per.new...@gmx.ch: Maybe you could add two buttons and set the other visible? Cheers Per - 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: FW: need help urgent......Change label dynamicly
And of course don't forget to add the button or a parent component to the ajaxrequesttarget as well. On Wed, May 6, 2009 at 11:58 AM, Janos Cserep cser...@metaprime.hu wrote: AFAIR a button's label comes from it's Model. So you should do: new AjaxButton(preview){ public void onSubmit(AjaxRequestTarget target, Form form){ String label = getModelObject(); // or getDefaultModelObject(); if 1.4 if (click.equals(label) { getModel().setObject(unclick); // or getDefaultModel().setObject(unclick) in case you're at 1.4 } } }.setModel(click); On Wed, May 6, 2009 at 11:44 AM, nino martinez wael nino.martinez.w...@gmail.com wrote: Maybe to it with an attribute modifier.. I cant remember ajaxbutton.. 2009/5/6 Per Newgro per.new...@gmx.ch: Maybe you could add two buttons and set the other visible? Cheers Per - 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: Google Analytics and Wicket
Hi Mariana, Yes, with __trackPageview you can pretty much achieve what you want to do. In your menu component you probably change the panels by instantiating and replacing a main panel inside your page, right? If yes, do something like this: public void onClick(AjaxRequestTarget target) { // ... replace, etc target.appendJavaScript(pageTracker._trackPageview(' + panel trackCode + ');); } AjaxRequestTarget.appendJavaScript gets evaluated by the browser at the end of the AJAX call. Hope this helps, Janos On Fri, Apr 17, 2009 at 11:53 PM, Mariana Bustamante marian...@gmail.comwrote: Hello, I'm trying to use Google Analytics with my web application made using Wicket. The layout of my application is like this: I have a global plage called homePage that contains some panels inside. One of the panels is a menu which is completely made in java code using Wicket, the other important panel is the content panel that changes to a different panel with Ajax every time a user clicks a button on the menu. I tried placing the Google Analytics script at the bottom of the homePage but, as expected, in the generated report I can only see this page. However, I need to be able to view every panel as a different page. There is a link in the google analytics suppport page that seems like what I'm looking for ( http://www.google.com/support/googleanalytics/bin/answer.py?hl=enanswer=55519 ) but I can't see where to put the code they give since the links in my menu are generated by Wicket in java code and not in html. I would really appreciate any help to solve this problem, Thanks in advance, Mariana
Re: Markup inheritance with child pages setting title in the form 'BasePage.title + - + ChildPage.title'
1. Set an instance variable in the base page called basePageName You don't need a variable - all you need is a getter: public IModelString getPageTitleModel() { return new Model(ApplicationName); } 2. Use a Label to set the title in the base page Exactly, like this: add(new Label(pageTitle, getPageTitleModel()); 3. Let child pages append their part to the Label public IModelString getPageTitleModel() { return new Model(ApplicationName - Cool Page); } Another approach (this way you handle localization and don't have to override anything in your pages): public IModelString getPageTitleModel() { return new StringResourceModel(this.getClass().getSimpleName() + .PageTitle, this, null); } and put CoolPage.PageTitle=ApplicationName - Cool Page Title into your application properties file.
Re: URL rewriting
You have to mount your page via MixedParamUrlCodingStrategy: mount(new MixedParamUrlCodingStrategy(/company, CompanyPage.class, new String[] {companyName}); and in CompanyPage(PageParameters parameters) constructor do something like this: String nameInUrl = parameters.getString(); String company = nameInUrl.substring(0, ...); On Fri, Apr 10, 2009 at 5:11 PM, DV huc...@yahoo.com wrote: We are evaluating wicket to rewrite our consumer UI. There is one requirement in which I would like to get advice on. We have a requirement in which the wildcard url gets dispatched to a controller that renders a page. The url pattern is in the form of /company/**-details.html. We have a single controller that receives the above url and figures out the company name and displays the page accordingly or throws a http 404 error if the company is not found. e.g /company/ABC-details.html, /company/TOTO-details.html etc Can this be done in wicket? Any advice or hints would be appreciated! Dinp
Re: Localization issue
why the locale changes does not apply to the components? Are you setting up your components based on your locale in the constructor? Because if you do, then setting a Page object with setResponsePage won't create new component objects for you. Try: setResponsePage(this.getPage().getClass()); - this will forward you to a new instance of the page... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Localization issue
Actually now I have only one label for testing purposes: add(new Label(locale, getSession().getLocale().getLanguage())); That's actually bad practice. You are adding the component in the constructor. That code runs only once - when you create the component, page, etc. Try: add(new Label(locale, new PropertyModel(this, session.locale.language)); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to NOT use wicket's Role class
Bruce, Just use simpel strings as your role names: Roles roles = new Roles(OWNER,SUPERVISOR); roles.hasAnyRole(new Roles(OWNER)) - this will be true I usually put these as public final static Strings into my WebApplication class... Janos On Thu, Feb 14, 2008 at 8:39 PM, Bruce McGuire [EMAIL PROTECTED] wrote: Hello. My application has a need for more roles than user and admin. Can someone point me to links etc. on the simplest method of using more than these roles please? This class seems to be final, so extending it won't do the trick. Something of a similar complexity is desired, though. Thanks, Bruce. -- János Cserép - [EMAIL PROTECTED] Web: http://www.szeretgom.hu Skype: cserepj
Re: Mounting page at root
Is it possible at all to have content at / ? Trying to mount something at / results in an error and I'm wondering of there's a workaround. By default it displays your home page (actually the page represented by the page class returned by WebApplication's getHomePage() method) if you configure WicketFilter to the /* url.
Re: Mounting page at root
So I take it, it's currently not possible. Looks like I was not clear enough, sorry:) Configure your wicket filter to /* and return the page class you want to view as / as the home page in your application class. You don't have to mount anything, it will be displayed as /
Re: Doubt in wicket and multiple views
If you're looking for a way to use different layouts, templates for different virtual servers you have several options: - use the Session.setStyle() to set the style... you can do this in a custom WebRequest and by examining the server name of the request url. Then you can have different .html and .properties file per virtual host, but the same usage. - use a Border to incorporate all style information (adding css reference, the main layout, etc). I prefer this approach - I have an ancestor Page that always adds a border which border is made by a factory method I have on my subclassed webapplication. This way I can create different borders and thus different layouts and styles for different pages - or I could even have different styles based on any request parameters. The second approach can be seen in live at www.szeretgom.hu (sorry it is not available in English yet...) If you navigate to http://szeretgom.hu/portal/content/title/Wiki/ you get a different layout (which is created by a different border). A third kind of border is displayed at this URL: http://szeretgom.hu/portal/blog/pages/cserepj/ These are all handled by the same web application and it would be quite easy to modify my code to return different borders based on the request url's server name... Hope this helps... I have one model and 4 different web applications. All webapplications is using the same model but different views. There is Different virtual hosts on the same server. Can I use wicket for this? -- János Cserép - [EMAIL PROTECTED] Web: http://www.szeretgom.hu Skype: cserepj
Re: adding conditional component
How do you guys implement a link that is conditional? Like for example the link only shows if a given data is provided. Adding the a-tag in the Markup will coz an error if the condition is not met, because AjaxLink is not added. I usually handle such a situation by overriding the isVisible() method of the component: add(new Link(link) { @Override public boolean isVisible() { boolean externalCondition = ; return super.isVisible() externalCondition; } });