[jira] [Commented] (TAP5-2496) Inconsistent behavior of EnumValueEncoder

2016-09-22 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-2496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15513269#comment-15513269
 ] 

ASF subversion and git services commented on TAP5-2496:
---

Commit 45eaae528a4e418cecb03e41d47104853e973aa7 in tapestry-5's branch 
refs/heads/5.4.x from [~jkemnade]
[ https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;h=45eaae5 ]

TAP5-2565, TAP5-2496: always use name() when coercing enum values to String


> Inconsistent behavior of EnumValueEncoder 
> --
>
> Key: TAP5-2496
> URL: https://issues.apache.org/jira/browse/TAP5-2496
> Project: Tapestry 5
>  Issue Type: Bug
>Affects Versions: 5.4
>Reporter: Jochen Kemnade
>Assignee: Jochen Kemnade
> Fix For: 5.4
>
>
> EnumValueEncoder uses {{java.lang.Enum.name()}} in {{toClient(E)}} but uses 
> {{typeCoercer.coerce(clientValue, enumType)}} in {{toValue(String 
> clientValue)}}.
> I have a custom coercer in my project and this causes the value encoder to be 
> unable to decode the client-side value back to a server-side value.
> I think we should remove {{EnumValueEncoderFactory}} altogether because 
> {{TypeCoercedValueEncoderFactory}} should do its job just fine.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (TAP5-2496) Inconsistent behavior of EnumValueEncoder

2016-09-22 Thread Hudson (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-2496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15512897#comment-15512897
 ] 

Hudson commented on TAP5-2496:
--

FAILURE: Integrated in Jenkins build tapestry-trunk-freestyle #1598 (See 
[https://builds.apache.org/job/tapestry-trunk-freestyle/1598/])
TAP5-2565, TAP5-2496: always use name() when coercing enum values to (jkemnade: 
rev 7368fdc536d5ddc6c050b05bdbe45fea4d9517e1)
* (edit) tapestry-ioc/src/test/groovy/ioc/specs/TypeCoercerSpec.groovy
* (add) tapestry-ioc/src/test/java/com/example/Animal.java
* (edit) 
commons/src/main/java/org/apache/tapestry5/ioc/internal/services/TypeCoercerImpl.java


> Inconsistent behavior of EnumValueEncoder 
> --
>
> Key: TAP5-2496
> URL: https://issues.apache.org/jira/browse/TAP5-2496
> Project: Tapestry 5
>  Issue Type: Bug
>Affects Versions: 5.4
>Reporter: Jochen Kemnade
>Assignee: Jochen Kemnade
> Fix For: 5.4
>
>
> EnumValueEncoder uses {{java.lang.Enum.name()}} in {{toClient(E)}} but uses 
> {{typeCoercer.coerce(clientValue, enumType)}} in {{toValue(String 
> clientValue)}}.
> I have a custom coercer in my project and this causes the value encoder to be 
> unable to decode the client-side value back to a server-side value.
> I think we should remove {{EnumValueEncoderFactory}} altogether because 
> {{TypeCoercedValueEncoderFactory}} should do its job just fine.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (TAP5-2496) Inconsistent behavior of EnumValueEncoder

2016-09-22 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-2496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15512837#comment-15512837
 ] 

ASF subversion and git services commented on TAP5-2496:
---

Commit 7368fdc536d5ddc6c050b05bdbe45fea4d9517e1 in tapestry-5's branch 
refs/heads/master from [~jkemnade]
[ https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;h=7368fdc ]

TAP5-2565, TAP5-2496: always use name() when coercing enum values to String


> Inconsistent behavior of EnumValueEncoder 
> --
>
> Key: TAP5-2496
> URL: https://issues.apache.org/jira/browse/TAP5-2496
> Project: Tapestry 5
>  Issue Type: Bug
>Affects Versions: 5.4
>Reporter: Jochen Kemnade
>Assignee: Jochen Kemnade
> Fix For: 5.4
>
>
> EnumValueEncoder uses {{java.lang.Enum.name()}} in {{toClient(E)}} but uses 
> {{typeCoercer.coerce(clientValue, enumType)}} in {{toValue(String 
> clientValue)}}.
> I have a custom coercer in my project and this causes the value encoder to be 
> unable to decode the client-side value back to a server-side value.
> I think we should remove {{EnumValueEncoderFactory}} altogether because 
> {{TypeCoercedValueEncoderFactory}} should do its job just fine.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (TAP5-2496) Inconsistent behavior of EnumValueEncoder

