[ 
https://issues.apache.org/jira/browse/WICKET-2920?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12880370#action_12880370
 ] 

Jeremy Thomerson commented on WICKET-2920:
------------------------------------------

Please provide a quickstart that demonstrates this rather complex
description of an issue.  Thank you.




-- 
Jeremy Thomerson
http://www.wickettraining.com


> Repeaters fail to correctly display after a page render where the previous 
> page render was determined by the authorization strategy
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-2920
>                 URL: https://issues.apache.org/jira/browse/WICKET-2920
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.7
>         Environment: Windows XP - Jetty/Tomcat
>            Reporter: Nathan Collette
>
> First of all I want to say that this issue seems pretty similar to WICKET-943
> Here's what happens to the best of my understanding.
> A page renders with an unauthenticated user, where a ListView's 
> action=Component.RENDER in IAuthorizationStrategy is based on authentication. 
>  The page is loaded, and the component is not rendered because the user is 
> unauthenticated.  Then a user clicks the login -> redirectToInterceptPage.... 
>  However, upon returning to the page, the internalBeforeRender() method is 
> called on the ListView Component, and that method calls determineVisibility() 
> which is made up of 3 parts.  isVisible() which returns "true", 
> isVisibilityAllowed() which also returns "true" and isRenderAllowed() -- 
> which returns "false".  A "false" that is still based upon the previous 
> page's load where it checked the IAuthorizationStrategy Component.RENDER and 
> determined due to unauthentication that it should not be rendered.  And 
> because it returns false, determineVisiblity() returns false and the 
> onBeforeRender() method inside the internalBeforeRender() method is not 
> called and populateItems is also then never called.  After all that has 
> happened, then the Component.RENDER action is checked and it determines that 
> the component should be rendered...but it is too late to have the data on the 
> screen load properly because the popuplateItem's was never called.
> Here are some code snippets.  Note that in my particular use case the 
> AuthorizationStrategy was employed on the Container wrapping the list view, 
> but I also ran tests where the AuthorizationStrategy was directly on the 
> ListView.
> @Authorized
> public class MemberWebMarkupContainer extends WebMarkupContainer {
>  
>     public MemberWebMarkupContainer(String id) {
>         super(id);
>     }
> }
>  
> WebMarkupContainer isMember = new MemberWebMarkupContainer("isMember");
> isMember.add(new ListView<Consultant>("consultants", new 
> LoadableConsultantModel()) {
>  
>                 protected void populateItem(ListItem<Consultant> item) {
>                      
>                     Consultant consultant = item.getModelObject();
>                      
>                     item.add(new Label("name", consultant.getDisplayName()));
>                     item.add(new Label("phone", 
> consultant.getPhoneNumber()));                 
>                     item.add(new ExternalLink("emailLink", "mailto:"; + 
> consultant.getEmail(), consultant.getEmail()));
>                 }
>             };
> };
>  
> ....
>  
> public class HelpCenterAuthorizationStrategy implements 
> IAuthorizationStrategy, IUnauthorizedComponentInstantiationListener {
>  
>     @Override
>     public boolean isActionAuthorized(Component component, Action action) {
>          
>         if(action.equals(Component.RENDER)) {
>             Class<? extends Component> c = component.getClass();
>             Authorized authorized = c.getAnnotation(Authorized.class);
>  
>             if(authorized != null) {
>                 return HelpCenterSession.get().isAuthenticated();
>             }
>         }
>          
>         return true;
>     }
> }
> My current work-around for the problem is to modify my webMarkupContainer 
> like so:
> WebMarkupContainer isMember = new MemberWebMarkupContainer("isMember") {
>                       /*To get
>                        * around the issue of the ListView not properly 
> updating.
>                        * Methods of interest: 
> Component:callOnBeforeRenderIfNotVisible
>                        * Component:internalBeforeRender() **/
>                       @Override
>                       protected boolean callOnBeforeRenderIfNotVisible() {
>                               return true;
>                       };
>               };

-- 
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