Github user pedrosans commented on a diff in the pull request:

    https://github.com/apache/wicket/pull/210#discussion_r99943000
  
    --- Diff: 
wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageProvider.java
 ---
    @@ -197,26 +194,49 @@ else if (isNewPageInstance() == false)
        }
     
        /**
    -    * The page instance is new only if there is no cached instance or the 
data stores doesn't have
    -    * a page with that id with the same {@linkplain #pageClass}.
    -    * 
    -    * @see IPageProvider#isNewPageInstance()
    +    * @return negates {@link PageProvider#hasPageInstance()}
    +    * @deprecated use {@link PageProvider#hasPageInstance()} negation 
instead
         */
        @Override
        public boolean isNewPageInstance()
        {
    -           boolean isNew = pageInstance == null;
    -           if (isNew && pageId != null)
    +           return !hasPageInstance();
    +   }
    +
    +   /**
    +    * If this provider returns existing page, regardless if it was already 
created by PageProvider
    +    * itself or is or can be found in the data store. The only guarantee 
is that by calling
    +    * {@link PageProvider#getPageInstance()} this provider will return an 
existing instance and no
    +    * page will be created.
    +    * 
    +    * @return if provides an existing page
    +    */
    +   @Override
    +   public final boolean hasPageInstance()
    +   {
    +           if (provision != null || pageId != null)
                {
    -                   IRequestablePage storedPageInstance = 
getStoredPage(pageId);
    -                   if (storedPageInstance != null)
    -                   {
    -                           pageInstance = storedPageInstance;
    -                           isNew = false;
    -                   }
    +                   return getProvision().didResolveToPage();
                }
    +           else
    +                   return false;
    +   }
     
    -           return isNew;
    +   /**
    +    * Returns whether or not the page instance held by this provider has 
been instantiated by the
    +    * provider.
    +    * 
    +    * @return {@code true} iff the page instance held by this provider was 
instantiated by the
    +    *         provider
    +    */
    +   @Override
    +   public final boolean doesProvideNewPage()
    +   {
    +           if (provision == null)
    +           {
    +                   throw new IllegalStateException("Page instance not yet 
resolved");
    --- End diff --
    
    Looking bad indeed, I fixed later during my work on the branch: 
https://github.com/apache/wicket/pull/210/commits/b64f2b4b2cb50a594cabb50a0c1eeca43485f6b9#diff-36b11db0d92a540368a080c520de953aL177
    
    The three states looks overcomplicated. There's no place in Wicket core 
needing to test such flag for the value "OLD".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to