2016-09-22 Thread Artyom Kravchenko (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-2496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15512569#comment-15512569
 ] 

Artyom Kravchenko commented on TAP5-2496:
-

Hi
I use 5.4.1 version. 
I see that {code:borderStyle=solid}EnumValueEncoder.toClient(E){code} has 
{code:borderStyle=solid}typeCoercer.coerce(value, String.class){code} instead 
of  {code:borderStyle=solid}java.lang.Enum.name(){code} as it was in 5.3.8 (my 
previous version). I did not find any commits (work logs) in this task and 
5.4.1 tasks where  {code:borderStyle=solid}EnumValueEncoder.toClient(E){code} 
was changed.

But any way it was changed and I faced with issue after upgrade. The main 
reason is: 
I have enum like:

{code:title=Pets.java|borderStyle=solid}
// Some comments here
public enum Pets {
DOG_PET("Dog"),
CAT_PET("Cat")

private String displayValue;

private Pets(String displayValue) {
this.displayValue = displayValue;
}

@Override
public String toString() {
return displayValue;
}
}
{code}

As you see 
 {code:borderStyle=solid}toString(){code} method overridden therefore   
{code:borderStyle=solid}DOG_PET.toString() != DOG_PET.name(){code} 

When 'select options' (combo box with enum) renders it uses  
{code:borderStyle=solid}typeCoercer.coerce(DOG_PET, enumType){code} to get 
value attribute for  tag  (before it was just 
{code:borderStyle=solid}DOG_PET.name() == "DOG_PET"{code}).  Eventually we just 
get {code:borderStyle=solid}DOG_PET.toString() == "Dog"{code} as a result value.

Then on submit {code:borderStyle=solid}StringToEnumCoercion{code} try to 
'restore' selected option value to enum instance:

- collect all enum values to map where key is: 
{code:borderStyle=solid}DOG_PET.name(){code} and value 
{code:borderStyle=solid}DOG_PET{code} 
- extract value from map (using option value as key == "Dog")

Of course it has null result since "Dog" != "DOG_PET".

In other word  will not works if my enum has overridden 
{code:borderStyle=solid}toString(){code} method (it require custom encoder to 
work). 

I think it is need to use single mechanist to bind enum to string and vice 
versa in both cases: {code:borderStyle=solid}typeCoercer.coerce(value, 
String.class){code} or  {code:borderStyle=solid}value.name(){code}






> Inconsistent behavior of EnumValueEncoder 
> --
>
> Key: TAP5-2496
> URL: https://issues.apache.org/jira/browse/TAP5-2496
> Project: Tapestry 5
>  Issue Type: Bug
>Affects Versions: 5.4
>Reporter: Jochen Kemnade
>Assignee: Jochen Kemnade
> Fix For: 5.4
>
>
> EnumValueEncoder uses {{java.lang.Enum.name()}} in {{toClient(E)}} but uses 
> {{typeCoercer.coerce(clientValue, enumType)}} in {{toValue(String 
> clientValue)}}.
> I have a custom coercer in my project and this causes the value encoder to be 
> unable to decode the client-side value back to a server-side value.
> I think we should remove {{EnumValueEncoderFactory}} altogether because 
> {{TypeCoercedValueEncoderFactory}} should do its job just fine.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (TAP5-2496) Inconsistent behavior of EnumValueEncoder

2015-09-01 Thread Jochen Kemnade (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-2496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14725213#comment-14725213
 ] 

Jochen Kemnade commented on TAP5-2496:
--

If I completely remove {{EnumValueEncoderFactory}} and the respective 
contribution in {{TapestryModule}}, the test suite runs fine.

> Inconsistent behavior of EnumValueEncoder 
> --
>
> Key: TAP5-2496
> URL: https://issues.apache.org/jira/browse/TAP5-2496
> Project: Tapestry 5
>  Issue Type: Bug
>Affects Versions: 5.4
>Reporter: Jochen Kemnade
>
> EnumValueEncoder uses {{java.lang.Enum.name()}} in {{toClient(E)}} but uses 
> {{typeCoercer.coerce(clientValue, enumType)}} in {{toValue(String 
> clientValue)}}.
> I have a custom coercer in my project and this causes the value encoder to be 
> unable to decode the client-side value back to a server-side value.
> I think we should remove {{EnumValueEncoderFactory}} altogether because 
> {{TypeCoercedValueEncoderFactory}} should do its job just fine.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)