You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Kurt Sys <ku...@gmail.com> on 2011/07/02 16:16:40 UTC

ajax GET stopped because of precondition check

Hey all,

In IE, I can't get lazyloadpanels to load. I have a webapp with some
lazyloadpanels, and none of them loads in IE - in other browsers, there is
no problem. (Also, the content of an iframe doesn't load, which seems to be
related, since it is also an ajax-request.) I've been trying both IE 8 and
IE 9 on three different pc's. Can someone give me a clue why it won't work
in IE? (IE security settings are set to low, scripts etc are
enabled/allowed, so I suppose ajax-requests can be performed... if not, I
have no clue how to allow ajax in IE.) You may check it out:
http://www.tinyleaps.be

I've been checking on similar problems with lazyloadpanel in ie, and the
problem was known in 2008 (if it's the same, but it looks really similar):
http://www.mail-archive.com/users@wicket.apache.org/msg18815.html
There seems to be a bug report and a 'fixed' status, although it doesn't
seem to work out fine for me - the last comment states that the fix is not
confirmed. Or I am  missing something, which wouldn't really surprise me :),
or there still something wrong with the precondition stuff and loading the
panel in IE:
https://issues.apache.org/jira/browse/WICKET-1653


Ajax debug window (only these three lines):
--
INFO: Ajax GET stopped because of precondition check,
url:?wicket:interface=:3:mainpanel:bloglist:1:commentaar::IBehaviorListener:0:
INFO: Ajax GET stopped because of precondition check,
url:?wicket:interface=:3:mainpanel:bloglist:2:commentaar::IBehaviorListener:0:
INFO: Ajax GET stopped because of precondition check,
url:?wicket:interface=:3:weer::IBehaviorListener:0:
--

HomePage.html:
--
[...]
<body>
<wicket:extend>
[...]
      <div wicket:id="route" />
[...]
            <div wicket:id="mainpanel" />
[...]
            <div wicket:id="weer" class="weer" >&nbsp;
            </div>
[...]
      </div>
</wicket:extend>
</body>
</html>
--

HomePage.java:
--
[...]

public class HomePage
      extends BasePage {

   Panel mainPanel;
   Label linktekst;


   public HomePage() {
      this(null);
   }


   public HomePage(PageParameters pars) {
[...]
      add(new RoutePanel("route"));


      if (pars != null) {
         mainPanel = new BlogPanel("mainpanel", pars.getAsInteger("id"));
      }
      else {
         mainPanel = new BlogPanel("mainpanel");
      }

      add(mainPanel);
[...]
      add(new AjaxLazyLoadPanel("weer") {

         @Override
         public Component getLazyLoadComponent(String markupId) {
            return new WeerPanel(markupId,
reis.getBlogitemList().get(0).getLocation().getName());
         }

      });
   }

}
--

BlogPanel.html
--
[...]
      <wicket:panel>
[...]
         <ul class="bloglist">
            <li wicket:id="bloglist" class="blogitem">
[...]
                   <div wicket:id="commentaar" />
                     </div>
[...]
            </li>
         </ul>
[...]
      </wicket:panel>
   </body>
</html>
--

BlogPanel.java:
--
[...]
public final class BlogPanel
      extends Panel {

   private static final int ITEMSPERPAGE = 3;

   public BlogPanel(String id) {
      this(id, 0);
   }


   public BlogPanel(final String id, final int blogid) {
      super(id);

      setOutputMarkupId(true);

[...]
      List<Blogitem> blogitemList =
            Q.EM.createNamedQuery("Blogitem.findAll", Blogitem.class).
            setHint(QueryHints.REFRESH, HintValues.TRUE).getResultList();

      BlogListView blogListView = new BlogListView(
            "bloglist",
            new ListDataProvider(blogitemList),
            ITEMSPERPAGE) {

         @Override
         protected void populateItem(final Item<Blogitem> item) {

[...]
            item.add(new AjaxLazyLoadPanel("commentaar") {

               @Override
               public Component getLazyLoadComponent(String markupId) {
                  return new CommentaarPanel(markupId,
item.getModelObject());
               }

            });
[...]
         }

      };

[...]
      add(blogListView);

[...]
}

abstract class BlogListView
      extends DataView<Blogitem> {

   BlogListView(String id, ListDataProvider ldp, int i) {
      super(id, ldp, i);
   }

[...]
   }
}
--

CommentaarPanel.html:
--
[...]
   <body>
      <wicket:panel>
         <div wicket:id="commentaarToevoegen" />
         <ul>
            <li wicket:id="commentaarList" class="commentaar">
               <p class="zegt"><span wicket:id="tijdstip" /> - <span
wicket:id="commentator" class="schrift commentator" /> laat weten:</p>
               <p wicket:id="tekst" class="schrift" />
            </li>
            <div wicket:id="commentaarNav" class="navigator navigatordown"
/>
         </ul>
      </wicket:panel>
   </body>
</html>
--

CommentaarPanel.java:
--
[...]
public final class CommentaarPanel
      extends Panel {

   private Blogitem blog;
   private List<Comment> commentList;
   private DataView<Comment> commentListView;


   public CommentaarPanel(String id, Blogitem blog) {
      super(id);

      this.blog = blog;

      setOutputMarkupId(true);

      commentList = blog.getCommentList();
      Collections.sort(commentList);
      commentListView =
            new DataView<Comment>("commentaarList",
                                  new ListDataProvider(commentList),
                                  5) {

               @Override
               protected void populateItem(Item<Comment> item) {
                  item.add(new Label("tekst",
item.getModelObject().getText()));
                  item.add(new Label("commentator",
item.getModelObject().getName()));
                  item.add(new Label("tijdstip",
Q.DF.format(item.getModelObject().getTimestamp())));
               }

            };
      add(commentListView);
      add(new AjaxPagingNavigator("commentaarNav", commentListView) {

         @Override
         public boolean isVisible() {
            return this.getPageable().getPageCount() > 1;
         }

      });
      add(new CommentaarToevoegenPanel("commentaarToevoegen", this));
   }


   public Blogitem getBlog() {
      return blog;
   }


   public List<Comment> getCommentList() {
      return commentList;
   }


   public DataView<Comment> getCommentListView() {
      return commentListView;
   }

}
--


WeerPanel.html:
--
[...]
   <body>
      <wicket:panel>
         <span wicket:id="locatie" /><br />
         <img wicket:id="icoonhuidig" class="weericoon" />
         <p>temperatuur: <span wicket:id="temperatuur" />&deg;C<br />
         vochtigheid: <span wicket:id="vochtigheid" /><br />
         wind: <span wicket:id="wind" /></p>
      </wicket:panel>
   </body>
</html>
--

WeerPanel.java:
--
[...]
public final class WeerPanel
      extends Panel {

   private String locatie;

   public WeerPanel(String id, String locatie) {
      super(id);
      this.locatie = locatie;
      init();
   }


   public WeerPanel(String id) {
      this(id, "Brugge");
   }


   private void init() {
      Document doc = null;
      {
         InputStream in = null;
         try {
            URL xmlUrl = new URL("http://www.google.com/ig/api?weather=" +
locatie);
            in = xmlUrl.openStream();
            doc = parse(in);
         }
         catch (MalformedURLException ex) {
            Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
null, ex);
         }
         catch (IOException ex) {
            Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
null, ex);
         }
         finally {
            if (in != null) {
               try {
                  in.close();
               }
               catch (IOException ex) {

Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE, null, ex);
               }
            }
         }
      }

      String locatieString = "<ongekend>";
      String srcicon = "http://www.google.com";
      String temperatuur = "<?>";
      String vochtigheid = "<?>";
      String wind = "<?>";

      if (doc != null) {
         locatieString =

 doc.getElementsByTagName("city").item(0).getAttributes().getNamedItem("data").getNodeValue();
         NodeList nl =
doc.getElementsByTagName("current_conditions").item(0).getChildNodes();
         for (int i = 0; i < nl.getLength(); i++) {
            Node n = nl.item(i);
            if (n.getNodeName().equals("icon")) {
               srcicon +=
n.getAttributes().getNamedItem("data").getNodeValue();
            }
            else if (n.getNodeName().equals("temp_c")) {
               temperatuur =
n.getAttributes().getNamedItem("data").getNodeValue();
            }
            else if (n.getNodeName().equals("humidity")) {
               vochtigheid =
n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
            }
            else if (n.getNodeName().equals("wind_condition")) {
               wind =
n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
            }
         }
      }

      add(new Label("locatie", locatieString));
      add(new StaticImage("icoonhuidig", srcicon));
      Label temperatuurLabel = new Label("temperatuur", temperatuur);
      temperatuurLabel.setRenderBodyOnly(true);
      add(temperatuurLabel);
      Label vochtigheidLabel = new Label("vochtigheid", vochtigheid);
      vochtigheidLabel.setRenderBodyOnly(true);
      add(vochtigheidLabel);
      Label windLabel = new Label("wind", wind);
      windLabel.setRenderBodyOnly(true);
      add(windLabel);

   }


   public static Document parse(InputStream is) {
      Document ret = null;
      DocumentBuilderFactory domFactory;
      DocumentBuilder builder;

      try {
         domFactory = DocumentBuilderFactory.newInstance();
         domFactory.setValidating(false);
         domFactory.setNamespaceAware(false);
         builder = domFactory.newDocumentBuilder();

         ret = builder.parse(is);
      }
      catch (Exception ex) {
         System.err.println("unable to load XML: " + ex);
      }
      return ret;
   }

}
--

Re: ajax GET stopped because of precondition check

Posted by Martin Grigorov <mg...@apache.org>.
For most of the Ajax requests is used GET method.
For ajax form submit for example is used POST.

You can check the used method and the headers with Firebug in Firefox.
IE may add/remove some header but the method and the url should be the
same as in FF.

