[ 
https://issues.jboss.org/browse/RF-11882?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Brian Leathem updated RF-11882:
-------------------------------

    Description: 
I get a 

FATAL:
{code}
...javax.faces.FacesException: Error in conversion Java Object to JavaScript
        at 
org.ajax4jsf.javascript.ScriptUtils.appendScript(ScriptUtils.java:194) 
[:4.1.0.Final]
        at 
org.ajax4jsf.javascript.ScriptUtils.appendScript(ScriptUtils.java:123) 
[:4.1.0.Final]
....
Caused by: java.lang.IllegalAccessException: Class 
org.ajax4jsf.javascript.PropertyUtils can not access a member of class 
java.util.HashMap$Entry with modifiers "public final"
{code}

Which wasn't there in richfaces 3.3.3

The code snippet:

{code}
class MyBean{
public String actionMethod(){
....do something which creates a Map <String,String> data, now I want to sort 
it before I return it:

        private List<Entry<String, String>> sortDataIntoList(Map<String, 
String> data) {
                        List<Entry<String, String>> sortedList = new 
ArrayList<Entry<String, String>>(data.entrySet());
                        Collections.sort(sortedList, new 
Comparator<Entry<String, String>>() {
                                public int compare(Entry<String, String> f1, 
Entry<String, String> f2) {
                                        return 
f1.getValue().compareTo(f2.getValue());
                                }
                        });
                        if(sortedList.size()>max)
                                return sortedList.subList(0, max);
                        return sortedList;
        }

...and return it from...
public static MyInnerClass{
  List<Entry<String,String>> data
 public MyInnerClass(List<Entry<String,String>> data){
this.data=data
}
public   List<Entry<String,String>> getData(){
return data;}

}

}
{code}

results in the mentioned error



A possible workaround is to use one's own implementation of a key value object 
e.g. something like 
http://stackoverflow.com/questions/521171/a-java-collection-of-value-pairs-tuples

  was:
I get a 

FATAL:
...javax.faces.FacesException: Error in conversion Java Object to JavaScript
        at 
org.ajax4jsf.javascript.ScriptUtils.appendScript(ScriptUtils.java:194) 
[:4.1.0.Final]
        at 
org.ajax4jsf.javascript.ScriptUtils.appendScript(ScriptUtils.java:123) 
[:4.1.0.Final]
....
Caused by: java.lang.IllegalAccessException: Class 
org.ajax4jsf.javascript.PropertyUtils can not access a member of class 
java.util.HashMap$Entry with modifiers "public final"

Which wasn't there in richfaces 3.3.3

The code snippet:

class MyBean{
public String actionMethod(){
....do something which creates a Map <String,String> data, now I want to sort 
it before I return it:

        private List<Entry<String, String>> sortDataIntoList(Map<String, 
String> data) {
                        List<Entry<String, String>> sortedList = new 
ArrayList<Entry<String, String>>(data.entrySet());
                        Collections.sort(sortedList, new 
Comparator<Entry<String, String>>() {
                                public int compare(Entry<String, String> f1, 
Entry<String, String> f2) {
                                        return 
f1.getValue().compareTo(f2.getValue());
                                }
                        });
                        if(sortedList.size()>max)
                                return sortedList.subList(0, max);
                        return sortedList;
        }

...and return it from...
public static MyInnerClass{
  List<Entry<String,String>> data
 public MyInnerClass(List<Entry<String,String>> data){
this.data=data
}
public   List<Entry<String,String>> getData(){
return data;}

}

}

results in the mentioned error



A possible workaround is to use one's own implementation of a key value object 
e.g. something like 
http://stackoverflow.com/questions/521171/a-java-collection-of-value-pairs-tuples


    
> a4j jsFunction cannot transform java class to json in the getData method call
> -----------------------------------------------------------------------------
>
>                 Key: RF-11882
>                 URL: https://issues.jboss.org/browse/RF-11882
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 4.1.0.Final
>            Reporter: Dirk Dollar
>            Priority: Minor
>
> I get a 
> FATAL:
> {code}
> ...javax.faces.FacesException: Error in conversion Java Object to JavaScript
>       at 
> org.ajax4jsf.javascript.ScriptUtils.appendScript(ScriptUtils.java:194) 
> [:4.1.0.Final]
>       at 
> org.ajax4jsf.javascript.ScriptUtils.appendScript(ScriptUtils.java:123) 
> [:4.1.0.Final]
> ....
> Caused by: java.lang.IllegalAccessException: Class 
> org.ajax4jsf.javascript.PropertyUtils can not access a member of class 
> java.util.HashMap$Entry with modifiers "public final"
> {code}
> Which wasn't there in richfaces 3.3.3
> The code snippet:
> {code}
> class MyBean{
> public String actionMethod(){
> ....do something which creates a Map <String,String> data, now I want to sort 
> it before I return it:
>       private List<Entry<String, String>> sortDataIntoList(Map<String, 
> String> data) {
>                       List<Entry<String, String>> sortedList = new 
> ArrayList<Entry<String, String>>(data.entrySet());
>                       Collections.sort(sortedList, new 
> Comparator<Entry<String, String>>() {
>                               public int compare(Entry<String, String> f1, 
> Entry<String, String> f2) {
>                                       return 
> f1.getValue().compareTo(f2.getValue());
>                               }
>                       });
>                       if(sortedList.size()>max)
>                               return sortedList.subList(0, max);
>                       return sortedList;
>       }
> ...and return it from...
> public static MyInnerClass{
>   List<Entry<String,String>> data
>  public MyInnerClass(List<Entry<String,String>> data){
> this.data=data
> }
> public   List<Entry<String,String>> getData(){
> return data;}
> }
> }
> {code}
> results in the mentioned error
> A possible workaround is to use one's own implementation of a key value 
> object e.g. something like 
> http://stackoverflow.com/questions/521171/a-java-collection-of-value-pairs-tuples

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
richfaces-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/richfaces-issues

Reply via email to