[
https://issues.apache.org/jira/browse/WICKET-6279?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sven Ackermann updated WICKET-6279:
-----------------------------------
Description:
The magic values {{AttributeModifier.VALUELESS_ATTRIBUTE_REMOVE}} and
{{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}} do not work correctly after they
have been deserialized.
Imagine you have a page with a component that has sth. added like this:
{code:java}
component.add(AttributeModifier.replace("myattribute",
AttributeModifier.VALUELESS_ATTRIBUTE_ADD));
component.add(AttributeModifier.replace("anotherattribute",
Model.of(AttributeModifier.VALUELESS_ATTRIBUTE_ADD)));
component.add(AttributeModifier.replace("thirdattribute", new
StringResourceModel("myresourcekey").setDefaultValue(AttributeModifier.VALUELESS_ATTRIBUTE_ADD)));
{code}
Once we navigate away from the page, it gets serialized including the String
value "VA_ADD" for {{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}}. When we go
back (e.g. with browser back button), it is deserialized. But then the
deserialized String "VA_ADD" is not anymore the same as
{{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}}, so we have an attribute added to
our component with value "VA_ADD".
I'm not sure how this can be resolved or if it can be resolved at all. My
workaround is to use an {{AbstractReadOnlyModel}} that always returns
{{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}}, so that special value is not
serialized at all.
If it's not possible to manage the deserialisation, then there should be at
least some documentation about this problem and maybe convenience code using my
workaround with {{AbstractReadOnlyModel}} could be provided.
Thanks,
Sven
was:
The magic values {{AttributeModifier.VALUELESS_ATTRIBUTE_REMOVE}} and
{{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}} do not work correctly after they
have been deserialized.
Imagine you have a page with a component that has sth. added like this:
{code:java}
component.add(AttributeModifier.replace("myattribute",
AttributeModifier.VALUELESS_ATTRIBUTE_ADD));
component.add(AttributeModifier.replace("anotherattribute",
Model.of(AttributeModifier.VALUELESS_ATTRIBUTE_ADD)));
component.add(AttributeModifier.replace("thirdattribute", new
StringResourceModel("myresourcekey").setDefaultValue(AttributeModifier.VALUELESS_ATTRIBUTE_ADD)));
{code}
Once we navaigate away from the page, it gets serialized including the String
value "VA_ADD" for {{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}}. When we go
back (e.g. with browser back button), it is deserialized. But then the
deserialized String "VA_ADD" is not anymore the same as
{{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}}, so we have an attribute added to
our component with value "VA_ADD".
I'm not sure how this can be resolved or if it can be resolved at all. My
workaround is to use an {{AbstractReadOnlyModel}} that always returns
{{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}}, so that special value is not
serialized at all.
If it's not possible to manage the deserialisation, then there should be at
least some documentation about this problem and maybe convenience code using my
workaround with {{AbstractReadOnlyModel}} could be provided.
Thanks,
Sven
> AttributeModifier.VALUELESS_ATTRIBUTE_REMOVE does not work after
> deserialisation
> --------------------------------------------------------------------------------
>
> Key: WICKET-6279
> URL: https://issues.apache.org/jira/browse/WICKET-6279
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 7.2.0
> Environment: Tomcat 7.0
> Windows 7
> Reporter: Sven Ackermann
> Labels: attribute, behavior
>
> The magic values {{AttributeModifier.VALUELESS_ATTRIBUTE_REMOVE}} and
> {{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}} do not work correctly after
> they have been deserialized.
> Imagine you have a page with a component that has sth. added like this:
> {code:java}
> component.add(AttributeModifier.replace("myattribute",
> AttributeModifier.VALUELESS_ATTRIBUTE_ADD));
> component.add(AttributeModifier.replace("anotherattribute",
> Model.of(AttributeModifier.VALUELESS_ATTRIBUTE_ADD)));
> component.add(AttributeModifier.replace("thirdattribute", new
> StringResourceModel("myresourcekey").setDefaultValue(AttributeModifier.VALUELESS_ATTRIBUTE_ADD)));
> {code}
> Once we navigate away from the page, it gets serialized including the String
> value "VA_ADD" for {{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}}. When we go
> back (e.g. with browser back button), it is deserialized. But then the
> deserialized String "VA_ADD" is not anymore the same as
> {{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}}, so we have an attribute added
> to our component with value "VA_ADD".
> I'm not sure how this can be resolved or if it can be resolved at all. My
> workaround is to use an {{AbstractReadOnlyModel}} that always returns
> {{AttributeModifier.VALUELESS_ATTRIBUTE_ADD}}, so that special value is not
> serialized at all.
> If it's not possible to manage the deserialisation, then there should be at
> least some documentation about this problem and maybe convenience code using
> my workaround with {{AbstractReadOnlyModel}} could be provided.
> Thanks,
> Sven
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)