On Wed, Jul 6, 2011 at 12:34 PM, Kurt Sys <ku...@gmail.com> wrote:
> It only worked once in IE (checked only on 1 pc). So, probably a caching
> problem of IE?
>
> I suppose the ajax-requests of wicket are 'GET'-requests and there is no
> timestamp or something variable added to the response, or is there? Anyway,
> the only thing I can think of so far is caching of ajax-requests somewhere
> in IE, so:
> http://www.codemiles.com/ajax/solution-to-ajax-cache-problem-with-internet-explorer-t602.html
> http://www.codecouch.com/2009/01/how-to-stop-internet-explorer-from-caching-ajax-requests/
> http://weblogs.asp.net/pleloup/archive/2006/06/08/451583.aspx
> (and many more of these kind of solutions).
> I remember: add some headers to the response. Question now is: how to
> customize the response of an ajax-request? Or is there any other solution to
> the caching of IE?  (In case caching is the problem here).
>
> Thx, Kurt
>
> 2011/7/6 Kurt Sys <ku...@gmail.com>
>
>> Well, I got a new hosting, and for some reason, it seems to work in IE now,
>> except for the iframe. Nothing is loaded in the iframe so far. That'll be a
>> IE issue, so I suppose this thread may be closed.
>>
>>
>> 2011/7/5 Kurt Sys <ku...@gmail.com>
>>
>>> I found this thread:
>>>
>>> http://apache-wicket.1842946.n4.nabble.com/Wicket-1-4m3-AjaxButton-AjaxSubmitLink-in-ModalWindow-in-IE-7-Problem-td1893357.html
>>> So I checked all wicket:ids, and none of them has a value of 'id' or
>>> 'submit' or something similar. IE still fails to load the panels...
>>>
>>>
>>> 2011/7/3 Kurt Sys <ku...@gmail.com>
>>>
>>>> The lazy loading example seems to work fine (I tried Wicket 1.4.17, the
>>>> one I'm using too).
>>>>
>>>> For some reason 'precondition()' returns false in IE when called from my
>>>> app. The code loading the panels is really straight forward. I can't think
>>>> of any reason (for now) why the precondition returns false, only in IE, and
>>>> even not for all lazyloadpanels.
>>>> I have actually no idea where precondition is changed or something - I
>>>> checked the js file (wicket-ajax.js) and there the function of the prototype
>>>> just returns true (see below). So, precondition it is changed somewhere, for
>>>> some reason, and probably something in a javascript-file of wicket that is
>>>> called from my code IE doesn't like (other browsers don't complain). What
>>>> code can be wrong? Something 'wrong' in the html-files? Style files (which
>>>> would be very odd, if you ask me)?
>>>>
>>>> --
>>>>
>>>> Wicket.Ajax.Request.prototype = {
>>>>     // Creates a new request object.        initialize: function(url, loadedCallback, parseResponse, randomURL, failureHandler, channel) {
>>>>             this.url = url;
>>>>             this.loadedCallback = loadedCallback;
>>>>             // whether we should give the loadedCallback parsed response (DOM tree) or the raw string               this.parseResponse = parseResponse != null ? parseResponse : true;
>>>>             this.randomURL = randomURL != null ? randomURL : true;
>>>>             this.failureHandler = failureHandler != null ? failureHandler : function() { };
>>>>             this.async = true;
>>>>             this.channel = channel;
>>>>             this.precondition = function() { return true; } // allow a condition to block request
>>>>             // when suppressDone is set, the loadedCallback is responsible for calling              // Ajax.Request.done() to process possibly pendings requests in the channel.            this.suppressDone = false;
>>>>             this.instance = Math.random();
>>>>             this.debugContent = true;
>>>>     },
>>>> --
>>>>
>>>>
>>>>
>>>>
>>>> 2011/7/3 Martin Grigorov <mg...@apache.org>
>>>>
>>>>> Can you check http://wicketstuff.org/wicket/ajax/lazy-loading ?
>>>>> This is Wicket 1.5-RC5.1 and it works for me with IE8.
>>>>>
>>>>> Wicket 1.4.17 at http://wicketstuff.org/wicket14/ajax/lazy-loading
>>>>>
>>>>> On Sat, Jul 2, 2011 at 5:16 PM, Kurt Sys <ku...@gmail.com> wrote:
>>>>> > Hey all,
>>>>> >
>>>>> > In IE, I can't get lazyloadpanels to load. I have a webapp with some
>>>>> > lazyloadpanels, and none of them loads in IE - in other browsers,
>>>>> there is
>>>>> > no problem. (Also, the content of an iframe doesn't load, which seems
>>>>> to be
>>>>> > related, since it is also an ajax-request.) I've been trying both IE 8
>>>>> and
>>>>> > IE 9 on three different pc's. Can someone give me a clue why it won't
>>>>> work
>>>>> > in IE? (IE security settings are set to low, scripts etc are
>>>>> > enabled/allowed, so I suppose ajax-requests can be performed... if
>>>>> not, I
>>>>> > have no clue how to allow ajax in IE.) You may check it out:
>>>>> > http://www.tinyleaps.be
>>>>> >
>>>>> > I've been checking on similar problems with lazyloadpanel in ie, and
>>>>> the
>>>>> > problem was known in 2008 (if it's the same, but it looks really
>>>>> similar):
>>>>> > http://www.mail-archive.com/users@wicket.apache.org/msg18815.html
>>>>> > There seems to be a bug report and a 'fixed' status, although it
>>>>> doesn't
>>>>> > seem to work out fine for me - the last comment states that the fix is
>>>>> not
>>>>> > confirmed. Or I am  missing something, which wouldn't really surprise
>>>>> me :),
>>>>> > or there still something wrong with the precondition stuff and loading
>>>>> the
>>>>> > panel in IE:
>>>>> > https://issues.apache.org/jira/browse/WICKET-1653
>>>>> >
>>>>> >
>>>>> > Ajax debug window (only these three lines):
>>>>> > --
>>>>> > INFO: Ajax GET stopped because of precondition check,
>>>>> >
>>>>> url:?wicket:interface=:3:mainpanel:bloglist:1:commentaar::IBehaviorListener:0:
>>>>> > INFO: Ajax GET stopped because of precondition check,
>>>>> >
>>>>> url:?wicket:interface=:3:mainpanel:bloglist:2:commentaar::IBehaviorListener:0:
>>>>> > INFO: Ajax GET stopped because of precondition check,
>>>>> > url:?wicket:interface=:3:weer::IBehaviorListener:0:
>>>>> > --
>>>>> >
>>>>> > HomePage.html:
>>>>> > --
>>>>> > [...]
>>>>> > <body>
>>>>> > <wicket:extend>
>>>>> > [...]
>>>>> >      <div wicket:id="route" />
>>>>> > [...]
>>>>> >            <div wicket:id="mainpanel" />
>>>>> > [...]
>>>>> >            <div wicket:id="weer" class="weer" >&nbsp;
>>>>> >            </div>
>>>>> > [...]
>>>>> >      </div>
>>>>> > </wicket:extend>
>>>>> > </body>
>>>>> > </html>
>>>>> > --
>>>>> >
>>>>> > HomePage.java:
>>>>> > --
>>>>> > [...]
>>>>> >
>>>>> > public class HomePage
>>>>> >      extends BasePage {
>>>>> >
>>>>> >   Panel mainPanel;
>>>>> >   Label linktekst;
>>>>> >
>>>>> >
>>>>> >   public HomePage() {
>>>>> >      this(null);
>>>>> >   }
>>>>> >
>>>>> >
>>>>> >   public HomePage(PageParameters pars) {
>>>>> > [...]
>>>>> >      add(new RoutePanel("route"));
>>>>> >
>>>>> >
>>>>> >      if (pars != null) {
>>>>> >         mainPanel = new BlogPanel("mainpanel",
>>>>> pars.getAsInteger("id"));
>>>>> >      }
>>>>> >      else {
>>>>> >         mainPanel = new BlogPanel("mainpanel");
>>>>> >      }
>>>>> >
>>>>> >      add(mainPanel);
>>>>> > [...]
>>>>> >      add(new AjaxLazyLoadPanel("weer") {
>>>>> >
>>>>> >         @Override
>>>>> >         public Component getLazyLoadComponent(String markupId) {
>>>>> >            return new WeerPanel(markupId,
>>>>> > reis.getBlogitemList().get(0).getLocation().getName());
>>>>> >         }
>>>>> >
>>>>> >      });
>>>>> >   }
>>>>> >
>>>>> > }
>>>>> > --
>>>>> >
>>>>> > BlogPanel.html
>>>>> > --
>>>>> > [...]
>>>>> >      <wicket:panel>
>>>>> > [...]
>>>>> >         <ul class="bloglist">
>>>>> >            <li wicket:id="bloglist" class="blogitem">
>>>>> > [...]
>>>>> >                   <div wicket:id="commentaar" />
>>>>> >                     </div>
>>>>> > [...]
>>>>> >            </li>
>>>>> >         </ul>
>>>>> > [...]
>>>>> >      </wicket:panel>
>>>>> >   </body>
>>>>> > </html>
>>>>> > --
>>>>> >
>>>>> > BlogPanel.java:
>>>>> > --
>>>>> > [...]
>>>>> > public final class BlogPanel
>>>>> >      extends Panel {
>>>>> >
>>>>> >   private static final int ITEMSPERPAGE = 3;
>>>>> >
>>>>> >   public BlogPanel(String id) {
>>>>> >      this(id, 0);
>>>>> >   }
>>>>> >
>>>>> >
>>>>> >   public BlogPanel(final String id, final int blogid) {
>>>>> >      super(id);
>>>>> >
>>>>> >      setOutputMarkupId(true);
>>>>> >
>>>>> > [...]
>>>>> >      List<Blogitem> blogitemList =
>>>>> >            Q.EM.createNamedQuery("Blogitem.findAll", Blogitem.class).
>>>>> >            setHint(QueryHints.REFRESH,
>>>>> HintValues.TRUE).getResultList();
>>>>> >
>>>>> >      BlogListView blogListView = new BlogListView(
>>>>> >            "bloglist",
>>>>> >            new ListDataProvider(blogitemList),
>>>>> >            ITEMSPERPAGE) {
>>>>> >
>>>>> >         @Override
>>>>> >         protected void populateItem(final Item<Blogitem> item) {
>>>>> >
>>>>> > [...]
>>>>> >            item.add(new AjaxLazyLoadPanel("commentaar") {
>>>>> >
>>>>> >               @Override
>>>>> >               public Component getLazyLoadComponent(String markupId) {
>>>>> >                  return new CommentaarPanel(markupId,
>>>>> > item.getModelObject());
>>>>> >               }
>>>>> >
>>>>> >            });
>>>>> > [...]
>>>>> >         }
>>>>> >
>>>>> >      };
>>>>> >
>>>>> > [...]
>>>>> >      add(blogListView);
>>>>> >
>>>>> > [...]
>>>>> > }
>>>>> >
>>>>> > abstract class BlogListView
>>>>> >      extends DataView<Blogitem> {
>>>>> >
>>>>> >   BlogListView(String id, ListDataProvider ldp, int i) {
>>>>> >      super(id, ldp, i);
>>>>> >   }
>>>>> >
>>>>> > [...]
>>>>> >   }
>>>>> > }
>>>>> > --
>>>>> >
>>>>> > CommentaarPanel.html:
>>>>> > --
>>>>> > [...]
>>>>> >   <body>
>>>>> >      <wicket:panel>
>>>>> >         <div wicket:id="commentaarToevoegen" />
>>>>> >         <ul>
>>>>> >            <li wicket:id="commentaarList" class="commentaar">
>>>>> >               <p class="zegt"><span wicket:id="tijdstip" /> - <span
>>>>> > wicket:id="commentator" class="schrift commentator" /> laat weten:</p>
>>>>> >               <p wicket:id="tekst" class="schrift" />
>>>>> >            </li>
>>>>> >            <div wicket:id="commentaarNav" class="navigator
>>>>> navigatordown"
>>>>> > />
>>>>> >         </ul>
>>>>> >      </wicket:panel>
>>>>> >   </body>
>>>>> > </html>
>>>>> > --
>>>>> >
>>>>> > CommentaarPanel.java:
>>>>> > --
>>>>> > [...]
>>>>> > public final class CommentaarPanel
>>>>> >      extends Panel {
>>>>> >
>>>>> >   private Blogitem blog;
>>>>> >   private List<Comment> commentList;
>>>>> >   private DataView<Comment> commentListView;
>>>>> >
>>>>> >
>>>>> >   public CommentaarPanel(String id, Blogitem blog) {
>>>>> >      super(id);
>>>>> >
>>>>> >      this.blog = blog;
>>>>> >
>>>>> >      setOutputMarkupId(true);
>>>>> >
>>>>> >      commentList = blog.getCommentList();
>>>>> >      Collections.sort(commentList);
>>>>> >      commentListView =
>>>>> >            new DataView<Comment>("commentaarList",
>>>>> >                                  new ListDataProvider(commentList),
>>>>> >                                  5) {
>>>>> >
>>>>> >               @Override
>>>>> >               protected void populateItem(Item<Comment> item) {
>>>>> >                  item.add(new Label("tekst",
>>>>> > item.getModelObject().getText()));
>>>>> >                  item.add(new Label("commentator",
>>>>> > item.getModelObject().getName()));
>>>>> >                  item.add(new Label("tijdstip",
>>>>> > Q.DF.format(item.getModelObject().getTimestamp())));
>>>>> >               }
>>>>> >
>>>>> >            };
>>>>> >      add(commentListView);
>>>>> >      add(new AjaxPagingNavigator("commentaarNav", commentListView) {
>>>>> >
>>>>> >         @Override
>>>>> >         public boolean isVisible() {
>>>>> >            return this.getPageable().getPageCount() > 1;
>>>>> >         }
>>>>> >
>>>>> >      });
>>>>> >      add(new CommentaarToevoegenPanel("commentaarToevoegen", this));
>>>>> >   }
>>>>> >
>>>>> >
>>>>> >   public Blogitem getBlog() {
>>>>> >      return blog;
>>>>> >   }
>>>>> >
>>>>> >
>>>>> >   public List<Comment> getCommentList() {
>>>>> >      return commentList;
>>>>> >   }
>>>>> >
>>>>> >
>>>>> >   public DataView<Comment> getCommentListView() {
>>>>> >      return commentListView;
>>>>> >   }
>>>>> >
>>>>> > }
>>>>> > --
>>>>> >
>>>>> >
>>>>> > WeerPanel.html:
>>>>> > --
>>>>> > [...]
>>>>> >   <body>
>>>>> >      <wicket:panel>
>>>>> >         <span wicket:id="locatie" /><br />
>>>>> >         <img wicket:id="icoonhuidig" class="weericoon" />
>>>>> >         <p>temperatuur: <span wicket:id="temperatuur" />&deg;C<br />
>>>>> >         vochtigheid: <span wicket:id="vochtigheid" /><br />
>>>>> >         wind: <span wicket:id="wind" /></p>
>>>>> >      </wicket:panel>
>>>>> >   </body>
>>>>> > </html>
>>>>> > --
>>>>> >
>>>>> > WeerPanel.java:
>>>>> > --
>>>>> > [...]
>>>>> > public final class WeerPanel
>>>>> >      extends Panel {
>>>>> >
>>>>> >   private String locatie;
>>>>> >
>>>>> >   public WeerPanel(String id, String locatie) {
>>>>> >      super(id);
>>>>> >      this.locatie = locatie;
>>>>> >      init();
>>>>> >   }
>>>>> >
>>>>> >
>>>>> >   public WeerPanel(String id) {
>>>>> >      this(id, "Brugge");
>>>>> >   }
>>>>> >
>>>>> >
>>>>> >   private void init() {
>>>>> >      Document doc = null;
>>>>> >      {
>>>>> >         InputStream in = null;
>>>>> >         try {
>>>>> >            URL xmlUrl = new URL("
>>>>> http://www.google.com/ig/api?weather=" +
>>>>> > locatie);
>>>>> >            in = xmlUrl.openStream();
>>>>> >            doc = parse(in);
>>>>> >         }
>>>>> >         catch (MalformedURLException ex) {
>>>>> >
>>>>>  Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
>>>>> > null, ex);
>>>>> >         }
>>>>> >         catch (IOException ex) {
>>>>> >
>>>>>  Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
>>>>> > null, ex);
>>>>> >         }
>>>>> >         finally {
>>>>> >            if (in != null) {
>>>>> >               try {
>>>>> >                  in.close();
>>>>> >               }
>>>>> >               catch (IOException ex) {
>>>>> >
>>>>> > Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE, null,
>>>>> ex);
>>>>> >               }
>>>>> >            }
>>>>> >         }
>>>>> >      }
>>>>> >
>>>>> >      String locatieString = "<ongekend>";
>>>>> >      String srcicon = "http://www.google.com";
>>>>> >      String temperatuur = "<?>";
>>>>> >      String vochtigheid = "<?>";
>>>>> >      String wind = "<?>";
>>>>> >
>>>>> >      if (doc != null) {
>>>>> >         locatieString =
>>>>> >
>>>>> >
>>>>>  doc.getElementsByTagName("city").item(0).getAttributes().getNamedItem("data").getNodeValue();
>>>>> >         NodeList nl =
>>>>> >
>>>>> doc.getElementsByTagName("current_conditions").item(0).getChildNodes();
>>>>> >         for (int i = 0; i < nl.getLength(); i++) {
>>>>> >            Node n = nl.item(i);
>>>>> >            if (n.getNodeName().equals("icon")) {
>>>>> >               srcicon +=
>>>>> > n.getAttributes().getNamedItem("data").getNodeValue();
>>>>> >            }
>>>>> >            else if (n.getNodeName().equals("temp_c")) {
>>>>> >               temperatuur =
>>>>> > n.getAttributes().getNamedItem("data").getNodeValue();
>>>>> >            }
>>>>> >            else if (n.getNodeName().equals("humidity")) {
>>>>> >               vochtigheid =
>>>>> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>>>>> >            }
>>>>> >            else if (n.getNodeName().equals("wind_condition")) {
>>>>> >               wind =
>>>>> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>>>>> >            }
>>>>> >         }
>>>>> >      }
>>>>> >
>>>>> >      add(new Label("locatie", locatieString));
>>>>> >      add(new StaticImage("icoonhuidig", srcicon));
>>>>> >      Label temperatuurLabel = new Label("temperatuur", temperatuur);
>>>>> >      temperatuurLabel.setRenderBodyOnly(true);
>>>>> >      add(temperatuurLabel);
>>>>> >      Label vochtigheidLabel = new Label("vochtigheid", vochtigheid);
>>>>> >      vochtigheidLabel.setRenderBodyOnly(true);
>>>>> >      add(vochtigheidLabel);
>>>>> >      Label windLabel = new Label("wind", wind);
>>>>> >      windLabel.setRenderBodyOnly(true);
>>>>> >      add(windLabel);
>>>>> >
>>>>> >   }
>>>>> >
>>>>> >
>>>>> >   public static Document parse(InputStream is) {
>>>>> >      Document ret = null;
>>>>> >      DocumentBuilderFactory domFactory;
>>>>> >      DocumentBuilder builder;
>>>>> >
>>>>> >      try {
>>>>> >         domFactory = DocumentBuilderFactory.newInstance();
>>>>> >         domFactory.setValidating(false);
>>>>> >         domFactory.setNamespaceAware(false);
>>>>> >         builder = domFactory.newDocumentBuilder();
>>>>> >
>>>>> >         ret = builder.parse(is);
>>>>> >      }
>>>>> >      catch (Exception ex) {
>>>>> >         System.err.println("unable to load XML: " + ex);
>>>>> >      }
>>>>> >      return ret;
>>>>> >   }
>>>>> >
>>>>> > }
>>>>> > --
>>>>> >
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Martin Grigorov
>>>>> jWeekend
>>>>> Training, Consulting, Development
>>>>> http://jWeekend.com
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>
>>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ajax GET stopped because of precondition check

