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

Johan Compagner commented on WICKET-1872:
-----------------------------------------

you mean we keep the meta data if the behavior is removed?
and if there are no removed behaviors we just remove it?

what about keeping the index but just let there be a hole in it he behaviors 
list?

so if we have

behavior1
tempbehavior2
behavior3

and then we just make sure this happens:

behavior1
null
behavior3

dont know if our current storage can handle that easily and of course things 
like getBehaviors() must filter that

> Url for behaviour and isTemporary flag of behaviour.
> ----------------------------------------------------
>
>                 Key: WICKET-1872
>                 URL: https://issues.apache.org/jira/browse/WICKET-1872
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.4
>            Reporter: Stanislav Dvorscak
>            Priority: Critical
>
> You add two behaviors to the Component. First behavior is temporary and the 
> second is normal. 
> Now the wicket creates the url by "urlFor(final Component component, final 
> IBehavior behaviour, final RequestListenerInterface listener)" for second 
> behavior with behaviourId=1. On the end of request the wicket removes the 
> temporary behavior. Now the component contains only 1 but not 2 behaviors. 
> And in the next request in method "public final void processEvents(final 
> RequestCycle requestCycle)" the wicket  tries to find the behavior by its id. 
> But the problem is with if (component.getBehaviors().size() > idAsInt) 
> condition, and with the fact that index of behavior is incorrect.
> The problematic classes with their methods:
> *org.apache.wicket.RequestCycle:*
>       public final CharSequence urlFor(final Component component, final 
> IBehavior behaviour,
>               final RequestListenerInterface listener)
>       {
>               int index = component.getBehaviors().indexOf(behaviour);
>               if (index == -1)
>               {
>                       throw new IllegalArgumentException("Behavior " + this +
>                               " was not registered with this component: " + 
> component.toString());
>               }
>               RequestParameters params = new RequestParameters();
>               params.setBehaviorId(String.valueOf(index));
> ...
> ==============================================================================================
> *org.apache.wicket.request.target.component.listener.BehaviorRequestTarget*
>       public final void processEvents(final RequestCycle requestCycle)
>       {
>               // Preprocess like standard component request. Do all the 
> initialization
>               // necessary
>               onProcessEvents(requestCycle);
>               // Get the IBehavior for the component based on the request 
> parameters
>               final Component component = getTarget();
>               final String id = getRequestParameters().getBehaviorId();
>               if (id == null)
>               {
>                       throw new IllegalStateException(
>                                       "Parameter behaviorId was not provided: 
> unable to locate listener. Component: " +
>                                                       component.toString());
>               }
>               final int idAsInt = Integer.parseInt(id);
>               IBehaviorListener behaviorListener = null;
>               if (component.getBehaviors().size() > idAsInt)

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