Alright, I got this to work in a clean way.

The problem was that the QTip jQuery plugin *cloned* the panel / form.
This was causing trouble for the form submission. Simply adding a
.remove() which removed the original DOM tree fixed the issue.

I ended up with replacing
.append("               content: $('#" + contentMarkupId + "').html(),")

by
.append("               content: $('#" + contentMarkupId + "').remove(),")


and now everything works as a charm.


Antoine.


On Wed, Mar 10, 2010 at 6:04 PM, Antoine van Wel
<[email protected]> wrote:
> Turns out "Wicket.$$(this)" returned false after all. Thanks Richard!
>
> I ended up adapting the AjaxButton by simply kicking out the
> Wicket.$$(this) of the pre-condition check.
>
> So can anybody tell me what this "Wicket.$$(this)" is good for ... I
> got a gut-feeling what I've done is not such a good idea :-)
>
>
> Antoine
>
>
> On Tue, Mar 9, 2010 at 6:44 PM, Antoine van Wel
> <[email protected]> wrote:
>> Hi Richard,
>>
>> Thanks for the reply. It didn't bring me further though.
>> When debugging, Wicket.$$(this) and the other one both return true, so
>> that doesn't seem to be the problem.
>>
>> When tracking the evaluation of the precondition, I end up in wicket-event.js
>>
>> 25 if (Function.prototype.bind == null) {
>> 26 Function.prototype.bind = function(object) {
>> 27 var __method = this;
>> 28 return function() {
>> 29 return __method.apply(object, arguments);
>> 30 }
>> 31 }
>> 32}
>>
>> where line 29 will return false.
>> Does that ring any bells?
>>
>>
>> By the way, in the code I copied-and-pasted in my previous email, two
>> lines were not included which needs to be there:
>> setOutputMarkupId(true) on parent & content components.
>>
>>
>> Antoine
>>
>> On Tue, Mar 9, 2010 at 4:37 PM, Richard Wilkinson
>> <[email protected]> wrote:
>>> Hi,
>>>
>>> 'Ajax POST stopped because of precondition check' is probably your
>>> problem.  all wicket ajax can have a precondition, which is basically
>>> a function that returns true or false, and will only execute the ajax
>>> if it returns true.  I expect that for some reason in your case this
>>> function is returning false.
>>>
>>> for an AjaxButton (well AjaxFormSubmitBehavior) the precondition is
>>> this: "return Wicket.$$(this)&&Wicket.$$('" + getForm().getMarkupId()
>>> + "')";
>>>
>>> in the wicket ajax javascript file i see this:
>>>
>>> // returns if the element belongs to current document
>>> // if the argument is not element, function returns true
>>> Wicket.$$ = function(element) {
>>> .......
>>> }
>>>
>>> This must be failing for you, which I presume has something to do with
>>> how you are passing the content into the qtip;
>>>
>>> content: $('#" + contentMarkupId + "').html()
>>>
>>> Hope that helps.
>>>
>>> --
>>> Regards - Richard Wilkinson
>>> Developer,
>>> jWeekend: OO & Java Technologies - Development and Training
>>> http://jWeekend.com
>>>
>>>
>>> On 9 March 2010 13:05, Antoine van Wel <[email protected]> wrote:
>>>> Hi everybody,
>>>>
>>>> Integrating a Jquery tooltip (qtip) went smoothly until I tried to do
>>>> an Ajax form submit.
>>>> The Wicket Ajax Debug panel shows an "Ajax POST stopped because of
>>>> precondition check", so an Ajax response is never sent.
>>>>
>>>> What I'm doing is simply render the text for the tooltip on the same
>>>> page in a hidden div, then pointing the content of the tooltip to that
>>>> div.
>>>>
>>>> the html:
>>>>
>>>> <wicket:head>
>>>>        <script type="text/javascript" 
>>>> src="/js/jquery-1.3.2.min.js"></script>
>>>>        <script type="text/javascript" 
>>>> src="/js/jquery.qtip-1.0.0-rc3.min.js"></script>
>>>> </wicket:head>
>>>>
>>>> <wicket:extend>
>>>>        <div wicket:id="content" style="display: none;">
>>>>                <form wicket:id="form">
>>>>                        <input type="submit" wicket:id="clickme" 
>>>> value="click me">
>>>>                </form>
>>>>        </div>
>>>>
>>>>        <span wicket:id="tipme">hover over me</span>
>>>> </wicket:extend>
>>>>
>>>> the page class:
>>>>
>>>> public class JQueryTestPage extends BasePage {
>>>>        public JQueryTestPage() {
>>>>                WebMarkupContainer content = new 
>>>> WebMarkupContainer("content");
>>>>                add(content);
>>>>
>>>>                Form<Void> form = new Form<Void>("form");
>>>>                content.add(form);
>>>>                form.add(new AjaxButton("clickme") {
>>>>                       �...@override
>>>>                        protected void onSubmit(AjaxRequestTarget target, 
>>>> Form<?> form) {
>>>>                                System.out.println("testing");
>>>>                        }
>>>>
>>>>                });
>>>>
>>>>                WebMarkupContainer qtip = new WebMarkupContainer("tipme");
>>>>                add(qtip);
>>>>                qtip.add(new QTipBehavior(qtip, content));
>>>>        }
>>>>
>>>> }
>>>>
>>>>
>>>> and finally the QTipBehavior:
>>>>
>>>> public class QTipBehavior extends AbstractBehavior {
>>>>        private String componentMarkupId;
>>>>        private String contentMarkupId;
>>>>
>>>>        public QTipBehavior(Component parent, Component content) {
>>>>                contentMarkupId = content.getMarkupId();
>>>>                componentMarkupId = parent.getMarkupId();
>>>>        }
>>>>
>>>>       �...@override
>>>>        public void renderHead(IHeaderResponse response) {
>>>>                String javascript = new StringBuilder()
>>>>                        .append("$(function() {")
>>>>                        .append("       $('#" + componentMarkupId + 
>>>> "').qtip({")
>>>>                        .append("               content: $('#" + 
>>>> contentMarkupId + "').html(),")
>>>>                        .append("               hide: { fixed: true },")
>>>>                        .append("               position: { corner: { 
>>>> target: 'topRight', tooltip:
>>>> 'leftTop' } },")
>>>>                        .append("       })")
>>>>                        .append("});")
>>>>                        .toString();
>>>>                response.renderOnDomReadyJavascript(javascript);
>>>>        }
>>>> }
>>>>
>>>>
>>>> All pretty straightforward.
>>>>
>>>> So my guess is somehow Wicket is not happy about the redirection I
>>>> created by not using the rendered button directly.
>>>> I've been trying to debug this using Firebug, obviously without success.
>>>>
>>>> Does anybody have any hints how to solve this? Is the approach I'm
>>>> taking flawed? Maybe jWicket or wiQuery could help here?
>>>>
>>>>
>>>>
>>>> Antoine
>



-- 
take your photos everywhere you go - https://www.memolio.com
follow us on Twitter - http://twitter.com/Memolio

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to