Posted by Kurt Sys <ku...@gmail.com>.
It only worked once in IE (checked only on 1 pc). So, probably a caching
problem of IE?

I suppose the ajax-requests of wicket are 'GET'-requests and there is no
timestamp or something variable added to the response, or is there? Anyway,
the only thing I can think of so far is caching of ajax-requests somewhere
in IE, so:
http://www.codemiles.com/ajax/solution-to-ajax-cache-problem-with-internet-explorer-t602.html
http://www.codecouch.com/2009/01/how-to-stop-internet-explorer-from-caching-ajax-requests/
http://weblogs.asp.net/pleloup/archive/2006/06/08/451583.aspx
(and many more of these kind of solutions).
I remember: add some headers to the response. Question now is: how to
customize the response of an ajax-request? Or is there any other solution to
the caching of IE?  (In case caching is the problem here).

Thx, Kurt

2011/7/6 Kurt Sys <ku...@gmail.com>

> Well, I got a new hosting, and for some reason, it seems to work in IE now,
> except for the iframe. Nothing is loaded in the iframe so far. That'll be a
> IE issue, so I suppose this thread may be closed.
>
>
> 2011/7/5 Kurt Sys <ku...@gmail.com>
>
>> I found this thread:
>>
>> http://apache-wicket.1842946.n4.nabble.com/Wicket-1-4m3-AjaxButton-AjaxSubmitLink-in-ModalWindow-in-IE-7-Problem-td1893357.html
>> So I checked all wicket:ids, and none of them has a value of 'id' or
>> 'submit' or something similar. IE still fails to load the panels...
>>
>>
>> 2011/7/3 Kurt Sys <ku...@gmail.com>
>>
>>> The lazy loading example seems to work fine (I tried Wicket 1.4.17, the
>>> one I'm using too).
>>>
>>> For some reason 'precondition()' returns false in IE when called from my
>>> app. The code loading the panels is really straight forward. I can't think
>>> of any reason (for now) why the precondition returns false, only in IE, and
>>> even not for all lazyloadpanels.
>>> I have actually no idea where precondition is changed or something - I
>>> checked the js file (wicket-ajax.js) and there the function of the prototype
>>> just returns true (see below). So, precondition it is changed somewhere, for
>>> some reason, and probably something in a javascript-file of wicket that is
>>> called from my code IE doesn't like (other browsers don't complain). What
>>> code can be wrong? Something 'wrong' in the html-files? Style files (which
>>> would be very odd, if you ask me)?
>>>
>>> --
>>>
>>> Wicket.Ajax.Request.prototype = {
>>>     // Creates a new request object.	initialize: function(url, loadedCallback, parseResponse, randomURL, failureHandler, channel) {
>>> 		this.url = url;
>>> 		this.loadedCallback = loadedCallback;
>>> 		// whether we should give the loadedCallback parsed response (DOM tree) or the raw string		this.parseResponse = parseResponse != null ? parseResponse : true;
>>> 		this.randomURL = randomURL != null ? randomURL : true;
>>> 		this.failureHandler = failureHandler != null ? failureHandler : function() { };
>>> 		this.async = true;
>>> 		this.channel = channel;
>>> 		this.precondition = function() { return true; } // allow a condition to block request
>>> 		// when suppressDone is set, the loadedCallback is responsible for calling		// Ajax.Request.done() to process possibly pendings requests in the channel.		this.suppressDone = false;
>>> 		this.instance = Math.random();
>>> 		this.debugContent = true;
>>> 	},
>>> --	
>>>
>>>
>>>
>>>
>>> 2011/7/3 Martin Grigorov <mg...@apache.org>
>>>
>>>> Can you check http://wicketstuff.org/wicket/ajax/lazy-loading ?
>>>> This is Wicket 1.5-RC5.1 and it works for me with IE8.
>>>>
>>>> Wicket 1.4.17 at http://wicketstuff.org/wicket14/ajax/lazy-loading
>>>>
>>>> On Sat, Jul 2, 2011 at 5:16 PM, Kurt Sys <ku...@gmail.com> wrote:
>>>> > Hey all,
>>>> >
>>>> > In IE, I can't get lazyloadpanels to load. I have a webapp with some
>>>> > lazyloadpanels, and none of them loads in IE - in other browsers,
>>>> there is
>>>> > no problem. (Also, the content of an iframe doesn't load, which seems
>>>> to be
>>>> > related, since it is also an ajax-request.) I've been trying both IE 8
>>>> and
>>>> > IE 9 on three different pc's. Can someone give me a clue why it won't
>>>> work
>>>> > in IE? (IE security settings are set to low, scripts etc are
>>>> > enabled/allowed, so I suppose ajax-requests can be performed... if
>>>> not, I
>>>> > have no clue how to allow ajax in IE.) You may check it out:
>>>> > http://www.tinyleaps.be
>>>> >
>>>> > I've been checking on similar problems with lazyloadpanel in ie, and
>>>> the
>>>> > problem was known in 2008 (if it's the same, but it looks really
>>>> similar):
>>>> > http://www.mail-archive.com/users@wicket.apache.org/msg18815.html
>>>> > There seems to be a bug report and a 'fixed' status, although it
>>>> doesn't
>>>> > seem to work out fine for me - the last comment states that the fix is
>>>> not
>>>> > confirmed. Or I am  missing something, which wouldn't really surprise
>>>> me :),
>>>> > or there still something wrong with the precondition stuff and loading
>>>> the
>>>> > panel in IE:
>>>> > https://issues.apache.org/jira/browse/WICKET-1653
>>>> >
>>>> >
>>>> > Ajax debug window (only these three lines):
>>>> > --
>>>> > INFO: Ajax GET stopped because of precondition check,
>>>> >
>>>> url:?wicket:interface=:3:mainpanel:bloglist:1:commentaar::IBehaviorListener:0:
>>>> > INFO: Ajax GET stopped because of precondition check,
>>>> >
>>>> url:?wicket:interface=:3:mainpanel:bloglist:2:commentaar::IBehaviorListener:0:
>>>> > INFO: Ajax GET stopped because of precondition check,
>>>> > url:?wicket:interface=:3:weer::IBehaviorListener:0:
>>>> > --
>>>> >
>>>> > HomePage.html:
>>>> > --
>>>> > [...]
>>>> > <body>
>>>> > <wicket:extend>
>>>> > [...]
>>>> >      <div wicket:id="route" />
>>>> > [...]
>>>> >            <div wicket:id="mainpanel" />
>>>> > [...]
>>>> >            <div wicket:id="weer" class="weer" >&nbsp;
>>>> >            </div>
>>>> > [...]
>>>> >      </div>
>>>> > </wicket:extend>
>>>> > </body>
>>>> > </html>
>>>> > --
>>>> >
>>>> > HomePage.java:
>>>> > --
>>>> > [...]
>>>> >
>>>> > public class HomePage
>>>> >      extends BasePage {
>>>> >
>>>> >   Panel mainPanel;
>>>> >   Label linktekst;
>>>> >
>>>> >
>>>> >   public HomePage() {
>>>> >      this(null);
>>>> >   }
>>>> >
>>>> >
>>>> >   public HomePage(PageParameters pars) {
>>>> > [...]
>>>> >      add(new RoutePanel("route"));
>>>> >
>>>> >
>>>> >      if (pars != null) {
>>>> >         mainPanel = new BlogPanel("mainpanel",
>>>> pars.getAsInteger("id"));
>>>> >      }
>>>> >      else {
>>>> >         mainPanel = new BlogPanel("mainpanel");
>>>> >      }
>>>> >
>>>> >      add(mainPanel);
>>>> > [...]
>>>> >      add(new AjaxLazyLoadPanel("weer") {
>>>> >
>>>> >         @Override
>>>> >         public Component getLazyLoadComponent(String markupId) {
>>>> >            return new WeerPanel(markupId,
>>>> > reis.getBlogitemList().get(0).getLocation().getName());
>>>> >         }
>>>> >
>>>> >      });
>>>> >   }
>>>> >
>>>> > }
>>>> > --
>>>> >
>>>> > BlogPanel.html
>>>> > --
>>>> > [...]
>>>> >      <wicket:panel>
>>>> > [...]
>>>> >         <ul class="bloglist">
>>>> >            <li wicket:id="bloglist" class="blogitem">
>>>> > [...]
>>>> >                   <div wicket:id="commentaar" />
>>>> >                     </div>
>>>> > [...]
>>>> >            </li>
>>>> >         </ul>
>>>> > [...]
>>>> >      </wicket:panel>
>>>> >   </body>
>>>> > </html>
>>>> > --
>>>> >
>>>> > BlogPanel.java:
>>>> > --
>>>> > [...]
>>>> > public final class BlogPanel
>>>> >      extends Panel {
>>>> >
>>>> >   private static final int ITEMSPERPAGE = 3;
>>>> >
>>>> >   public BlogPanel(String id) {
>>>> >      this(id, 0);
>>>> >   }
>>>> >
>>>> >
>>>> >   public BlogPanel(final String id, final int blogid) {
>>>> >      super(id);
>>>> >
>>>> >      setOutputMarkupId(true);
>>>> >
>>>> > [...]
>>>> >      List<Blogitem> blogitemList =
>>>> >            Q.EM.createNamedQuery("Blogitem.findAll", Blogitem.class).
>>>> >            setHint(QueryHints.REFRESH,
>>>> HintValues.TRUE).getResultList();
>>>> >
>>>> >      BlogListView blogListView = new BlogListView(
>>>> >            "bloglist",
>>>> >            new ListDataProvider(blogitemList),
>>>> >            ITEMSPERPAGE) {
>>>> >
>>>> >         @Override
>>>> >         protected void populateItem(final Item<Blogitem> item) {
>>>> >
>>>> > [...]
>>>> >            item.add(new AjaxLazyLoadPanel("commentaar") {
>>>> >
>>>> >               @Override
>>>> >               public Component getLazyLoadComponent(String markupId) {
>>>> >                  return new CommentaarPanel(markupId,
>>>> > item.getModelObject());
>>>> >               }
>>>> >
>>>> >            });
>>>> > [...]
>>>> >         }
>>>> >
>>>> >      };
>>>> >
>>>> > [...]
>>>> >      add(blogListView);
>>>> >
>>>> > [...]
>>>> > }
>>>> >
>>>> > abstract class BlogListView
>>>> >      extends DataView<Blogitem> {
>>>> >
>>>> >   BlogListView(String id, ListDataProvider ldp, int i) {
>>>> >      super(id, ldp, i);
>>>> >   }
>>>> >
>>>> > [...]
>>>> >   }
>>>> > }
>>>> > --
>>>> >
>>>> > CommentaarPanel.html:
>>>> > --
>>>> > [...]
>>>> >   <body>
>>>> >      <wicket:panel>
>>>> >         <div wicket:id="commentaarToevoegen" />
>>>> >         <ul>
>>>> >            <li wicket:id="commentaarList" class="commentaar">
>>>> >               <p class="zegt"><span wicket:id="tijdstip" /> - <span
>>>> > wicket:id="commentator" class="schrift commentator" /> laat weten:</p>
>>>> >               <p wicket:id="tekst" class="schrift" />
>>>> >            </li>
>>>> >            <div wicket:id="commentaarNav" class="navigator
>>>> navigatordown"
>>>> > />
>>>> >         </ul>
>>>> >      </wicket:panel>
>>>> >   </body>
>>>> > </html>
>>>> > --
>>>> >
>>>> > CommentaarPanel.java:
>>>> > --
>>>> > [...]
>>>> > public final class CommentaarPanel
>>>> >      extends Panel {
>>>> >
>>>> >   private Blogitem blog;
>>>> >   private List<Comment> commentList;
>>>> >   private DataView<Comment> commentListView;
>>>> >
>>>> >
>>>> >   public CommentaarPanel(String id, Blogitem blog) {
>>>> >      super(id);
>>>> >
>>>> >      this.blog = blog;
>>>> >
>>>> >      setOutputMarkupId(true);
>>>> >
>>>> >      commentList = blog.getCommentList();
>>>> >      Collections.sort(commentList);
>>>> >      commentListView =
>>>> >            new DataView<Comment>("commentaarList",
>>>> >                                  new ListDataProvider(commentList),
>>>> >                                  5) {
>>>> >
>>>> >               @Override
>>>> >               protected void populateItem(Item<Comment> item) {
>>>> >                  item.add(new Label("tekst",
>>>> > item.getModelObject().getText()));
>>>> >                  item.add(new Label("commentator",
>>>> > item.getModelObject().getName()));
>>>> >                  item.add(new Label("tijdstip",
>>>> > Q.DF.format(item.getModelObject().getTimestamp())));
>>>> >               }
>>>> >
>>>> >            };
>>>> >      add(commentListView);
>>>> >      add(new AjaxPagingNavigator("commentaarNav", commentListView) {
>>>> >
>>>> >         @Override
>>>> >         public boolean isVisible() {
>>>> >            return this.getPageable().getPageCount() > 1;
>>>> >         }
>>>> >
>>>> >      });
>>>> >      add(new CommentaarToevoegenPanel("commentaarToevoegen", this));
>>>> >   }
>>>> >
>>>> >
>>>> >   public Blogitem getBlog() {
>>>> >      return blog;
>>>> >   }
>>>> >
>>>> >
>>>> >   public List<Comment> getCommentList() {
>>>> >      return commentList;
>>>> >   }
>>>> >
>>>> >
>>>> >   public DataView<Comment> getCommentListView() {
>>>> >      return commentListView;
>>>> >   }
>>>> >
>>>> > }
>>>> > --
>>>> >
>>>> >
>>>> > WeerPanel.html:
>>>> > --
>>>> > [...]
>>>> >   <body>
>>>> >      <wicket:panel>
>>>> >         <span wicket:id="locatie" /><br />
>>>> >         <img wicket:id="icoonhuidig" class="weericoon" />
>>>> >         <p>temperatuur: <span wicket:id="temperatuur" />&deg;C<br />
>>>> >         vochtigheid: <span wicket:id="vochtigheid" /><br />
>>>> >         wind: <span wicket:id="wind" /></p>
>>>> >      </wicket:panel>
>>>> >   </body>
>>>> > </html>
>>>> > --
>>>> >
>>>> > WeerPanel.java:
>>>> > --
>>>> > [...]
>>>> > public final class WeerPanel
>>>> >      extends Panel {
>>>> >
>>>> >   private String locatie;
>>>> >
>>>> >   public WeerPanel(String id, String locatie) {
>>>> >      super(id);
>>>> >      this.locatie = locatie;
>>>> >      init();
>>>> >   }
>>>> >
>>>> >
>>>> >   public WeerPanel(String id) {
>>>> >      this(id, "Brugge");
>>>> >   }
>>>> >
>>>> >
>>>> >   private void init() {
>>>> >      Document doc = null;
>>>> >      {
>>>> >         InputStream in = null;
>>>> >         try {
>>>> >            URL xmlUrl = new URL("
>>>> http://www.google.com/ig/api?weather=" +
>>>> > locatie);
>>>> >            in = xmlUrl.openStream();
>>>> >            doc = parse(in);
>>>> >         }
>>>> >         catch (MalformedURLException ex) {
>>>> >
>>>>  Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
>>>> > null, ex);
>>>> >         }
>>>> >         catch (IOException ex) {
>>>> >
>>>>  Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
>>>> > null, ex);
>>>> >         }
>>>> >         finally {
>>>> >            if (in != null) {
>>>> >               try {
>>>> >                  in.close();
>>>> >               }
>>>> >               catch (IOException ex) {
>>>> >
>>>> > Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE, null,
>>>> ex);
>>>> >               }
>>>> >            }
>>>> >         }
>>>> >      }
>>>> >
>>>> >      String locatieString = "<ongekend>";
>>>> >      String srcicon = "http://www.google.com";
>>>> >      String temperatuur = "<?>";
>>>> >      String vochtigheid = "<?>";
>>>> >      String wind = "<?>";
>>>> >
>>>> >      if (doc != null) {
>>>> >         locatieString =
>>>> >
>>>> >
>>>>  doc.getElementsByTagName("city").item(0).getAttributes().getNamedItem("data").getNodeValue();
>>>> >         NodeList nl =
>>>> >
>>>> doc.getElementsByTagName("current_conditions").item(0).getChildNodes();
>>>> >         for (int i = 0; i < nl.getLength(); i++) {
>>>> >            Node n = nl.item(i);
>>>> >            if (n.getNodeName().equals("icon")) {
>>>> >               srcicon +=
>>>> > n.getAttributes().getNamedItem("data").getNodeValue();
>>>> >            }
>>>> >            else if (n.getNodeName().equals("temp_c")) {
>>>> >               temperatuur =
>>>> > n.getAttributes().getNamedItem("data").getNodeValue();
>>>> >            }
>>>> >            else if (n.getNodeName().equals("humidity")) {
>>>> >               vochtigheid =
>>>> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>>>> >            }
>>>> >            else if (n.getNodeName().equals("wind_condition")) {
>>>> >               wind =
>>>> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>>>> >            }
>>>> >         }
>>>> >      }
>>>> >
>>>> >      add(new Label("locatie", locatieString));
>>>> >      add(new StaticImage("icoonhuidig", srcicon));
>>>> >      Label temperatuurLabel = new Label("temperatuur", temperatuur);
>>>> >      temperatuurLabel.setRenderBodyOnly(true);
>>>> >      add(temperatuurLabel);
>>>> >      Label vochtigheidLabel = new Label("vochtigheid", vochtigheid);
>>>> >      vochtigheidLabel.setRenderBodyOnly(true);
>>>> >      add(vochtigheidLabel);
>>>> >      Label windLabel = new Label("wind", wind);
>>>> >      windLabel.setRenderBodyOnly(true);
>>>> >      add(windLabel);
>>>> >
>>>> >   }
>>>> >
>>>> >
>>>> >   public static Document parse(InputStream is) {
>>>> >      Document ret = null;
>>>> >      DocumentBuilderFactory domFactory;
>>>> >      DocumentBuilder builder;
>>>> >
>>>> >      try {
>>>> >         domFactory = DocumentBuilderFactory.newInstance();
>>>> >         domFactory.setValidating(false);
>>>> >         domFactory.setNamespaceAware(false);
>>>> >         builder = domFactory.newDocumentBuilder();
>>>> >
>>>> >         ret = builder.parse(is);
>>>> >      }
>>>> >      catch (Exception ex) {
>>>> >         System.err.println("unable to load XML: " + ex);
>>>> >      }
>>>> >      return ret;
>>>> >   }
>>>> >
>>>> > }
>>>> > --
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Martin Grigorov
>>>> jWeekend
>>>> Training, Consulting, Development
>>>> http://jWeekend.com
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>
>

