quickstart
Wicket Guys, FYI - Your quickstart page on wicket.apache.org is broken with a javascript error. Can't build a quick wicket app using the maven archetype. Probably a quick fix for you. -- IMPORTANT: This e-mail (including any attachments) is intended for the use of the individual or entity to which it is addressed and may contain information that is classified, private, or confidential. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is prohibited. If you have received this communication in error, please notify us immediately by replying to this e-mail. Thank you.
AjaxChannel usage
I would like to have my file upload requests on my site, which take much longer than a normal request, go through a different mechanism. I'd like the user to still be able to click around the site and work while the file is uploading and then when it finishes, I can pop up an "All Done" type dialog. AjaxChannel seems to me to be the mechanism to do this, but either I am doing it wrong or it doesn't work as I'd expect. My links I'm testing the concept with looks like (I'm using wicket 6.10.0): add(new AjaxLink("slow") { @Override public void onClick(AjaxRequestTarget target) { System.out.println("Slow Link Clicked"); try { Thread.sleep(Integer.valueOf("1")); } catch (InterruptedException ie) {} target.appendJavaScript("alert('Done with slow running request');"); System.out.println("Done Processing Slow Link."); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(new AjaxChannel("upl", AjaxChannel.Type.QUEUE)); } }); add(new AjaxLink("fast") { @Override public void onClick(AjaxRequestTarget target) { System.out.println("Fast Link Clicked"); target.appendJavaScript("alert('Done with fast running request');"); System.out.println("Done Processing Fast Link."); } }); I would expect that if I click Slow, then click Fast that the fast would return to the user before the slow, but that's not happening. I can attach a quickstart and create an issue in JIRA if that is the route to go if I am doing it right. If I'm doing it wrong, can someone let me know how I can accomplish what I'm looking to do? Thanks, Steve
DataTable sort column descending
Is there an easy way to have a DataTable column sort descending the first time it is clicked on? The code in OrderByLink does the following: protected SortOrder nextSortOrder(final SortOrder order) { // init / flip order if (order == SortOrder.NONE) { return SortOrder.ASCENDING; } else { return order == SortOrder.ASCENDING ? SortOrder.DESCENDING : SortOrder.ASCENDING; } } The first time it is NONE, so it changes to ASCENDING. This is the desired outcome in most use cases, but not one I am working on. I think I can override this, but it's ugly since I'd have to go through OrderByLinkBorder, HeadersToolbar and to Datatable. Just wondering if there's a cleaner and/or easier way. -- IMPORTANT: This e-mail (including any attachments) is intended for the use of the individual or entity to which it is addressed and may contain information that is classified, private, or confidential. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is prohibited. If you have received this communication in error, please notify us immediately by replying to this e-mail. Thank you.
IAjaxCallListener getPrecondition
I am aware of the getPrecondition() method on IAjaxCallListener that I can use to prevent the ajax call from happening on the click of a link, button, etc, but I'm wondering if anything in the wicket framework can prevent the default altogether. Let me try to explain with an example of my use case: final RadioChoice favorite = new RadioChoice("favorite", Model.of(Hobbit.Samwise), Arrays.asList(Hobbit.values())); favorite.add(new AjaxFormChoiceComponentUpdatingBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { System.out.println("update has been called. model is now: " + favorite.getModelObject()); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new AjaxCallListener().onPrecondition("return confirm(\"Did you change your mind?\");")); } }); When I click on one of the radio buttons or its label, I get the confirmation box. If I click "OK", it calls the onUpdate() as expected. If I click "Cancel", it does not call onUpdate as expected, but what I would like it to do is revert the state or the RadioChoice before I clicked it. Same thing with CheckBoxMultipleChoice. Is there an easy way in wicket to do this, or do I need to write the custom javascript to do this myself? If wicket doesn't do this, should/can it? -- IMPORTANT: This e-mail (including any attachments) is intended for the use of the individual or entity to which it is addressed and may contain information that is classified, private, or confidential. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is prohibited. If you have received this communication in error, please notify us immediately by replying to this e-mail. Thank you.
Component to String
I found several threads on the user list about converting a Component into a String. There are at least 2 very valid use cases where doing this makes sense: 1. You are trying to create an html email to send out to your customers. Building that content out with wicket is a great way to do it. We are able to harness Wicket's awesome i18n capabilities to generate the content. Otherwise, we resort to ResourceBundles or having to introduce some other templating library. 2. Many Javascript APIs/JQuery Plugins (i.e. growl notifications, popovers, etc) want the html content passed in. Again, ideally the component is written in wicket. The threads I've seen have asked for potential ways to do this, but I'm wondering if this is a utility that should be included within Wicket itself. What do you think? If you think this type of utility does not belong in the framework and should be implemented by the users instead, can you provide a wicket 6 way of accomplishing this? Thanks. -- IMPORTANT: This e-mail (including any attachments) is intended for the use of the individual or entity to which it is addressed and may contain information that is classified, private, or confidential. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is prohibited. If you have received this communication in error, please notify us immediately by replying to this e-mail. Thank you.
AjaxErrorStrategy.INVOKE_FAILURE_HANDLER in wicket6
I see I can override the AjaxErrorHandlingStrategy in wicket6 to be AjaxErrorStrategy.INVOKE_FAILURE_HANDLER so that we don't get a 302 to the appropriate error page (InternalError, NotAuthorized, etc). My question is how do I do something useful with this? With only that change, the 500 error comes back to the client and we get a javascript error. We are using ajax and breadcrumbs on our site and what I'd like to do is hook into the wicket framework so that if one of these errors was detected on an ajax request, I can simply swap out the "content" portion of the page with the appropriate error component. That way, the state of the page, including visited breadcrumbs, navigation menus, etc remain intact, so the user can hopefully go "back" to some point they were working on by clicking on one of their breadcrumbs. -- IMPORTANT: This e-mail (including any attachments) is intended for the use of the individual or entity to which it is addressed and may contain information that is classified, private, or confidential. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is prohibited. If you have received this communication in error, please notify us immediately by replying to this e-mail. Thank you.
AjaxRequestAttributes.setAllowDefault
We have a dropdown menu based component (based off of twitter bootstrap) that needs to have the links' default allowed so the menu closes. We can create a subclass of AjaxLink that overrides the updateAjaxAttributes and does this, but then developers have to know either to use that specialized link or to override the updateAjaxAttributes in their link. Is there a way that the controlling componenent (the menu) can override the ajaxattributes for its children links? Currently, the updateAjaxAttributes method is protected, so I'm not aware of a way. Would it make sense to make this method public and/or is there another way to accomplish this?
form inputs to Labels
We have forms throughout our application that can be toggled from read-only to editable. The wicket framework will disable the form components which is great, but we'd rather have it display just the texts in a label. We can subclass TextField, TextArea, DropDownChoice, etc and override the onComponentTag() and onComponentTagBody() methods where applicable, but was wondering if anyone had a more elegant solution or wicket had something out of the box that would turn FormComponents into Labels. Here's example for a TextField we could do by subclassing TextField and overriding onComponentTag: @Override protected void onComponentTag(ComponentTag tag) { if (!isEnabledInHierarchy()) { tag.setName("span"); tag.remove("type"); tag.remove("disabled"); tag.remove("name"); tag.remove("value"); tag.setType(XmlTag.TagType.OPEN); } }
DataTable in wicket 6 using wicket:container
The DataTable was changed in wicket 6 to use wicket:container instead of span on the td and th elements ( https://issues.apache.org/jira/browse/WICKET-4224). While this fixed the issue described in the ticket, it can make dealing with the DataTable a little more cumbersome and introduces a new bug in my opinion. If I want to simply add a link into a column (very usual use case), I cannot do so now without creating a dummy panel around it, or at least I don't know of a way. Any component with attributes in the componentTag itself get dropped because the wicket:container tag doesn't get rendered, only the child does. It works fine with plain Label's, but that's about it. I can create a handful of dummy components that wrap the columns "real" content, but wasn't sure if this was the best way to do it. Other people will certainly have the same issues when they upgrade to wicket 6. If you want me to create a quickstart for the link issue, I can do that.
ajax and browser back button in wicket 6
I did a search in the user list and found several references of various ways to solve the back button using ajax problem, but most were a few years old. I was wondering if wicket 6 does can do this out of the box now. One of the stated goals on the wicket site is that it will "Fully solve back button problem". Does this hold true for ajax requests or just plain http requests (or both)?
Re: adding resources after ajax swap
Igor, Can you provide more info on the filter? I'm struggling to see how adding a filter to my code will help since the js file is being requested on a different domain. I tried the code below to inspect things, but I never got anything in there except GETs. Also, is this something you think might be worthwhile putting into wicket itself? I can see users wanting to include scripts from Google's CDN or other providers without having to provide some sort of hack. public class OptionsFilter implements Filter { @Override public void destroy() { } @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; System.err.println(request.getMethod() + ": " + request.getRequestURL()); if (request.getMethod().equals("OPTIONS")) { Enumeration headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { System.err.println(headerNames.nextElement()); } } else { chain.doFilter(req, res); } } @Override public void init(FilterConfig arg0) throws ServletException { } } On Thu, Sep 22, 2011 at 3:18 PM, Steve Lowery wrote: > Is that a filter on my end? Would that go before or after my wicket filter > mapping? Any helpful resources out there on this? I haven't dealt with > OPTIONS methods before. > > > On Thu, Sep 22, 2011 at 2:28 PM, Steve Lowery > wrote: > >> I'm having an issue using resources after an ajax swap, in this case >> jquery. My home page does not have anything jquery related on it. There is >> an AjaxFallbackLink which swaps out the main content. The new content Panel >> has a jquery header contributor. I see this is being returned in the >> response to the AjaxFallbackLink click: >> >>
Re: adding resources after ajax swap
Is that a filter on my end? Would that go before or after my wicket filter mapping? Any helpful resources out there on this? I haven't dealt with OPTIONS methods before. On Thu, Sep 22, 2011 at 2:28 PM, Steve Lowery wrote: > I'm having an issue using resources after an ajax swap, in this case > jquery. My home page does not have anything jquery related on it. There is > an AjaxFallbackLink which swaps out the main content. The new content Panel > has a jquery header contributor. I see this is being returned in the > response to the AjaxFallbackLink click: > >
Re: adding resources after ajax swap
Igor, Here are the request headers (response returns a 405 - Method not allowed): OPTIONS http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.jsHTTP/1.1 Access-Control-Request-Method: GET Origin: http://localhost:8080 Access-Control-Request-Headers: Origin, Wicket-Ajax, Accept Note: If I download the js file and do a response.renderJavascriptResource(new ResourceReference(MyClass.class, "jquery.js")) as opposed to response.renderJavascriptReference(" http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js";); it works. On Thu, Sep 22, 2011 at 2:28 PM, Steve Lowery wrote: > I'm having an issue using resources after an ajax swap, in this case > jquery. My home page does not have anything jquery related on it. There is > an AjaxFallbackLink which swaps out the main content. The new content Panel > has a jquery header contributor. I see this is being returned in the > response to the AjaxFallbackLink click: > >
adding resources after ajax swap
I'm having an issue using resources after an ajax swap, in this case jquery. My home page does not have anything jquery related on it. There is an AjaxFallbackLink which swaps out the main content. The new content Panel has a jquery header contributor. I see this is being returned in the response to the AjaxFallbackLink click:
serialization question
Is there a hook point to serialization of components? We would like to throw a WicketRuntimeException if we detect that we are about to attempt to serialize out an attached (in our case Hibernate) entity rather than using a LoadableDetachableModel and only serializing the id. I see I can register an DetachListener, but that doesn't fire until after the model is detached and that doesn't help in these cases I think. We have had issues where we actually OOM the server when trying to serialize an entity that has LOTS of associations. I'd like to throw the exception before the serialization is even attempted. We are using wicket 1.4.17.
validation with link only
I have a Form object whose only child is an AjaxSubmitLink. The Form's onSubmit() calls to a service to delete its model object (from the underlying database). I would like to add validation to make sure that the model can be deleted (i.e. there are no foreign keys referencing it) before attempting to do it. I thought I could achieve this with an AbstractFormValidator, but if I detect the error in the validate() method, all of the error methods on AbstractFormValidator expect a FormComponent, which I don't have. What is the best way to accomplish validating a Form that does not have a FormComponent?
1.5-RC1 maven source, javadoc, and tests
Looks like the source, javadoc and test artifacts for 1.5-RC1 published to the maven repo are empty. Can this be fixed please? Thanks, Steve
YuiMenuBarItem getMenuClass menu2
I'm trying to create a YuiMenuBar for my application using the ones in the menu2 packages. It works great, but I want to style one of the YuiMenuBarItems differently. I see there is an overridable getMenuClass() method, but there are 2 issues: 1. The only way to contruct a YuiMenuBarItem is through YuiMenuBar.addMenu(), so even if I create a subclass, it does me no good. 2. The getMenuClass() is returning "yuimenuitem", but the markup already has the class attribute set to "yuimenubaritem" and it is not being overwritten by the one in the component. Am I using these components right, or does YuiMenuItem need a setMenuClass() on it? I am using version 1.4.1.
DateTimeField enhancement
I'd like to use the DateTimeField component, but there is no API that I can see to override what DatePicker gets added to the component. I'd like to subclass the DatePicker and customize the icon, positioning, etc. I can do this if just dealing with the DateTextField, where I add the DatePicker behavior myself, but I can't do it when using the DateTimeField. Is there a way to do this? If not, could it be enhanced so we can do this? A simple protected newDatePicker() method on DateTimeField would accomplish this.
Transactions with RuntimeException
We have a filter that runs in our context before the wicket filter that starts a hibernate transaction, does a chain.doFilter() and then commits the transaction. The problem we are running into is that if a RuntimeException is thrown, Wicket catches it, logs it and figures out which page to display to the user. However, the exception is swallowed and therefore our filter has no knowledge that something bad occurred and is committing the transaction when it shouldn't be. What is the recommended way to deal with this?
onComponentTagBody Behavior
We have a component that extends Label we've written to replace the body of the component with N/A, unknown, or whatever resource we give it when its model object is null (by overriding onComponentTagBody). I'd like to pull this out into a behavior, but can't seem to do it by overriding beforeRender(), onRendered(), or onComponentTag() in the behavior. I can write to the response in the behavior before and after the components tag, but not in its body. Anybody know of a way to do this?
AjaxBehavior and onblur
I have a Form on my page that has amongst others 3 fields: zipcode, city, and state. I would like it when the user enters data in the zipcode field, an ajax request be generated to lookup and populate the city and state fields in the form. However, I don't want the underlying model (an employee) to be updated until the form is submitted. The textfields' models are PropertyModels of the underlying Employee model. AjaxFormComponentUpdatingBehavior("onblur") updates the model, but persists the changes to the Employee object since it is a managed object (we are using hibernate). If I use an AjaxEventBehavior("onblur"), the model doesn't get updated, but the getInput() and getValue() on the zipcode textfield doesn't reflect what the user just entered. It still has what was in the original model. Is there some way to have an ajax call for an onblur (or whatever event) not update the model, but give the handling code access to what data is currently in the component the behavior is attached to? Thanks, Steve
override isEnabledInHierarchy?
I would like to build a simple form whose markup looks like the following: [Label] [edit] [attr1] [attr2] [submit] [cancel] I call setEnabled(false) on the Form when it is constructed which makes its FormComponents disabled making a "read only" version of the form. I'd then like the editLink.onClick() to enable the form, which will enable it's components. However, since the editLink is a child of the Form which is initially disabled, that link is disabled. I am looking for a way to not have the link be disabled eventhough the form it is in is disabled. My thought was for that link, I could override isEnabledInHierarchy() to just negate the value returned by super (if the form is disabled the link is enabled and vice versa), but that method is final, so no can do. Is anyone aware of another way I could go about doing this? I know I could create a wicket component on say the tbody element and have it be disabled, but then the link would have to be passed which element(s) it needs to enable when clicked and I was hoping to just be able to use the hierarchy so I can make the EditLink a reusable component since this is a very common use case for us (having read only forms that become editable with a click). Thanks in advance! Steve