Re: How to update a Component from Javascript
Hi Martin Thanks for your reply. I've made the changes you suggested, but my ajax update never happens. I think I am missing something in what wicketAjaxGet can do, or how you are supposed to get the callback url. Here's a simplified version of my label class, maybe I'm doing something wrong: private class ComplianceLabel extends Label implements IHeaderContributor { private AbstractDefaultAjaxBehavior b; public ComplianceLabel(String id) { super(id, new AbstractReadOnlyModelString() { private static final long serialVersionUID = - 7745806927016944636L;; @Override public String getObject() { // Get the dynamic value of the label...I never see this update } }); setOutputMarkupId(true); b = new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = - 5672238144436563958L; @Override protected void respond(AjaxRequestTarget target) { } }; add(b); } @Override public void renderHead(IHeaderResponse response) { String js = wary.push(' + b.getCallbackUrl() + '); response.renderOnLoadJavascript(js); } } Thanks for any advice. Julian On Mon, Oct 24, 2011 at 11:41 PM, Martin Grigorov mgrigo...@apache.orgwrote: Hi, On Tue, Oct 25, 2011 at 2:15 AM, Julian Sinai jsi...@gmail.com wrote: This should be easy, but I'm striking out... I want to use a new Javascript feature (EventSourcehttp://dev.w3.org/html5/eventsource/, part of HTML5 WebSockets) to push notifications from the server to the browser. Getting the basic mechanism to work was easy. What I can't figure out how to do is once I get the notification on the client, how to tell Wicket to update the relevant components via Ajax. In other words, the equivalent of AjaxRequestTarget.addComponent(Component) in Javascript. This is how far I got, which didn't work. I was trying to use wicketAjaxGet: Script at the top of my page: var wary = new Array(); var source = new EventSource(events); source.onmessage = function(event) { for (var i = 0, item; item = wary[i]; i++) { missing check for 'i wary.length' wicketAjaxGet('+item+', function(){}.bind(this),function(){}.bind(this)); The success and failure handlers can be omitted. Just do: wicketAjaxGet(url) } }; Method in my Component subclass: public void renderHead(IHeaderResponse response) { String js = wary.push(' + b.getCallbackUrl() + '); response.renderOnLoadJavascript(js); } Any help is appreciated. What exactly breaks ? Is the Ajax call made at all ? Verify with Firebug Also with Firebug dump the contents of wary array. Julian -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com
How to update a Component from Javascript
This should be easy, but I'm striking out... I want to use a new Javascript feature (EventSourcehttp://dev.w3.org/html5/eventsource/, part of HTML5 WebSockets) to push notifications from the server to the browser. Getting the basic mechanism to work was easy. What I can't figure out how to do is once I get the notification on the client, how to tell Wicket to update the relevant components via Ajax. In other words, the equivalent of AjaxRequestTarget.addComponent(Component) in Javascript. This is how far I got, which didn't work. I was trying to use wicketAjaxGet: Script at the top of my page: var wary = new Array(); var source = new EventSource(events); source.onmessage = function(event) { for (var i = 0, item; item = wary[i]; i++) { wicketAjaxGet('+item+', function(){}.bind(this),function(){}.bind(this)); } }; Method in my Component subclass: public void renderHead(IHeaderResponse response) { String js = wary.push(' + b.getCallbackUrl() + '); response.renderOnLoadJavascript(js); } Any help is appreciated. Julian
Wicket filter chain and other servlets
Hi, I really could use some advice on how to solve this problem: In our webapp, we have a wicket filter as well as a couple of other servlets. The url pattern for the wicket filter is the usual /*. The problem is that because of this, all urls, including those of the other servlets, go through the wicket filter, which is causing problems. Specifically, we are using spring, so wicket's SpringComponentInjector wraps the beans, which sometimes results in the exception below. The real solution is to separate the other servlets into another webapp, but because of time constraints we can't do that. We also can't easily change our urls to assign a unique pattern to the wicket urls (although the other servlets do have unique patterns), because it will adversely affect users. Is there a way to solve this problem in web.xml? Use wicket servlet instead of wicket filter? org.apache.wicket.WicketRuntimeException: There is no application attached to current thread http-8443-7 at org.apache.wicket.Application.get(Application.java:179) ... at WICKET_com.hytrust.arc.TrustedHostMgr$$EnhancerByCGLIB$$eded0a19.refreshAllPolicy(generated) ... at com.hytrust.proxy.vmware.VIMHandlerServlet.doPost(VIMHandlerServlet.java:47) Any help is appreciated. Julian
Re: Wicket filter chain and other servlets
Hi Dan I don't understand the reason either, but clearly it's happening. My best guess is what I said in my original post: the non-wicket servlets are going through the wicket filter. Julian On Mon, Aug 8, 2011 at 12:23 PM, Dan Retzlaff dretzl...@gmail.com wrote: Hi Julian, I'm not quite understanding your setup. How did your non-Wicket servlet get a Wicket-proxied Spring bean? Dan On Mon, Aug 8, 2011 at 12:14 PM, Julian Sinai jsi...@gmail.com wrote: Hi, I really could use some advice on how to solve this problem: In our webapp, we have a wicket filter as well as a couple of other servlets. The url pattern for the wicket filter is the usual /*. The problem is that because of this, all urls, including those of the other servlets, go through the wicket filter, which is causing problems. Specifically, we are using spring, so wicket's SpringComponentInjector wraps the beans, which sometimes results in the exception below. The real solution is to separate the other servlets into another webapp, but because of time constraints we can't do that. We also can't easily change our urls to assign a unique pattern to the wicket urls (although the other servlets do have unique patterns), because it will adversely affect users. Is there a way to solve this problem in web.xml? Use wicket servlet instead of wicket filter? org.apache.wicket.WicketRuntimeException: There is no application attached to current thread http-8443-7 at org.apache.wicket.Application.get(Application.java:179) ... at WICKET_com.hytrust.arc.TrustedHostMgr$$EnhancerByCGLIB$$eded0a19.refreshAllPolicy(generated) ... at com.hytrust.proxy.vmware.VIMHandlerServlet.doPost(VIMHandlerServlet.java:47) Any help is appreciated. Julian
Re: Wicket filter chain and other servlets
Dan, thanks for your reply. You may be right, though I can't imagine what could be putting the proxy somewhere the servlet can access it. I'll take another look. And your suggestion to put a breakpoint in the SpringComponentInjector is a good one. Julian On Mon, Aug 8, 2011 at 12:49 PM, Dan Retzlaff dretzl...@gmail.com wrote: On second thought, both instantiating a Component and requesting injection would blow up immediately without an Application set. So I have to think something in your Wicket application is putting the proxy somewhere the servlet can access it.
Re: DateTimeField and setOutputMarkupId()
Martin, thanks for your help. Igor's hint helped me. After some investigation I realized that I have a visitor in my button's submit handler that visits all form components and adds them to the ajax target. That meant it was visiting the inner fields of the DateTimeField, also, which was not necessary. I fixed it by ignoring form fields in the visitor that don't have outputMarkupId set. Julian On Thu, Jul 21, 2011 at 11:32 PM, Martin Grigorov mgrigo...@apache.orgwrote: I don't see any problem. Put a break point in AjaxRequestTarget.addComponent() and see what is registered. If you see component with id hours then investigate the stacktrace. As last resort you can create a quickstart with plain Wicket components and if it still fails with this error send it to us in a ticket. On Thu, Jul 21, 2011 at 11:49 PM, Julian Sinai jsi...@gmail.com wrote: Hi Martin Thanks for looking at this. It's a bit complicated because we've built a form framework around Wicket, but here goes: In the page: HtFormPanel.DateFormField startField = new HtFormPanel.DateFormField(startField, new StringResourceModel(start, this, null), new PropertyModelDate(this, start), false); Where the constructor for HtFormPanel.DateFormField is: public DateFormField(String uniqueId, IModelString label, IModel m, boolean bShowTime) { // The DateTimeField is contained within the DateFormField super(uniqueId, FieldType.DATETEXTFIELD.toString(), (bShowTime ? new DateTimeField(FIELD_ID) : new DateField(FIELD_ID)), label, m); } Next, in the page: startField.setFieldOutputMarkupId(true); // The radio button that does the ajax update: final HtFormPanel.RadioFormFieldReportAction actionField = new HtFormPanel.RadioFormFieldReportAction( actionField,new ResourceModel(actionField),actionTypes,new LocalizedChoiceRendererReportAction(this), new PropertyModelReportAction(this,action)); Finally, the update code that causes the problem: actionField.getFormComponent().add( new HtAjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 8574977146235850631L; protected void onUpdate(AjaxRequestTarget target) { if (getAction() != null getAction().equals(ReportAction.VIEW)) { startField.setRequired(false); } else { startField.setRequired(true); } // We update the startField and the DateTimeField inside it. target.addComponent(startField); target.addComponent(startField.getComponent()); } }); Julian On Thu, Jul 21, 2011 at 12:30 PM, Martin Grigorov mgrigo...@apache.org wrote: Show some code. On Thu, Jul 21, 2011 at 10:09 PM, Julian Sinai jsi...@gmail.com wrote: Nothing is adding it, we add the DateTimeField itself to the target. Julian On Thu, Jul 21, 2011 at 12:08 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote: what is adding that to the target? -igor On Thu, Jul 21, 2011 at 12:07 PM, Julian Sinai jsi...@gmail.com wrote: It is the hours component of the DateTimeField. From DateTimeField.html: input type=text wicket:id=hours size=2 /nbsp;: Julian On Thu, Jul 21, 2011 at 11:24 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote: what is hours ? -igor On Thu, Jul 21, 2011 at 11:17 AM, Julian Sinai jsi...@gmail.com wrote: Igor, We do update the DateTimeField itself, and this is what we see: SEVERE: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] java.lang.IllegalArgumentException: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] at org.apache.wicket.ajax.AjaxRequestTarget.addComponent(AjaxRequestTarget.java:346) Julian On Thu, Jul 21, 2011 at 11:02 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote: cant update the DateTimeField itself? -igor On Thu, Jul 21, 2011 at 10:57 AM, Julian Sinai jsi...@gmail.com wrote: We have a need to update a DateTimeField via Ajax, but its fields are private, and they don't have setOutputMarkupId() set on them. The result is an exception upon Ajax update. Is there any solution other than cloning and owning DateTimeField? We are using Wicket 1.4.17 (and we can't upgrade to 1.5 just yet). Any help is appreciated. Julian -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com
DateTimeField and setOutputMarkupId()
We have a need to update a DateTimeField via Ajax, but its fields are private, and they don't have setOutputMarkupId() set on them. The result is an exception upon Ajax update. Is there any solution other than cloning and owning DateTimeField? We are using Wicket 1.4.17 (and we can't upgrade to 1.5 just yet). Any help is appreciated. Julian
Re: DateTimeField and setOutputMarkupId()
Igor, We do update the DateTimeField itself, and this is what we see: SEVERE: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] java.lang.IllegalArgumentException: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] at org.apache.wicket.ajax.AjaxRequestTarget.addComponent(AjaxRequestTarget.java:346) Julian On Thu, Jul 21, 2011 at 11:02 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: cant update the DateTimeField itself? -igor On Thu, Jul 21, 2011 at 10:57 AM, Julian Sinai jsi...@gmail.com wrote: We have a need to update a DateTimeField via Ajax, but its fields are private, and they don't have setOutputMarkupId() set on them. The result is an exception upon Ajax update. Is there any solution other than cloning and owning DateTimeField? We are using Wicket 1.4.17 (and we can't upgrade to 1.5 just yet). Any help is appreciated. Julian
Re: DateTimeField and setOutputMarkupId()
It is the hours component of the DateTimeField. From DateTimeField.html: input type=text wicket:id=hours size=2 /nbsp;: Julian On Thu, Jul 21, 2011 at 11:24 AM, Igor Vaynberg igor.vaynb...@gmail.comwrote: what is hours ? -igor On Thu, Jul 21, 2011 at 11:17 AM, Julian Sinai jsi...@gmail.com wrote: Igor, We do update the DateTimeField itself, and this is what we see: SEVERE: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] java.lang.IllegalArgumentException: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] at org.apache.wicket.ajax.AjaxRequestTarget.addComponent(AjaxRequestTarget.java:346) Julian On Thu, Jul 21, 2011 at 11:02 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote: cant update the DateTimeField itself? -igor On Thu, Jul 21, 2011 at 10:57 AM, Julian Sinai jsi...@gmail.com wrote: We have a need to update a DateTimeField via Ajax, but its fields are private, and they don't have setOutputMarkupId() set on them. The result is an exception upon Ajax update. Is there any solution other than cloning and owning DateTimeField? We are using Wicket 1.4.17 (and we can't upgrade to 1.5 just yet). Any help is appreciated. Julian
Re: DateTimeField and setOutputMarkupId()
Nothing is adding it, we add the DateTimeField itself to the target. Julian On Thu, Jul 21, 2011 at 12:08 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote: what is adding that to the target? -igor On Thu, Jul 21, 2011 at 12:07 PM, Julian Sinai jsi...@gmail.com wrote: It is the hours component of the DateTimeField. From DateTimeField.html: input type=text wicket:id=hours size=2 /nbsp;: Julian On Thu, Jul 21, 2011 at 11:24 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote: what is hours ? -igor On Thu, Jul 21, 2011 at 11:17 AM, Julian Sinai jsi...@gmail.com wrote: Igor, We do update the DateTimeField itself, and this is what we see: SEVERE: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] java.lang.IllegalArgumentException: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] at org.apache.wicket.ajax.AjaxRequestTarget.addComponent(AjaxRequestTarget.java:346) Julian On Thu, Jul 21, 2011 at 11:02 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote: cant update the DateTimeField itself? -igor On Thu, Jul 21, 2011 at 10:57 AM, Julian Sinai jsi...@gmail.com wrote: We have a need to update a DateTimeField via Ajax, but its fields are private, and they don't have setOutputMarkupId() set on them. The result is an exception upon Ajax update. Is there any solution other than cloning and owning DateTimeField? We are using Wicket 1.4.17 (and we can't upgrade to 1.5 just yet). Any help is appreciated. Julian
Re: DateTimeField and setOutputMarkupId()
Hi Martin Thanks for looking at this. It's a bit complicated because we've built a form framework around Wicket, but here goes: In the page: HtFormPanel.DateFormField startField = new HtFormPanel.DateFormField(startField, new StringResourceModel(start, this, null), new PropertyModelDate(this, start), false); Where the constructor for HtFormPanel.DateFormField is: public DateFormField(String uniqueId, IModelString label, IModel m, boolean bShowTime) { // The DateTimeField is contained within the DateFormField super(uniqueId, FieldType.DATETEXTFIELD.toString(), (bShowTime ? new DateTimeField(FIELD_ID) : new DateField(FIELD_ID)), label, m); } Next, in the page: startField.setFieldOutputMarkupId(true); // The radio button that does the ajax update: final HtFormPanel.RadioFormFieldReportAction actionField = new HtFormPanel.RadioFormFieldReportAction( actionField,new ResourceModel(actionField),actionTypes,new LocalizedChoiceRendererReportAction(this), new PropertyModelReportAction(this,action)); Finally, the update code that causes the problem: actionField.getFormComponent().add( new HtAjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = 8574977146235850631L; protected void onUpdate(AjaxRequestTarget target) { if (getAction() != null getAction().equals(ReportAction.VIEW)) { startField.setRequired(false); } else { startField.setRequired(true); } // We update the startField and the DateTimeField inside it. target.addComponent(startField); target.addComponent(startField.getComponent()); } }); Julian On Thu, Jul 21, 2011 at 12:30 PM, Martin Grigorov mgrigo...@apache.orgwrote: Show some code. On Thu, Jul 21, 2011 at 10:09 PM, Julian Sinai jsi...@gmail.com wrote: Nothing is adding it, we add the DateTimeField itself to the target. Julian On Thu, Jul 21, 2011 at 12:08 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote: what is adding that to the target? -igor On Thu, Jul 21, 2011 at 12:07 PM, Julian Sinai jsi...@gmail.com wrote: It is the hours component of the DateTimeField. From DateTimeField.html: input type=text wicket:id=hours size=2 /nbsp;: Julian On Thu, Jul 21, 2011 at 11:24 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote: what is hours ? -igor On Thu, Jul 21, 2011 at 11:17 AM, Julian Sinai jsi...@gmail.com wrote: Igor, We do update the DateTimeField itself, and this is what we see: SEVERE: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] java.lang.IllegalArgumentException: cannot update component that does not have setOutputMarkupId property set to true. Component: [MarkupContainer [Component id = hours]] at org.apache.wicket.ajax.AjaxRequestTarget.addComponent(AjaxRequestTarget.java:346) Julian On Thu, Jul 21, 2011 at 11:02 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote: cant update the DateTimeField itself? -igor On Thu, Jul 21, 2011 at 10:57 AM, Julian Sinai jsi...@gmail.com wrote: We have a need to update a DateTimeField via Ajax, but its fields are private, and they don't have setOutputMarkupId() set on them. The result is an exception upon Ajax update. Is there any solution other than cloning and owning DateTimeField? We are using Wicket 1.4.17 (and we can't upgrade to 1.5 just yet). Any help is appreciated. Julian -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com
OutputStreams and Panels
I am using the BIRT Report Engine API. It generates html that I want to display in a Panel or a WebMarkupContainer. The API requires me to hand it a java.io.OutputStream, which it then writes to. How do I obtain a stream from Wicket in a way that the BIRT output can be inserted in my Panel? Any help is appreciated. Julian
ModalWindow form, autocomplete, and default button.
Hi, I'm having some trouble with modal forms. As advised by Matej in this post: http://markmail.org/thread/kmrsg2kvywpyf5dh, I am nesting my modal form inside another form. That works fine, but I now have two other problems: because Form.onComponentTag() rewrites my inner form tag as a div, my autocomplete=off attribute has no effect, and the default button that I set has no effect. How can I fix these two things? I'm using Wicket 1.4.0. If someone can help, I'd appreciate it. Thanks, Julian
AutoCompleteTextField stops showing completions
I'm having trouble with AutoCompleteTextField. It works great most of the time, but occasionally the autocompletions won't show up. This seems to be more of a problem on Safari and IE6. It happens either when the page first renders, or after clicking OK to take action based on the user's selection (there's an ajax button next to my AutoCompleteTextField). I've tried manually reinitializing the autocomplete JS code by calling target.appendJavascript(initialize()). I've also tried re-rendering the AutoCompleteTextField using target.addComponent(field). None of these techniques work. I'm using Wicket 1.4.0. If someone can help, I'd appreciate it. Thanks, Julian
CheckGroup and AjaxPagingNavigator
I'm having trouble with my usage of CheckGroup and AjaxPagingNavigator. If the user checks one or more checkboxes on one page of my data table, then navigates to the next page, the choices on the first page are forgotten. In my application, they need to be remembered. This was not a problem before I switched to Ajax paging navigation. If someone can help, I'd appreciate it. Thanks, Julian More detail: I'm using the DataView/IDataProvider pattern for my data table. I'm using CheckGroup, Check, and CheckGroupSelector for the checkboxes in my data table. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Defer call to preDecorateScript() till onSubmit() is called?
Hi, I need to display a confirmation message to the user before submitting a form. It's pretty standard to use the code below when the message is known at the time of button or link construction. But what about when the message must be synthesized at the time of the button click? I've tried using a model, but that didn't help. I would appreciate any help. Thanks, Julian @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return new AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator()) { @Override public CharSequence preDecorateScript(CharSequence script) { return if(!confirm(' + message + ')) return false; + script; } }; } - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org