Re: ajax GET stopped because of precondition check

Posted by Kurt Sys <ku...@gmail.com>.
Well, I got a new hosting, and for some reason, it seems to work in IE now,
except for the iframe. Nothing is loaded in the iframe so far. That'll be a
IE issue, so I suppose this thread may be closed.


2011/7/5 Kurt Sys <ku...@gmail.com>

> I found this thread:
>
> http://apache-wicket.1842946.n4.nabble.com/Wicket-1-4m3-AjaxButton-AjaxSubmitLink-in-ModalWindow-in-IE-7-Problem-td1893357.html
> So I checked all wicket:ids, and none of them has a value of 'id' or
> 'submit' or something similar. IE still fails to load the panels...
>
>
> 2011/7/3 Kurt Sys <ku...@gmail.com>
>
>> The lazy loading example seems to work fine (I tried Wicket 1.4.17, the
>> one I'm using too).
>>
>> For some reason 'precondition()' returns false in IE when called from my
>> app. The code loading the panels is really straight forward. I can't think
>> of any reason (for now) why the precondition returns false, only in IE, and
>> even not for all lazyloadpanels.
>> I have actually no idea where precondition is changed or something - I
>> checked the js file (wicket-ajax.js) and there the function of the prototype
>> just returns true (see below). So, precondition it is changed somewhere, for
>> some reason, and probably something in a javascript-file of wicket that is
>> called from my code IE doesn't like (other browsers don't complain). What
>> code can be wrong? Something 'wrong' in the html-files? Style files (which
>> would be very odd, if you ask me)?
>>
>> --
>>
>> Wicket.Ajax.Request.prototype = {
>>     // Creates a new request object.	initialize: function(url, loadedCallback, parseResponse, randomURL, failureHandler, channel) {
>> 		this.url = url;
>> 		this.loadedCallback = loadedCallback;
>> 		// whether we should give the loadedCallback parsed response (DOM tree) or the raw string		this.parseResponse = parseResponse != null ? parseResponse : true;
>> 		this.randomURL = randomURL != null ? randomURL : true;
>> 		this.failureHandler = failureHandler != null ? failureHandler : function() { };
>> 		this.async = true;
>> 		this.channel = channel;
>> 		this.precondition = function() { return true; } // allow a condition to block request
>> 		// when suppressDone is set, the loadedCallback is responsible for calling		// Ajax.Request.done() to process possibly pendings requests in the channel.		this.suppressDone = false;
>> 		this.instance = Math.random();
>> 		this.debugContent = true;
>> 	},
>> --	
>>
>>
>>
>>
>> 2011/7/3 Martin Grigorov <mg...@apache.org>
>>
>>> Can you check http://wicketstuff.org/wicket/ajax/lazy-loading ?
>>> This is Wicket 1.5-RC5.1 and it works for me with IE8.
>>>
>>> Wicket 1.4.17 at http://wicketstuff.org/wicket14/ajax/lazy-loading
>>>
>>> On Sat, Jul 2, 2011 at 5:16 PM, Kurt Sys <ku...@gmail.com> wrote:
>>> > Hey all,
>>> >
>>> > In IE, I can't get lazyloadpanels to load. I have a webapp with some
>>> > lazyloadpanels, and none of them loads in IE - in other browsers, there
>>> is
>>> > no problem. (Also, the content of an iframe doesn't load, which seems
>>> to be
>>> > related, since it is also an ajax-request.) I've been trying both IE 8
>>> and
>>> > IE 9 on three different pc's. Can someone give me a clue why it won't
>>> work
>>> > in IE? (IE security settings are set to low, scripts etc are
>>> > enabled/allowed, so I suppose ajax-requests can be performed... if not,
>>> I
>>> > have no clue how to allow ajax in IE.) You may check it out:
>>> > http://www.tinyleaps.be
>>> >
>>> > I've been checking on similar problems with lazyloadpanel in ie, and
>>> the
>>> > problem was known in 2008 (if it's the same, but it looks really
>>> similar):
>>> > http://www.mail-archive.com/users@wicket.apache.org/msg18815.html
>>> > There seems to be a bug report and a 'fixed' status, although it
>>> doesn't
>>> > seem to work out fine for me - the last comment states that the fix is
>>> not
>>> > confirmed. Or I am  missing something, which wouldn't really surprise
>>> me :),
>>> > or there still something wrong with the precondition stuff and loading
>>> the
>>> > panel in IE:
>>> > https://issues.apache.org/jira/browse/WICKET-1653
>>> >
>>> >
>>> > Ajax debug window (only these three lines):
>>> > --
>>> > INFO: Ajax GET stopped because of precondition check,
>>> >
>>> url:?wicket:interface=:3:mainpanel:bloglist:1:commentaar::IBehaviorListener:0:
>>> > INFO: Ajax GET stopped because of precondition check,
>>> >
>>> url:?wicket:interface=:3:mainpanel:bloglist:2:commentaar::IBehaviorListener:0:
>>> > INFO: Ajax GET stopped because of precondition check,
>>> > url:?wicket:interface=:3:weer::IBehaviorListener:0:
>>> > --
>>> >
>>> > HomePage.html:
>>> > --
>>> > [...]
>>> > <body>
>>> > <wicket:extend>
>>> > [...]
>>> >      <div wicket:id="route" />
>>> > [...]
>>> >            <div wicket:id="mainpanel" />
>>> > [...]
>>> >            <div wicket:id="weer" class="weer" >&nbsp;
>>> >            </div>
>>> > [...]
>>> >      </div>
>>> > </wicket:extend>
>>> > </body>
>>> > </html>
>>> > --
>>> >
>>> > HomePage.java:
>>> > --
>>> > [...]
>>> >
>>> > public class HomePage
>>> >      extends BasePage {
>>> >
>>> >   Panel mainPanel;
>>> >   Label linktekst;
>>> >
>>> >
>>> >   public HomePage() {
>>> >      this(null);
>>> >   }
>>> >
>>> >
>>> >   public HomePage(PageParameters pars) {
>>> > [...]
>>> >      add(new RoutePanel("route"));
>>> >
>>> >
>>> >      if (pars != null) {
>>> >         mainPanel = new BlogPanel("mainpanel",
>>> pars.getAsInteger("id"));
>>> >      }
>>> >      else {
>>> >         mainPanel = new BlogPanel("mainpanel");
>>> >      }
>>> >
>>> >      add(mainPanel);
>>> > [...]
>>> >      add(new AjaxLazyLoadPanel("weer") {
>>> >
>>> >         @Override
>>> >         public Component getLazyLoadComponent(String markupId) {
>>> >            return new WeerPanel(markupId,
>>> > reis.getBlogitemList().get(0).getLocation().getName());
>>> >         }
>>> >
>>> >      });
>>> >   }
>>> >
>>> > }
>>> > --
>>> >
>>> > BlogPanel.html
>>> > --
>>> > [...]
>>> >      <wicket:panel>
>>> > [...]
>>> >         <ul class="bloglist">
>>> >            <li wicket:id="bloglist" class="blogitem">
>>> > [...]
>>> >                   <div wicket:id="commentaar" />
>>> >                     </div>
>>> > [...]
>>> >            </li>
>>> >         </ul>
>>> > [...]
>>> >      </wicket:panel>
>>> >   </body>
>>> > </html>
>>> > --
>>> >
>>> > BlogPanel.java:
>>> > --
>>> > [...]
>>> > public final class BlogPanel
>>> >      extends Panel {
>>> >
>>> >   private static final int ITEMSPERPAGE = 3;
>>> >
>>> >   public BlogPanel(String id) {
>>> >      this(id, 0);
>>> >   }
>>> >
>>> >
>>> >   public BlogPanel(final String id, final int blogid) {
>>> >      super(id);
>>> >
>>> >      setOutputMarkupId(true);
>>> >
>>> > [...]
>>> >      List<Blogitem> blogitemList =
>>> >            Q.EM.createNamedQuery("Blogitem.findAll", Blogitem.class).
>>> >            setHint(QueryHints.REFRESH,
>>> HintValues.TRUE).getResultList();
>>> >
>>> >      BlogListView blogListView = new BlogListView(
>>> >            "bloglist",
>>> >            new ListDataProvider(blogitemList),
>>> >            ITEMSPERPAGE) {
>>> >
>>> >         @Override
>>> >         protected void populateItem(final Item<Blogitem> item) {
>>> >
>>> > [...]
>>> >            item.add(new AjaxLazyLoadPanel("commentaar") {
>>> >
>>> >               @Override
>>> >               public Component getLazyLoadComponent(String markupId) {
>>> >                  return new CommentaarPanel(markupId,
>>> > item.getModelObject());
>>> >               }
>>> >
>>> >            });
>>> > [...]
>>> >         }
>>> >
>>> >      };
>>> >
>>> > [...]
>>> >      add(blogListView);
>>> >
>>> > [...]
>>> > }
>>> >
>>> > abstract class BlogListView
>>> >      extends DataView<Blogitem> {
>>> >
>>> >   BlogListView(String id, ListDataProvider ldp, int i) {
>>> >      super(id, ldp, i);
>>> >   }
>>> >
>>> > [...]
>>> >   }
>>> > }
>>> > --
>>> >
>>> > CommentaarPanel.html:
>>> > --
>>> > [...]
>>> >   <body>
>>> >      <wicket:panel>
>>> >         <div wicket:id="commentaarToevoegen" />
>>> >         <ul>
>>> >            <li wicket:id="commentaarList" class="commentaar">
>>> >               <p class="zegt"><span wicket:id="tijdstip" /> - <span
>>> > wicket:id="commentator" class="schrift commentator" /> laat weten:</p>
>>> >               <p wicket:id="tekst" class="schrift" />
>>> >            </li>
>>> >            <div wicket:id="commentaarNav" class="navigator
>>> navigatordown"
>>> > />
>>> >         </ul>
>>> >      </wicket:panel>
>>> >   </body>
>>> > </html>
>>> > --
>>> >
>>> > CommentaarPanel.java:
>>> > --
>>> > [...]
>>> > public final class CommentaarPanel
>>> >      extends Panel {
>>> >
>>> >   private Blogitem blog;
>>> >   private List<Comment> commentList;
>>> >   private DataView<Comment> commentListView;
>>> >
>>> >
>>> >   public CommentaarPanel(String id, Blogitem blog) {
>>> >      super(id);
>>> >
>>> >      this.blog = blog;
>>> >
>>> >      setOutputMarkupId(true);
>>> >
>>> >      commentList = blog.getCommentList();
>>> >      Collections.sort(commentList);
>>> >      commentListView =
>>> >            new DataView<Comment>("commentaarList",
>>> >                                  new ListDataProvider(commentList),
>>> >                                  5) {
>>> >
>>> >               @Override
>>> >               protected void populateItem(Item<Comment> item) {
>>> >                  item.add(new Label("tekst",
>>> > item.getModelObject().getText()));
>>> >                  item.add(new Label("commentator",
>>> > item.getModelObject().getName()));
>>> >                  item.add(new Label("tijdstip",
>>> > Q.DF.format(item.getModelObject().getTimestamp())));
>>> >               }
>>> >
>>> >            };
>>> >      add(commentListView);
>>> >      add(new AjaxPagingNavigator("commentaarNav", commentListView) {
>>> >
>>> >         @Override
>>> >         public boolean isVisible() {
>>> >            return this.getPageable().getPageCount() > 1;
>>> >         }
>>> >
>>> >      });
>>> >      add(new CommentaarToevoegenPanel("commentaarToevoegen", this));
>>> >   }
>>> >
>>> >
>>> >   public Blogitem getBlog() {
>>> >      return blog;
>>> >   }
>>> >
>>> >
>>> >   public List<Comment> getCommentList() {
>>> >      return commentList;
>>> >   }
>>> >
>>> >
>>> >   public DataView<Comment> getCommentListView() {
>>> >      return commentListView;
>>> >   }
>>> >
>>> > }
>>> > --
>>> >
>>> >
>>> > WeerPanel.html:
>>> > --
>>> > [...]
>>> >   <body>
>>> >      <wicket:panel>
>>> >         <span wicket:id="locatie" /><br />
>>> >         <img wicket:id="icoonhuidig" class="weericoon" />
>>> >         <p>temperatuur: <span wicket:id="temperatuur" />&deg;C<br />
>>> >         vochtigheid: <span wicket:id="vochtigheid" /><br />
>>> >         wind: <span wicket:id="wind" /></p>
>>> >      </wicket:panel>
>>> >   </body>
>>> > </html>
>>> > --
>>> >
>>> > WeerPanel.java:
>>> > --
>>> > [...]
>>> > public final class WeerPanel
>>> >      extends Panel {
>>> >
>>> >   private String locatie;
>>> >
>>> >   public WeerPanel(String id, String locatie) {
>>> >      super(id);
>>> >      this.locatie = locatie;
>>> >      init();
>>> >   }
>>> >
>>> >
>>> >   public WeerPanel(String id) {
>>> >      this(id, "Brugge");
>>> >   }
>>> >
>>> >
>>> >   private void init() {
>>> >      Document doc = null;
>>> >      {
>>> >         InputStream in = null;
>>> >         try {
>>> >            URL xmlUrl = new URL("http://www.google.com/ig/api?weather="
>>> +
>>> > locatie);
>>> >            in = xmlUrl.openStream();
>>> >            doc = parse(in);
>>> >         }
>>> >         catch (MalformedURLException ex) {
>>> >
>>>  Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
>>> > null, ex);
>>> >         }
>>> >         catch (IOException ex) {
>>> >
>>>  Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
>>> > null, ex);
>>> >         }
>>> >         finally {
>>> >            if (in != null) {
>>> >               try {
>>> >                  in.close();
>>> >               }
>>> >               catch (IOException ex) {
>>> >
>>> > Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE, null,
>>> ex);
>>> >               }
>>> >            }
>>> >         }
>>> >      }
>>> >
>>> >      String locatieString = "<ongekend>";
>>> >      String srcicon = "http://www.google.com";
>>> >      String temperatuur = "<?>";
>>> >      String vochtigheid = "<?>";
>>> >      String wind = "<?>";
>>> >
>>> >      if (doc != null) {
>>> >         locatieString =
>>> >
>>> >
>>>  doc.getElementsByTagName("city").item(0).getAttributes().getNamedItem("data").getNodeValue();
>>> >         NodeList nl =
>>> > doc.getElementsByTagName("current_conditions").item(0).getChildNodes();
>>> >         for (int i = 0; i < nl.getLength(); i++) {
>>> >            Node n = nl.item(i);
>>> >            if (n.getNodeName().equals("icon")) {
>>> >               srcicon +=
>>> > n.getAttributes().getNamedItem("data").getNodeValue();
>>> >            }
>>> >            else if (n.getNodeName().equals("temp_c")) {
>>> >               temperatuur =
>>> > n.getAttributes().getNamedItem("data").getNodeValue();
>>> >            }
>>> >            else if (n.getNodeName().equals("humidity")) {
>>> >               vochtigheid =
>>> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>>> >            }
>>> >            else if (n.getNodeName().equals("wind_condition")) {
>>> >               wind =
>>> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>>> >            }
>>> >         }
>>> >      }
>>> >
>>> >      add(new Label("locatie", locatieString));
>>> >      add(new StaticImage("icoonhuidig", srcicon));
>>> >      Label temperatuurLabel = new Label("temperatuur", temperatuur);
>>> >      temperatuurLabel.setRenderBodyOnly(true);
>>> >      add(temperatuurLabel);
>>> >      Label vochtigheidLabel = new Label("vochtigheid", vochtigheid);
>>> >      vochtigheidLabel.setRenderBodyOnly(true);
>>> >      add(vochtigheidLabel);
>>> >      Label windLabel = new Label("wind", wind);
>>> >      windLabel.setRenderBodyOnly(true);
>>> >      add(windLabel);
>>> >
>>> >   }
>>> >
>>> >
>>> >   public static Document parse(InputStream is) {
>>> >      Document ret = null;
>>> >      DocumentBuilderFactory domFactory;
>>> >      DocumentBuilder builder;
>>> >
>>> >      try {
>>> >         domFactory = DocumentBuilderFactory.newInstance();
>>> >         domFactory.setValidating(false);
>>> >         domFactory.setNamespaceAware(false);
>>> >         builder = domFactory.newDocumentBuilder();
>>> >
>>> >         ret = builder.parse(is);
>>> >      }
>>> >      catch (Exception ex) {
>>> >         System.err.println("unable to load XML: " + ex);
>>> >      }
>>> >      return ret;
>>> >   }
>>> >
>>> > }
>>> > --
>>> >
>>>
>>>
>>>
>>> --
>>> Martin Grigorov
>>> jWeekend
>>> Training, Consulting, Development
>>> http://jWeekend.com
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>

