Wicket
  1. Wicket
  2. WICKET-4404

CryptoMapper is not successfully decoding AbstractDefaultAjaxBehavior.generateCallbackScript request

    Details

      Description

      I have a yui menu wrapper that I have written that does not work when the cryptomapper is being used. It works fine otherwise. It basically outputs javascript in the header and that javascript renders the dom elements. So the only wicket component is a div that represents the menu. All of the items get generated by the javascript. One of the attributes on the menu item is a "url" attribute. In the url attribute I have "javascript: " and then the javascript string that is created via the generateCallbackScript method. The respond method never gets called if the cryptomapper is enabled.

      1. HomePageSource.txt
        6 kB
        Josh Chappelle
      2. wicket_cryptomapper_quickstart.zip
        1.19 MB
        Josh Chappelle

        Activity

        Hide
        Martin Grigorov added a comment -

        I cannot run your quickstart.
        There is a JavaScript error:
        Uncaught Error: HIERARCHY_REQUEST_ERR: DOM Exception 3
        g._addToParentcontainer_core-min-ver-1326296648000.js:9
        rcontainer_core-min-ver-1326296648000.js:9
        g.rendercontainer_core-min-ver-1326296648000.js:9
        (anonymous function):8080/?0:13
        Wicket.Event.fireDomReadyHandlerswicket-event-ver-1328860748000.js:170
        (anonymous function)wicket-event-ver-1328860748000.js:191
        domCheck

        Clicking the link works OK but the HTML for the menu is just:
        <div wicket:id="menu" id="menu1" class="yui-module yui-overlay yuimenubar"></div>
        i.e. there is nothing to click.

        Show
        Martin Grigorov added a comment - I cannot run your quickstart. There is a JavaScript error: Uncaught Error: HIERARCHY_REQUEST_ERR: DOM Exception 3 g._addToParentcontainer_core-min-ver-1326296648000.js:9 rcontainer_core-min-ver-1326296648000.js:9 g.rendercontainer_core-min-ver-1326296648000.js:9 (anonymous function):8080/?0:13 Wicket.Event.fireDomReadyHandlerswicket-event-ver-1328860748000.js:170 (anonymous function)wicket-event-ver-1328860748000.js:191 domCheck Clicking the link works OK but the HTML for the menu is just: <div wicket:id="menu" id="menu1" class="yui-module yui-overlay yuimenubar"></div> i.e. there is nothing to click.
        Hide
        Josh Chappelle added a comment -

        Hmm, I'll unzip and see if I can reproduce. I will say that I only tested in IE9. I'm not sure if that's the browser you were using.

        I'll see if I can run it down and repost.

        Show
        Josh Chappelle added a comment - Hmm, I'll unzip and see if I can reproduce. I will say that I only tested in IE9. I'm not sure if that's the browser you were using. I'll see if I can run it down and repost.
        Hide
        Josh Chappelle added a comment - - edited

        I just unzipped the wicket_cryptomapper_quickstart.zip and imported the project into eclipse. When I pull it up in IE9 it renders the page fine. When I click the link titled "Yui menu link" it does nothing. I don't see any javascript errors either. I have put a debug point in CryptoMapper and I know that mapRequest() is getting called. In fact, I see that it gets two requests(the other link does this as well, I assume it is a wicket internal thing and must be normal). In the mapRequest there is a decryptUrl method that gets called. Here is the returned value of decryptUrl for each link for each request.

        YUI Menu Link Request 1:
        ?0-1.IBehaviorListener.0-menu

        YUI Menu Link Request 2:
        ?0

        Regular Ajax Link Request 1:
        ?0-3.IBehaviorListener.0-link

        Regular Ajax Link Request 2:
        wicket/bookmarkable/com.test.wicket.DestinationPage

        I hope you can get the quickstart to work for you. I've run down as much of this thing as I know to do. The only reason I am using the "homemade" yui menu instead of the wicketstuff version is that we were hitting some bugs with it and I couldn't really get any support from the community on it.

        Also, this worked in wicket 1.4.x.

        Thanks for the help.

        Josh

        Show
        Josh Chappelle added a comment - - edited I just unzipped the wicket_cryptomapper_quickstart.zip and imported the project into eclipse. When I pull it up in IE9 it renders the page fine. When I click the link titled "Yui menu link" it does nothing. I don't see any javascript errors either. I have put a debug point in CryptoMapper and I know that mapRequest() is getting called. In fact, I see that it gets two requests(the other link does this as well, I assume it is a wicket internal thing and must be normal). In the mapRequest there is a decryptUrl method that gets called. Here is the returned value of decryptUrl for each link for each request. YUI Menu Link Request 1: ?0-1.IBehaviorListener.0-menu YUI Menu Link Request 2: ?0 Regular Ajax Link Request 1: ?0-3.IBehaviorListener.0-link Regular Ajax Link Request 2: wicket/bookmarkable/com.test.wicket.DestinationPage I hope you can get the quickstart to work for you. I've run down as much of this thing as I know to do. The only reason I am using the "homemade" yui menu instead of the wicketstuff version is that we were hitting some bugs with it and I couldn't really get any support from the community on it. Also, this worked in wicket 1.4.x. Thanks for the help. Josh
        Hide
        Martin Grigorov added a comment -

        Can you minimize the quickstart even more ? Cut the YUI stuff. Just leave your ajax behavior + crypto mapper.

        Show
        Martin Grigorov added a comment - Can you minimize the quickstart even more ? Cut the YUI stuff. Just leave your ajax behavior + crypto mapper.
        Hide
        Josh Chappelle added a comment -

        I made a good attempt to but I can't accurately depict the problem without including the YUI stuff because it creates DOM elements on the fly. I would probably have to write more javascript than I know how to. I know that would seem like the problem must lie in the YUI stuff but from what I can tell the YUI stuff is calling wicket and the cryptomapper is failing to decrypt the request.

        Show
        Josh Chappelle added a comment - I made a good attempt to but I can't accurately depict the problem without including the YUI stuff because it creates DOM elements on the fly. I would probably have to write more javascript than I know how to. I know that would seem like the problem must lie in the YUI stuff but from what I can tell the YUI stuff is calling wicket and the cryptomapper is failing to decrypt the request.
        Hide
        Josh Chappelle added a comment -

        I attached the source of what the rendered HomePage looks like. I don't know if this will help but I figured I would go ahead and post it.

        One thing I have noticed in the javascript that renders using the generatecallbackscript is that jsessionid is in there and in plain text. Could that somehow be throwing off the decryption? I noticed the AjaxLink doesn't render it's callback that way.

        Show
        Josh Chappelle added a comment - I attached the source of what the rendered HomePage looks like. I don't know if this will help but I figured I would go ahead and post it. One thing I have noticed in the javascript that renders using the generatecallbackscript is that jsessionid is in there and in plain text. Could that somehow be throwing off the decryption? I noticed the AjaxLink doesn't render it's callback that way.
        Hide
        Martin Grigorov added a comment -

        Sorry, I cannot run this quickstart.
        Just tried it again with Firefox 10 and no menu is being shown. just the link. The error in console is: Node cannot be inserted at the specified point in the hierarchy.
        In Chrome 19 the error is: HIERARCHY_REQUEST_ERR: DOM Exception 3.

        Show
        Martin Grigorov added a comment - Sorry, I cannot run this quickstart. Just tried it again with Firefox 10 and no menu is being shown. just the link. The error in console is: Node cannot be inserted at the specified point in the hierarchy. In Chrome 19 the error is: HIERARCHY_REQUEST_ERR: DOM Exception 3.
        Hide
        Sven Meier added a comment -

        Same problem here, I cannot run the quickstart

        Show
        Sven Meier added a comment - Same problem here, I cannot run the quickstart
        Hide
        Martin Grigorov added a comment -

        I reproduced it by extracting the generated urls manually from the generated html.
        The problem is that you keep the generated callback url to the behavior in a String instance (i.e. you cache it) at com.test.wicket.menu.yui.YuiMenuBarItem#setUrl().

        Initially the page is rendered for the home page url (i.e. '/') and at this time you cache the generated url. Then Wicket sees that this is a stateful page (its url needs the page id - ?0) and needs to regenerate the page html, but since you keep the url as a member which is rendered manually at com.test.wicket.menu.yui.YuiMenuBarItem#toJavascript() the url is not regenerated. Later when you request this url Wicket sees that it is stale and re-renders the whole page.

        I suggest you to create a Link-like Wicket component that generates its url (javascript:....) whenever asked by Wicket (i.e. when #onComponentTag() is called). This way it will have the correct url.

        Show
        Martin Grigorov added a comment - I reproduced it by extracting the generated urls manually from the generated html. The problem is that you keep the generated callback url to the behavior in a String instance (i.e. you cache it) at com.test.wicket.menu.yui.YuiMenuBarItem#setUrl(). Initially the page is rendered for the home page url (i.e. '/') and at this time you cache the generated url. Then Wicket sees that this is a stateful page (its url needs the page id - ?0) and needs to regenerate the page html, but since you keep the url as a member which is rendered manually at com.test.wicket.menu.yui.YuiMenuBarItem#toJavascript() the url is not regenerated. Later when you request this url Wicket sees that it is stale and re-renders the whole page. I suggest you to create a Link-like Wicket component that generates its url (javascript:....) whenever asked by Wicket (i.e. when #onComponentTag() is called). This way it will have the correct url.
        Hide
        Josh Chappelle added a comment -

        I'm trying to prevent having markup that backs the menu items. After your comment I made a change to call setUrl in the onComponentTag of my behavior. Then after the javascript gets generated I call setUrl(null) on the menu items. However, I still get the same issue.

        I kind of follow what you are saying about the stateless stuff. But why would it work when cryptomapper is not being used? It seems like from what you described that it wouldn't work either way.

        Show
        Josh Chappelle added a comment - I'm trying to prevent having markup that backs the menu items. After your comment I made a change to call setUrl in the onComponentTag of my behavior. Then after the javascript gets generated I call setUrl(null) on the menu items. However, I still get the same issue. I kind of follow what you are saying about the stateless stuff. But why would it work when cryptomapper is not being used? It seems like from what you described that it wouldn't work either way.

          People

          • Assignee:
            Unassigned
            Reporter:
            Josh Chappelle
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development