>         if (getAutoEnable())
>         {
>             // the link is enabled if this link doesn't link to the current
> page
>             boolean versionEnabled = isVersioned();
>             setVersioned(false);
>             setEnabled(!linksTo(getPage()));
>             setVersioned(versionEnabled);
>         }
Couldn't this be done by overriding the isEnabled() method with
something like (enabled && autoEnabled) so you don't need to care
about versioning at all?

yes this is better i think. We do change the behaviour a bit then because isEnabled will always
override it and is can return true or false where it at the past didn't but i think this doesn't expose a problem.



Well, I'm also not sure about this one. I think that
enabling/disabling behaviour would make pretty much sense, I even
wanted to do this with AttributeModifier in one of my apps (like: add
class x but only if y). If I got it right offering only a isVisible()
method for overriding would get the problem away because then the
value is determined dynamically so no versioning needs to be done. But
then you couldn't disable a behaviour from f.e. a onClick handler
without throwing the same problem on the developer again...


So IBehaviour.isEnabled() that by default is implemented in AbstractBehaviour as return true;
And is tested in Component.isBehaviourAccepted(final IBehaviour behaviour)
That is possible. Of course behaviours could test it themselfs now if they want to render themselfs or not in the
onComponentTag method. They don't have to do something there..


I think behaviour should be able to participate in versioning, because
I think there are situations where they could have versionable
properties (don't have an example for this currently). Maybe
disallowing behaviours used across multiple pages would fix the
problem? (I don't see cases where this would be needed and it
shouldn't be very hard to catch this at runtime)


But they can be attached to more then one component on the same page?
But how to test this? And how does a behaviour get the page?
For example:

AbstractBehaviour.bind(Component)
{
  Page page = component.getPage()
  if(this.page != page) throw Exception
   this.page = page;
}

But that method is not really possible . Because component.getPage() could return null.
(the component itself doesn't have to be added to a container/page yet)

So you really only have the components that get binded to you and
so you just can keep a reference to that component. (if there are more then one then it gets fuzzy)
But adding a change is currently not possible because component.addStateChange is protected
This can be handled by adding that method to AbstractBehaviour that calls the component where it got binded to

Should a behaviour be able to version something even if the component says i can't be versioned?

And what happens if there are more then one component where it is binded to..

johan


Reply via email to