Re: ajax GET stopped because of precondition check

Posted by Kurt Sys <ku...@gmail.com>.
I found this thread:
http://apache-wicket.1842946.n4.nabble.com/Wicket-1-4m3-AjaxButton-AjaxSubmitLink-in-ModalWindow-in-IE-7-Problem-td1893357.html
So I checked all wicket:ids, and none of them has a value of 'id' or
'submit' or something similar. IE still fails to load the panels...


2011/7/3 Kurt Sys <ku...@gmail.com>

> The lazy loading example seems to work fine (I tried Wicket 1.4.17, the one
> I'm using too).
>
> For some reason 'precondition()' returns false in IE when called from my
> app. The code loading the panels is really straight forward. I can't think
> of any reason (for now) why the precondition returns false, only in IE, and
> even not for all lazyloadpanels.
> I have actually no idea where precondition is changed or something - I
> checked the js file (wicket-ajax.js) and there the function of the prototype
> just returns true (see below). So, precondition it is changed somewhere, for
> some reason, and probably something in a javascript-file of wicket that is
> called from my code IE doesn't like (other browsers don't complain). What
> code can be wrong? Something 'wrong' in the html-files? Style files (which
> would be very odd, if you ask me)?
>
> --
>
> Wicket.Ajax.Request.prototype = {
>     // Creates a new request object.	initialize: function(url, loadedCallback, parseResponse, randomURL, failureHandler, channel) {
> 		this.url = url;
> 		this.loadedCallback = loadedCallback;
> 		// whether we should give the loadedCallback parsed response (DOM tree) or the raw string		this.parseResponse = parseResponse != null ? parseResponse : true;
> 		this.randomURL = randomURL != null ? randomURL : true;
> 		this.failureHandler = failureHandler != null ? failureHandler : function() { };
> 		this.async = true;
> 		this.channel = channel;
> 		this.precondition = function() { return true; } // allow a condition to block request
> 		// when suppressDone is set, the loadedCallback is responsible for calling		// Ajax.Request.done() to process possibly pendings requests in the channel.		this.suppressDone = false;
> 		this.instance = Math.random();
> 		this.debugContent = true;
> 	},
> --	
>
>
>
>
> 2011/7/3 Martin Grigorov <mg...@apache.org>
>
>> Can you check http://wicketstuff.org/wicket/ajax/lazy-loading ?
>> This is Wicket 1.5-RC5.1 and it works for me with IE8.
>>
>> Wicket 1.4.17 at http://wicketstuff.org/wicket14/ajax/lazy-loading
>>
>> On Sat, Jul 2, 2011 at 5:16 PM, Kurt Sys <ku...@gmail.com> wrote:
>> > Hey all,
>> >
>> > In IE, I can't get lazyloadpanels to load. I have a webapp with some
>> > lazyloadpanels, and none of them loads in IE - in other browsers, there
>> is
>> > no problem. (Also, the content of an iframe doesn't load, which seems to
>> be
>> > related, since it is also an ajax-request.) I've been trying both IE 8
>> and
>> > IE 9 on three different pc's. Can someone give me a clue why it won't
>> work
>> > in IE? (IE security settings are set to low, scripts etc are
>> > enabled/allowed, so I suppose ajax-requests can be performed... if not,
>> I
>> > have no clue how to allow ajax in IE.) You may check it out:
>> > http://www.tinyleaps.be
>> >
>> > I've been checking on similar problems with lazyloadpanel in ie, and the
>> > problem was known in 2008 (if it's the same, but it looks really
>> similar):
>> > http://www.mail-archive.com/users@wicket.apache.org/msg18815.html
>> > There seems to be a bug report and a 'fixed' status, although it doesn't
>> > seem to work out fine for me - the last comment states that the fix is
>> not
>> > confirmed. Or I am  missing something, which wouldn't really surprise me
>> :),
>> > or there still something wrong with the precondition stuff and loading
>> the
>> > panel in IE:
>> > https://issues.apache.org/jira/browse/WICKET-1653
>> >
>> >
>> > Ajax debug window (only these three lines):
>> > --
>> > INFO: Ajax GET stopped because of precondition check,
>> >
>> url:?wicket:interface=:3:mainpanel:bloglist:1:commentaar::IBehaviorListener:0:
>> > INFO: Ajax GET stopped because of precondition check,
>> >
>> url:?wicket:interface=:3:mainpanel:bloglist:2:commentaar::IBehaviorListener:0:
>> > INFO: Ajax GET stopped because of precondition check,
>> > url:?wicket:interface=:3:weer::IBehaviorListener:0:
>> > --
>> >
>> > HomePage.html:
>> > --
>> > [...]
>> > <body>
>> > <wicket:extend>
>> > [...]
>> >      <div wicket:id="route" />
>> > [...]
>> >            <div wicket:id="mainpanel" />
>> > [...]
>> >            <div wicket:id="weer" class="weer" >&nbsp;
>> >            </div>
>> > [...]
>> >      </div>
>> > </wicket:extend>
>> > </body>
>> > </html>
>> > --
>> >
>> > HomePage.java:
>> > --
>> > [...]
>> >
>> > public class HomePage
>> >      extends BasePage {
>> >
>> >   Panel mainPanel;
>> >   Label linktekst;
>> >
>> >
>> >   public HomePage() {
>> >      this(null);
>> >   }
>> >
>> >
>> >   public HomePage(PageParameters pars) {
>> > [...]
>> >      add(new RoutePanel("route"));
>> >
>> >
>> >      if (pars != null) {
>> >         mainPanel = new BlogPanel("mainpanel", pars.getAsInteger("id"));
>> >      }
>> >      else {
>> >         mainPanel = new BlogPanel("mainpanel");
>> >      }
>> >
>> >      add(mainPanel);
>> > [...]
>> >      add(new AjaxLazyLoadPanel("weer") {
>> >
>> >         @Override
>> >         public Component getLazyLoadComponent(String markupId) {
>> >            return new WeerPanel(markupId,
>> > reis.getBlogitemList().get(0).getLocation().getName());
>> >         }
>> >
>> >      });
>> >   }
>> >
>> > }
>> > --
>> >
>> > BlogPanel.html
>> > --
>> > [...]
>> >      <wicket:panel>
>> > [...]
>> >         <ul class="bloglist">
>> >            <li wicket:id="bloglist" class="blogitem">
>> > [...]
>> >                   <div wicket:id="commentaar" />
>> >                     </div>
>> > [...]
>> >            </li>
>> >         </ul>
>> > [...]
>> >      </wicket:panel>
>> >   </body>
>> > </html>
>> > --
>> >
>> > BlogPanel.java:
>> > --
>> > [...]
>> > public final class BlogPanel
>> >      extends Panel {
>> >
>> >   private static final int ITEMSPERPAGE = 3;
>> >
>> >   public BlogPanel(String id) {
>> >      this(id, 0);
>> >   }
>> >
>> >
>> >   public BlogPanel(final String id, final int blogid) {
>> >      super(id);
>> >
>> >      setOutputMarkupId(true);
>> >
>> > [...]
>> >      List<Blogitem> blogitemList =
>> >            Q.EM.createNamedQuery("Blogitem.findAll", Blogitem.class).
>> >            setHint(QueryHints.REFRESH, HintValues.TRUE).getResultList();
>> >
>> >      BlogListView blogListView = new BlogListView(
>> >            "bloglist",
>> >            new ListDataProvider(blogitemList),
>> >            ITEMSPERPAGE) {
>> >
>> >         @Override
>> >         protected void populateItem(final Item<Blogitem> item) {
>> >
>> > [...]
>> >            item.add(new AjaxLazyLoadPanel("commentaar") {
>> >
>> >               @Override
>> >               public Component getLazyLoadComponent(String markupId) {
>> >                  return new CommentaarPanel(markupId,
>> > item.getModelObject());
>> >               }
>> >
>> >            });
>> > [...]
>> >         }
>> >
>> >      };
>> >
>> > [...]
>> >      add(blogListView);
>> >
>> > [...]
>> > }
>> >
>> > abstract class BlogListView
>> >      extends DataView<Blogitem> {
>> >
>> >   BlogListView(String id, ListDataProvider ldp, int i) {
>> >      super(id, ldp, i);
>> >   }
>> >
>> > [...]
>> >   }
>> > }
>> > --
>> >
>> > CommentaarPanel.html:
>> > --
>> > [...]
>> >   <body>
>> >      <wicket:panel>
>> >         <div wicket:id="commentaarToevoegen" />
>> >         <ul>
>> >            <li wicket:id="commentaarList" class="commentaar">
>> >               <p class="zegt"><span wicket:id="tijdstip" /> - <span
>> > wicket:id="commentator" class="schrift commentator" /> laat weten:</p>
>> >               <p wicket:id="tekst" class="schrift" />
>> >            </li>
>> >            <div wicket:id="commentaarNav" class="navigator
>> navigatordown"
>> > />
>> >         </ul>
>> >      </wicket:panel>
>> >   </body>
>> > </html>
>> > --
>> >
>> > CommentaarPanel.java:
>> > --
>> > [...]
>> > public final class CommentaarPanel
>> >      extends Panel {
>> >
>> >   private Blogitem blog;
>> >   private List<Comment> commentList;
>> >   private DataView<Comment> commentListView;
>> >
>> >
>> >   public CommentaarPanel(String id, Blogitem blog) {
>> >      super(id);
>> >
>> >      this.blog = blog;
>> >
>> >      setOutputMarkupId(true);
>> >
>> >      commentList = blog.getCommentList();
>> >      Collections.sort(commentList);
>> >      commentListView =
>> >            new DataView<Comment>("commentaarList",
>> >                                  new ListDataProvider(commentList),
>> >                                  5) {
>> >
>> >               @Override
>> >               protected void populateItem(Item<Comment> item) {
>> >                  item.add(new Label("tekst",
>> > item.getModelObject().getText()));
>> >                  item.add(new Label("commentator",
>> > item.getModelObject().getName()));
>> >                  item.add(new Label("tijdstip",
>> > Q.DF.format(item.getModelObject().getTimestamp())));
>> >               }
>> >
>> >            };
>> >      add(commentListView);
>> >      add(new AjaxPagingNavigator("commentaarNav", commentListView) {
>> >
>> >         @Override
>> >         public boolean isVisible() {
>> >            return this.getPageable().getPageCount() > 1;
>> >         }
>> >
>> >      });
>> >      add(new CommentaarToevoegenPanel("commentaarToevoegen", this));
>> >   }
>> >
>> >
>> >   public Blogitem getBlog() {
>> >      return blog;
>> >   }
>> >
>> >
>> >   public List<Comment> getCommentList() {
>> >      return commentList;
>> >   }
>> >
>> >
>> >   public DataView<Comment> getCommentListView() {
>> >      return commentListView;
>> >   }
>> >
>> > }
>> > --
>> >
>> >
>> > WeerPanel.html:
>> > --
>> > [...]
>> >   <body>
>> >      <wicket:panel>
>> >         <span wicket:id="locatie" /><br />
>> >         <img wicket:id="icoonhuidig" class="weericoon" />
>> >         <p>temperatuur: <span wicket:id="temperatuur" />&deg;C<br />
>> >         vochtigheid: <span wicket:id="vochtigheid" /><br />
>> >         wind: <span wicket:id="wind" /></p>
>> >      </wicket:panel>
>> >   </body>
>> > </html>
>> > --
>> >
>> > WeerPanel.java:
>> > --
>> > [...]
>> > public final class WeerPanel
>> >      extends Panel {
>> >
>> >   private String locatie;
>> >
>> >   public WeerPanel(String id, String locatie) {
>> >      super(id);
>> >      this.locatie = locatie;
>> >      init();
>> >   }
>> >
>> >
>> >   public WeerPanel(String id) {
>> >      this(id, "Brugge");
>> >   }
>> >
>> >
>> >   private void init() {
>> >      Document doc = null;
>> >      {
>> >         InputStream in = null;
>> >         try {
>> >            URL xmlUrl = new URL("http://www.google.com/ig/api?weather="
>> +
>> > locatie);
>> >            in = xmlUrl.openStream();
>> >            doc = parse(in);
>> >         }
>> >         catch (MalformedURLException ex) {
>> >            Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
>> > null, ex);
>> >         }
>> >         catch (IOException ex) {
>> >            Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
>> > null, ex);
>> >         }
>> >         finally {
>> >            if (in != null) {
>> >               try {
>> >                  in.close();
>> >               }
>> >               catch (IOException ex) {
>> >
>> > Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE, null, ex);
>> >               }
>> >            }
>> >         }
>> >      }
>> >
>> >      String locatieString = "<ongekend>";
>> >      String srcicon = "http://www.google.com";
>> >      String temperatuur = "<?>";
>> >      String vochtigheid = "<?>";
>> >      String wind = "<?>";
>> >
>> >      if (doc != null) {
>> >         locatieString =
>> >
>> >
>>  doc.getElementsByTagName("city").item(0).getAttributes().getNamedItem("data").getNodeValue();
>> >         NodeList nl =
>> > doc.getElementsByTagName("current_conditions").item(0).getChildNodes();
>> >         for (int i = 0; i < nl.getLength(); i++) {
>> >            Node n = nl.item(i);
>> >            if (n.getNodeName().equals("icon")) {
>> >               srcicon +=
>> > n.getAttributes().getNamedItem("data").getNodeValue();
>> >            }
>> >            else if (n.getNodeName().equals("temp_c")) {
>> >               temperatuur =
>> > n.getAttributes().getNamedItem("data").getNodeValue();
>> >            }
>> >            else if (n.getNodeName().equals("humidity")) {
>> >               vochtigheid =
>> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>> >            }
>> >            else if (n.getNodeName().equals("wind_condition")) {
>> >               wind =
>> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>> >            }
>> >         }
>> >      }
>> >
>> >      add(new Label("locatie", locatieString));
>> >      add(new StaticImage("icoonhuidig", srcicon));
>> >      Label temperatuurLabel = new Label("temperatuur", temperatuur);
>> >      temperatuurLabel.setRenderBodyOnly(true);
>> >      add(temperatuurLabel);
>> >      Label vochtigheidLabel = new Label("vochtigheid", vochtigheid);
>> >      vochtigheidLabel.setRenderBodyOnly(true);
>> >      add(vochtigheidLabel);
>> >      Label windLabel = new Label("wind", wind);
>> >      windLabel.setRenderBodyOnly(true);
>> >      add(windLabel);
>> >
>> >   }
>> >
>> >
>> >   public static Document parse(InputStream is) {
>> >      Document ret = null;
>> >      DocumentBuilderFactory domFactory;
>> >      DocumentBuilder builder;
>> >
>> >      try {
>> >         domFactory = DocumentBuilderFactory.newInstance();
>> >         domFactory.setValidating(false);
>> >         domFactory.setNamespaceAware(false);
>> >         builder = domFactory.newDocumentBuilder();
>> >
>> >         ret = builder.parse(is);
>> >      }
>> >      catch (Exception ex) {
>> >         System.err.println("unable to load XML: " + ex);
>> >      }
>> >      return ret;
>> >   }
>> >
>> > }
>> > --
>> >
>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: ajax GET stopped because of precondition check

