Link: Why isn't the default implementation of Link.linksTo() 'return 
getResponsePage.equals(page)' ?
----------------------------------------------------------------------------------------------------

                 Key: WICKET-2464
                 URL: https://issues.apache.org/jira/browse/WICKET-2464
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
            Reporter: Knut Pape
            Priority: Minor


The default implementation of Link.linksTo(Page page) just returns false.
For a page that has state the defaults Link.linksTo(Page page) of a PageLink 
doesn't fit you should override this method and use an implementation that 
checks the state of that page.
More on this topic can be found at the bottom of the page 
http://cwiki.apache.org/confluence/display/WICKET/Bookmarkable .

---

This means that in cases where you are Linking to the same page from multiple 
places you have two options:
1. Re-implement the comparision logic on each site where a Link is created.
2. Create a specialized link class for this Page (you have to be aware of this 
and use it on all referencing Pages)

Just out of curiosity: Why isn't the default implementation of linksTo 'return 
getResponsePage.equals(page)' ?
This would mean that it is the responsibility of a state full page to implement 
equals() in a correct way.
Anyway, IMO the equals method of the Page is the place where comparison logic 
for comparing two pages belongs intuitively.

Regarding Regression we have 3 scenarios:
1. The equals method of the page was not overridden, the linksTo was also not 
overridden.
As long as both pages are not the same object instance (default equals 
implementation) you will still get false as a result.
2. The  linksTo method was implemented.
The linksTo override supersedes the implementation based on equals, so no 
change.
3. The equals method of a page was overridden with a meaningful implementation, 
linksTo() was not implemented.
This is a change compare to the original behavior which would have always 
returned false even if the two pages were the same.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to