You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Juergen Donnerstag (JIRA)" <ji...@apache.org> on 2009/01/24 23:45:59 UTC

[jira] Resolved: (WICKET-2030) BaseWicketTester can't find the pageLink field using reflection when you override the PageLink class.

     [ https://issues.apache.org/jira/browse/WICKET-2030?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juergen Donnerstag resolved WICKET-2030.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.4-RC2
         Assignee: Juergen Donnerstag

thanks

> BaseWicketTester can't find the pageLink field using reflection when you override the PageLink class.
> -----------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-2030
>                 URL: https://issues.apache.org/jira/browse/WICKET-2030
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4-RC1
>            Reporter: Maarten Billemont
>            Assignee: Juergen Donnerstag
>             Fix For: 1.4-RC2
>
>         Attachments: pagelink.patch
>
>
> Currently, BaseWicketTester (line 524) does this:
> 	public <C extends Page> Result isPageLink(String path, Class<C> expectedPageClass)
> 	{
> 		PageLink<?> pageLink = (PageLink<?>)getComponentFromLastRenderedPage(path);
> 		try
> 		{
> 			Field iPageLinkField = pageLink.getClass().getDeclaredField("pageLink");
> 			iPageLinkField.setAccessible(true);
> 			IPageLink iPageLink = (IPageLink)iPageLinkField.get(pageLink);
> 			return isEqual(expectedPageClass, iPageLink.getPageIdentity());
> 		}
> The problem manifests when you want to customize a page link's onClick by overriding it like this:
> new PageLink<AuthPage>("pageLink", AuthPage.class) {
>             private static final long serialVersionUID = 1L;
>             @Override
>             public void onClick() {
>                 Foo.bar();
>                 super.onClick();
>             }
> });
> As a result; the BaseWicketTester tries to look for the pageLink field in the anonymous class instead of the privately declared pageLink field in the PageLink class.
> BaseWicketTester should either go down the tree:
> for(Class type = pageLink.getClass(); type != Object.class; type = type.getSuperclass())
> Or a getter should be made for the pageLink field. (This is what Java wants you to do).

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