Posted by Kurt Sys <ku...@gmail.com>.
The lazy loading example seems to work fine (I tried Wicket 1.4.17, the one
I'm using too).

For some reason 'precondition()' returns false in IE when called from my
app. The code loading the panels is really straight forward. I can't think
of any reason (for now) why the precondition returns false, only in IE, and
even not for all lazyloadpanels.
I have actually no idea where precondition is changed or something - I
checked the js file (wicket-ajax.js) and there the function of the prototype
just returns true (see below). So, precondition it is changed somewhere, for
some reason, and probably something in a javascript-file of wicket that is
called from my code IE doesn't like (other browsers don't complain). What
code can be wrong? Something 'wrong' in the html-files? Style files (which
would be very odd, if you ask me)?

--

Wicket.Ajax.Request.prototype = {
    // Creates a new request object.	initialize: function(url,
loadedCallback, parseResponse, randomURL, failureHandler, channel) {
		this.url = url;
		this.loadedCallback = loadedCallback;
		// whether we should give the loadedCallback parsed response (DOM
tree) or the raw string		this.parseResponse = parseResponse != null ?
parseResponse : true;
		this.randomURL = randomURL != null ? randomURL : true;
		this.failureHandler = failureHandler != null ? failureHandler :
function() { };
		this.async = true;
		this.channel = channel;
		this.precondition = function() { return true; } // allow a condition
to block request
		// when suppressDone is set, the loadedCallback is responsible for
calling		// Ajax.Request.done() to process possibly pendings requests
in the channel.		this.suppressDone = false;
		this.instance = Math.random();
		this.debugContent = true;
	},
--	




2011/7/3 Martin Grigorov <mg...@apache.org>

> Can you check http://wicketstuff.org/wicket/ajax/lazy-loading ?
> This is Wicket 1.5-RC5.1 and it works for me with IE8.
>
> Wicket 1.4.17 at http://wicketstuff.org/wicket14/ajax/lazy-loading
>
> On Sat, Jul 2, 2011 at 5:16 PM, Kurt Sys <ku...@gmail.com> wrote:
> > Hey all,
> >
> > In IE, I can't get lazyloadpanels to load. I have a webapp with some
> > lazyloadpanels, and none of them loads in IE - in other browsers, there
> is
> > no problem. (Also, the content of an iframe doesn't load, which seems to
> be
> > related, since it is also an ajax-request.) I've been trying both IE 8
> and
> > IE 9 on three different pc's. Can someone give me a clue why it won't
> work
> > in IE? (IE security settings are set to low, scripts etc are
> > enabled/allowed, so I suppose ajax-requests can be performed... if not, I
> > have no clue how to allow ajax in IE.) You may check it out:
> > http://www.tinyleaps.be
> >
> > I've been checking on similar problems with lazyloadpanel in ie, and the
> > problem was known in 2008 (if it's the same, but it looks really
> similar):
> > http://www.mail-archive.com/users@wicket.apache.org/msg18815.html
> > There seems to be a bug report and a 'fixed' status, although it doesn't
> > seem to work out fine for me - the last comment states that the fix is
> not
> > confirmed. Or I am  missing something, which wouldn't really surprise me
> :),
> > or there still something wrong with the precondition stuff and loading
> the
> > panel in IE:
> > https://issues.apache.org/jira/browse/WICKET-1653
> >
> >
> > Ajax debug window (only these three lines):
> > --
> > INFO: Ajax GET stopped because of precondition check,
> >
> url:?wicket:interface=:3:mainpanel:bloglist:1:commentaar::IBehaviorListener:0:
> > INFO: Ajax GET stopped because of precondition check,
> >
> url:?wicket:interface=:3:mainpanel:bloglist:2:commentaar::IBehaviorListener:0:
> > INFO: Ajax GET stopped because of precondition check,
> > url:?wicket:interface=:3:weer::IBehaviorListener:0:
> > --
> >
> > HomePage.html:
> > --
> > [...]
> > <body>
> > <wicket:extend>
> > [...]
> >      <div wicket:id="route" />
> > [...]
> >            <div wicket:id="mainpanel" />
> > [...]
> >            <div wicket:id="weer" class="weer" >&nbsp;
> >            </div>
> > [...]
> >      </div>
> > </wicket:extend>
> > </body>
> > </html>
> > --
> >
> > HomePage.java:
> > --
> > [...]
> >
> > public class HomePage
> >      extends BasePage {
> >
> >   Panel mainPanel;
> >   Label linktekst;
> >
> >
> >   public HomePage() {
> >      this(null);
> >   }
> >
> >
> >   public HomePage(PageParameters pars) {
> > [...]
> >      add(new RoutePanel("route"));
> >
> >
> >      if (pars != null) {
> >         mainPanel = new BlogPanel("mainpanel", pars.getAsInteger("id"));
> >      }
> >      else {
> >         mainPanel = new BlogPanel("mainpanel");
> >      }
> >
> >      add(mainPanel);
> > [...]
> >      add(new AjaxLazyLoadPanel("weer") {
> >
> >         @Override
> >         public Component getLazyLoadComponent(String markupId) {
> >            return new WeerPanel(markupId,
> > reis.getBlogitemList().get(0).getLocation().getName());
> >         }
> >
> >      });
> >   }
> >
> > }
> > --
> >
> > BlogPanel.html
> > --
> > [...]
> >      <wicket:panel>
> > [...]
> >         <ul class="bloglist">
> >            <li wicket:id="bloglist" class="blogitem">
> > [...]
> >                   <div wicket:id="commentaar" />
> >                     </div>
> > [...]
> >            </li>
> >         </ul>
> > [...]
> >      </wicket:panel>
> >   </body>
> > </html>
> > --
> >
> > BlogPanel.java:
> > --
> > [...]
> > public final class BlogPanel
> >      extends Panel {
> >
> >   private static final int ITEMSPERPAGE = 3;
> >
> >   public BlogPanel(String id) {
> >      this(id, 0);
> >   }
> >
> >
> >   public BlogPanel(final String id, final int blogid) {
> >      super(id);
> >
> >      setOutputMarkupId(true);
> >
> > [...]
> >      List<Blogitem> blogitemList =
> >            Q.EM.createNamedQuery("Blogitem.findAll", Blogitem.class).
> >            setHint(QueryHints.REFRESH, HintValues.TRUE).getResultList();
> >
> >      BlogListView blogListView = new BlogListView(
> >            "bloglist",
> >            new ListDataProvider(blogitemList),
> >            ITEMSPERPAGE) {
> >
> >         @Override
> >         protected void populateItem(final Item<Blogitem> item) {
> >
> > [...]
> >            item.add(new AjaxLazyLoadPanel("commentaar") {
> >
> >               @Override
> >               public Component getLazyLoadComponent(String markupId) {
> >                  return new CommentaarPanel(markupId,
> > item.getModelObject());
> >               }
> >
> >            });
> > [...]
> >         }
> >
> >      };
> >
> > [...]
> >      add(blogListView);
> >
> > [...]
> > }
> >
> > abstract class BlogListView
> >      extends DataView<Blogitem> {
> >
> >   BlogListView(String id, ListDataProvider ldp, int i) {
> >      super(id, ldp, i);
> >   }
> >
> > [...]
> >   }
> > }
> > --
> >
> > CommentaarPanel.html:
> > --
> > [...]
> >   <body>
> >      <wicket:panel>
> >         <div wicket:id="commentaarToevoegen" />
> >         <ul>
> >            <li wicket:id="commentaarList" class="commentaar">
> >               <p class="zegt"><span wicket:id="tijdstip" /> - <span
> > wicket:id="commentator" class="schrift commentator" /> laat weten:</p>
> >               <p wicket:id="tekst" class="schrift" />
> >            </li>
> >            <div wicket:id="commentaarNav" class="navigator navigatordown"
> > />
> >         </ul>
> >      </wicket:panel>
> >   </body>
> > </html>
> > --
> >
> > CommentaarPanel.java:
> > --
> > [...]
> > public final class CommentaarPanel
> >      extends Panel {
> >
> >   private Blogitem blog;
> >   private List<Comment> commentList;
> >   private DataView<Comment> commentListView;
> >
> >
> >   public CommentaarPanel(String id, Blogitem blog) {
> >      super(id);
> >
> >      this.blog = blog;
> >
> >      setOutputMarkupId(true);
> >
> >      commentList = blog.getCommentList();
> >      Collections.sort(commentList);
> >      commentListView =
> >            new DataView<Comment>("commentaarList",
> >                                  new ListDataProvider(commentList),
> >                                  5) {
> >
> >               @Override
> >               protected void populateItem(Item<Comment> item) {
> >                  item.add(new Label("tekst",
> > item.getModelObject().getText()));
> >                  item.add(new Label("commentator",
> > item.getModelObject().getName()));
> >                  item.add(new Label("tijdstip",
> > Q.DF.format(item.getModelObject().getTimestamp())));
> >               }
> >
> >            };
> >      add(commentListView);
> >      add(new AjaxPagingNavigator("commentaarNav", commentListView) {
> >
> >         @Override
> >         public boolean isVisible() {
> >            return this.getPageable().getPageCount() > 1;
> >         }
> >
> >      });
> >      add(new CommentaarToevoegenPanel("commentaarToevoegen", this));
> >   }
> >
> >
> >   public Blogitem getBlog() {
> >      return blog;
> >   }
> >
> >
> >   public List<Comment> getCommentList() {
> >      return commentList;
> >   }
> >
> >
> >   public DataView<Comment> getCommentListView() {
> >      return commentListView;
> >   }
> >
> > }
> > --
> >
> >
> > WeerPanel.html:
> > --
> > [...]
> >   <body>
> >      <wicket:panel>
> >         <span wicket:id="locatie" /><br />
> >         <img wicket:id="icoonhuidig" class="weericoon" />
> >         <p>temperatuur: <span wicket:id="temperatuur" />&deg;C<br />
> >         vochtigheid: <span wicket:id="vochtigheid" /><br />
> >         wind: <span wicket:id="wind" /></p>
> >      </wicket:panel>
> >   </body>
> > </html>
> > --
> >
> > WeerPanel.java:
> > --
> > [...]
> > public final class WeerPanel
> >      extends Panel {
> >
> >   private String locatie;
> >
> >   public WeerPanel(String id, String locatie) {
> >      super(id);
> >      this.locatie = locatie;
> >      init();
> >   }
> >
> >
> >   public WeerPanel(String id) {
> >      this(id, "Brugge");
> >   }
> >
> >
> >   private void init() {
> >      Document doc = null;
> >      {
> >         InputStream in = null;
> >         try {
> >            URL xmlUrl = new URL("http://www.google.com/ig/api?weather="
> +
> > locatie);
> >            in = xmlUrl.openStream();
> >            doc = parse(in);
> >         }
> >         catch (MalformedURLException ex) {
> >            Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
> > null, ex);
> >         }
> >         catch (IOException ex) {
> >            Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
> > null, ex);
> >         }
> >         finally {
> >            if (in != null) {
> >               try {
> >                  in.close();
> >               }
> >               catch (IOException ex) {
> >
> > Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE, null, ex);
> >               }
> >            }
> >         }
> >      }
> >
> >      String locatieString = "<ongekend>";
> >      String srcicon = "http://www.google.com";
> >      String temperatuur = "<?>";
> >      String vochtigheid = "<?>";
> >      String wind = "<?>";
> >
> >      if (doc != null) {
> >         locatieString =
> >
> >
>  doc.getElementsByTagName("city").item(0).getAttributes().getNamedItem("data").getNodeValue();
> >         NodeList nl =
> > doc.getElementsByTagName("current_conditions").item(0).getChildNodes();
> >         for (int i = 0; i < nl.getLength(); i++) {
> >            Node n = nl.item(i);
> >            if (n.getNodeName().equals("icon")) {
> >               srcicon +=
> > n.getAttributes().getNamedItem("data").getNodeValue();
> >            }
> >            else if (n.getNodeName().equals("temp_c")) {
> >               temperatuur =
> > n.getAttributes().getNamedItem("data").getNodeValue();
> >            }
> >            else if (n.getNodeName().equals("humidity")) {
> >               vochtigheid =
> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
> >            }
> >            else if (n.getNodeName().equals("wind_condition")) {
> >               wind =
> > n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
> >            }
> >         }
> >      }
> >
> >      add(new Label("locatie", locatieString));
> >      add(new StaticImage("icoonhuidig", srcicon));
> >      Label temperatuurLabel = new Label("temperatuur", temperatuur);
> >      temperatuurLabel.setRenderBodyOnly(true);
> >      add(temperatuurLabel);
> >      Label vochtigheidLabel = new Label("vochtigheid", vochtigheid);
> >      vochtigheidLabel.setRenderBodyOnly(true);
> >      add(vochtigheidLabel);
> >      Label windLabel = new Label("wind", wind);
> >      windLabel.setRenderBodyOnly(true);
> >      add(windLabel);
> >
> >   }
> >
> >
> >   public static Document parse(InputStream is) {
> >      Document ret = null;
> >      DocumentBuilderFactory domFactory;
> >      DocumentBuilder builder;
> >
> >      try {
> >         domFactory = DocumentBuilderFactory.newInstance();
> >         domFactory.setValidating(false);
> >         domFactory.setNamespaceAware(false);
> >         builder = domFactory.newDocumentBuilder();
> >
> >         ret = builder.parse(is);
> >      }
> >      catch (Exception ex) {
> >         System.err.println("unable to load XML: " + ex);
> >      }
> >      return ret;
> >   }
> >
> > }
> > --
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: ajax GET stopped because of precondition check

Posted by Martin Grigorov <mg...@apache.org>.
Can you check http://wicketstuff.org/wicket/ajax/lazy-loading ?
This is Wicket 1.5-RC5.1 and it works for me with IE8.

Wicket 1.4.17 at http://wicketstuff.org/wicket14/ajax/lazy-loading

On Sat, Jul 2, 2011 at 5:16 PM, Kurt Sys <ku...@gmail.com> wrote:
> Hey all,
>
> In IE, I can't get lazyloadpanels to load. I have a webapp with some
> lazyloadpanels, and none of them loads in IE - in other browsers, there is
> no problem. (Also, the content of an iframe doesn't load, which seems to be
> related, since it is also an ajax-request.) I've been trying both IE 8 and
> IE 9 on three different pc's. Can someone give me a clue why it won't work
> in IE? (IE security settings are set to low, scripts etc are
> enabled/allowed, so I suppose ajax-requests can be performed... if not, I
> have no clue how to allow ajax in IE.) You may check it out:
> http://www.tinyleaps.be
>
> I've been checking on similar problems with lazyloadpanel in ie, and the
> problem was known in 2008 (if it's the same, but it looks really similar):
> http://www.mail-archive.com/users@wicket.apache.org/msg18815.html
> There seems to be a bug report and a 'fixed' status, although it doesn't
> seem to work out fine for me - the last comment states that the fix is not
> confirmed. Or I am  missing something, which wouldn't really surprise me :),
> or there still something wrong with the precondition stuff and loading the
> panel in IE:
> https://issues.apache.org/jira/browse/WICKET-1653
>
>
> Ajax debug window (only these three lines):
> --
> INFO: Ajax GET stopped because of precondition check,
> url:?wicket:interface=:3:mainpanel:bloglist:1:commentaar::IBehaviorListener:0:
> INFO: Ajax GET stopped because of precondition check,
> url:?wicket:interface=:3:mainpanel:bloglist:2:commentaar::IBehaviorListener:0:
> INFO: Ajax GET stopped because of precondition check,
> url:?wicket:interface=:3:weer::IBehaviorListener:0:
> --
>
> HomePage.html:
> --
> [...]
> <body>
> <wicket:extend>
> [...]
>      <div wicket:id="route" />
> [...]
>            <div wicket:id="mainpanel" />
> [...]
>            <div wicket:id="weer" class="weer" >&nbsp;
>            </div>
> [...]
>      </div>
> </wicket:extend>
> </body>
> </html>
> --
>
> HomePage.java:
> --
> [...]
>
> public class HomePage
>      extends BasePage {
>
>   Panel mainPanel;
>   Label linktekst;
>
>
>   public HomePage() {
>      this(null);
>   }
>
>
>   public HomePage(PageParameters pars) {
> [...]
>      add(new RoutePanel("route"));
>
>
>      if (pars != null) {
>         mainPanel = new BlogPanel("mainpanel", pars.getAsInteger("id"));
>      }
>      else {
>         mainPanel = new BlogPanel("mainpanel");
>      }
>
>      add(mainPanel);
> [...]
>      add(new AjaxLazyLoadPanel("weer") {
>
>         @Override
>         public Component getLazyLoadComponent(String markupId) {
>            return new WeerPanel(markupId,
> reis.getBlogitemList().get(0).getLocation().getName());
>         }
>
>      });
>   }
>
> }
> --
>
> BlogPanel.html
> --
> [...]
>      <wicket:panel>
> [...]
>         <ul class="bloglist">
>            <li wicket:id="bloglist" class="blogitem">
> [...]
>                   <div wicket:id="commentaar" />
>                     </div>
> [...]
>            </li>
>         </ul>
> [...]
>      </wicket:panel>
>   </body>
> </html>
> --
>
> BlogPanel.java:
> --
> [...]
> public final class BlogPanel
>      extends Panel {
>
>   private static final int ITEMSPERPAGE = 3;
>
>   public BlogPanel(String id) {
>      this(id, 0);
>   }
>
>
>   public BlogPanel(final String id, final int blogid) {
>      super(id);
>
>      setOutputMarkupId(true);
>
> [...]
>      List<Blogitem> blogitemList =
>            Q.EM.createNamedQuery("Blogitem.findAll", Blogitem.class).
>            setHint(QueryHints.REFRESH, HintValues.TRUE).getResultList();
>
>      BlogListView blogListView = new BlogListView(
>            "bloglist",
>            new ListDataProvider(blogitemList),
>            ITEMSPERPAGE) {
>
>         @Override
>         protected void populateItem(final Item<Blogitem> item) {
>
> [...]
>            item.add(new AjaxLazyLoadPanel("commentaar") {
>
>               @Override
>               public Component getLazyLoadComponent(String markupId) {
>                  return new CommentaarPanel(markupId,
> item.getModelObject());
>               }
>
>            });
> [...]
>         }
>
>      };
>
> [...]
>      add(blogListView);
>
> [...]
> }
>
> abstract class BlogListView
>      extends DataView<Blogitem> {
>
>   BlogListView(String id, ListDataProvider ldp, int i) {
>      super(id, ldp, i);
>   }
>
> [...]
>   }
> }
> --
>
> CommentaarPanel.html:
> --
> [...]
>   <body>
>      <wicket:panel>
>         <div wicket:id="commentaarToevoegen" />
>         <ul>
>            <li wicket:id="commentaarList" class="commentaar">
>               <p class="zegt"><span wicket:id="tijdstip" /> - <span
> wicket:id="commentator" class="schrift commentator" /> laat weten:</p>
>               <p wicket:id="tekst" class="schrift" />
>            </li>
>            <div wicket:id="commentaarNav" class="navigator navigatordown"
> />
>         </ul>
>      </wicket:panel>
>   </body>
> </html>
> --
>
> CommentaarPanel.java:
> --
> [...]
> public final class CommentaarPanel
>      extends Panel {
>
>   private Blogitem blog;
>   private List<Comment> commentList;
>   private DataView<Comment> commentListView;
>
>
>   public CommentaarPanel(String id, Blogitem blog) {
>      super(id);
>
>      this.blog = blog;
>
>      setOutputMarkupId(true);
>
>      commentList = blog.getCommentList();
>      Collections.sort(commentList);
>      commentListView =
>            new DataView<Comment>("commentaarList",
>                                  new ListDataProvider(commentList),
>                                  5) {
>
>               @Override
>               protected void populateItem(Item<Comment> item) {
>                  item.add(new Label("tekst",
> item.getModelObject().getText()));
>                  item.add(new Label("commentator",
> item.getModelObject().getName()));
>                  item.add(new Label("tijdstip",
> Q.DF.format(item.getModelObject().getTimestamp())));
>               }
>
>            };
>      add(commentListView);
>      add(new AjaxPagingNavigator("commentaarNav", commentListView) {
>
>         @Override
>         public boolean isVisible() {
>            return this.getPageable().getPageCount() > 1;
>         }
>
>      });
>      add(new CommentaarToevoegenPanel("commentaarToevoegen", this));
>   }
>
>
>   public Blogitem getBlog() {
>      return blog;
>   }
>
>
>   public List<Comment> getCommentList() {
>      return commentList;
>   }
>
>
>   public DataView<Comment> getCommentListView() {
>      return commentListView;
>   }
>
> }
> --
>
>
> WeerPanel.html:
> --
> [...]
>   <body>
>      <wicket:panel>
>         <span wicket:id="locatie" /><br />
>         <img wicket:id="icoonhuidig" class="weericoon" />
>         <p>temperatuur: <span wicket:id="temperatuur" />&deg;C<br />
>         vochtigheid: <span wicket:id="vochtigheid" /><br />
>         wind: <span wicket:id="wind" /></p>
>      </wicket:panel>
>   </body>
> </html>
> --
>
> WeerPanel.java:
> --
> [...]
> public final class WeerPanel
>      extends Panel {
>
>   private String locatie;
>
>   public WeerPanel(String id, String locatie) {
>      super(id);
>      this.locatie = locatie;
>      init();
>   }
>
>
>   public WeerPanel(String id) {
>      this(id, "Brugge");
>   }
>
>
>   private void init() {
>      Document doc = null;
>      {
>         InputStream in = null;
>         try {
>            URL xmlUrl = new URL("http://www.google.com/ig/api?weather=" +
> locatie);
>            in = xmlUrl.openStream();
>            doc = parse(in);
>         }
>         catch (MalformedURLException ex) {
>            Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
> null, ex);
>         }
>         catch (IOException ex) {
>            Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE,
> null, ex);
>         }
>         finally {
>            if (in != null) {
>               try {
>                  in.close();
>               }
>               catch (IOException ex) {
>
> Logger.getLogger(WeerPanel.class.getName()).log(Level.SEVERE, null, ex);
>               }
>            }
>         }
>      }
>
>      String locatieString = "<ongekend>";
>      String srcicon = "http://www.google.com";
>      String temperatuur = "<?>";
>      String vochtigheid = "<?>";
>      String wind = "<?>";
>
>      if (doc != null) {
>         locatieString =
>
>  doc.getElementsByTagName("city").item(0).getAttributes().getNamedItem("data").getNodeValue();
>         NodeList nl =
> doc.getElementsByTagName("current_conditions").item(0).getChildNodes();
>         for (int i = 0; i < nl.getLength(); i++) {
>            Node n = nl.item(i);
>            if (n.getNodeName().equals("icon")) {
>               srcicon +=
> n.getAttributes().getNamedItem("data").getNodeValue();
>            }
>            else if (n.getNodeName().equals("temp_c")) {
>               temperatuur =
> n.getAttributes().getNamedItem("data").getNodeValue();
>            }
>            else if (n.getNodeName().equals("humidity")) {
>               vochtigheid =
> n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>            }
>            else if (n.getNodeName().equals("wind_condition")) {
>               wind =
> n.getAttributes().getNamedItem("data").getNodeValue().split(": ")[1];
>            }
>         }
>      }
>
>      add(new Label("locatie", locatieString));
>      add(new StaticImage("icoonhuidig", srcicon));
>      Label temperatuurLabel = new Label("temperatuur", temperatuur);
>      temperatuurLabel.setRenderBodyOnly(true);
>      add(temperatuurLabel);
>      Label vochtigheidLabel = new Label("vochtigheid", vochtigheid);
>      vochtigheidLabel.setRenderBodyOnly(true);
>      add(vochtigheidLabel);
>      Label windLabel = new Label("wind", wind);
>      windLabel.setRenderBodyOnly(true);
>      add(windLabel);
>
>   }
>
>
>   public static Document parse(InputStream is) {
>      Document ret = null;
>      DocumentBuilderFactory domFactory;
>      DocumentBuilder builder;
>
>      try {
>         domFactory = DocumentBuilderFactory.newInstance();
>         domFactory.setValidating(false);
>         domFactory.setNamespaceAware(false);
>         builder = domFactory.newDocumentBuilder();
>
>         ret = builder.parse(is);
>      }
>      catch (Exception ex) {
>         System.err.println("unable to load XML: " + ex);
>      }
>      return ret;
>   }
>
> }
> --
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org