leclerc cyril created WICKET-7076:
-------------------------------------

             Summary: JavaScriptReferenceType newly created is not serializable
                 Key: WICKET-7076
                 URL: https://issues.apache.org/jira/browse/WICKET-7076
             Project: Wicket
          Issue Type: Bug
          Components: wicket-core
    Affects Versions: 9.15.0
            Reporter: leclerc cyril


After upgrading 9.14 => 9.15

1 enum was swicthed to class and this class is used in header

{{{}{}}}{{{}org.apache.wicket.markup.head{}}}{{{}.JavaScriptReferenceType.java{}}}

{{but this class is not serializable, for instance we are using hazelcast to 
store classes or panel in a map (body and headers), with version 9.14 and 
previous it was working, now as this class is not serializable it create an 
exception and the cache storing is not working.}}

{{}}
{code:java}
package org.apache.wicket.markup.head;
   18 
   19 import org.apache.wicket.util.lang.Args;
   20 
   21 /**
   22  * To be used to define the "type" attribute of the script tag written
   23  * by a {@link AbstractJavaScriptReferenceHeaderItem}.
   24  */
   25 public class JavaScriptReferenceType {
   26 
   27     public static final JavaScriptReferenceType TEXT_JAVASCRIPT = new 
JavaScriptReferenceType("text/javascript");
   28     public static final JavaScriptReferenceType MODULE = new 
JavaScriptReferenceType("module");
   29 
   30     private final String type;
   31 
   32     public JavaScriptReferenceType(final String type) {
   33         this.type = Args.notEmpty(type, "type");
   34     }
   35 
   36     public String getType() {
   37         return type;
   38     }
   39 }
 {code}
{{}}

{{To reproduce, just create a panel with javascript file set in java with ajax 
link or ajax behaviour}}

{{and in the render method try to add item in header attribute (to be stored) 
here this code is working}}
{code:java}
@Override
public void render(HeaderItem item) {
//this is just a test to see if code works
if( !closed && !(item instanceof JavaScriptReferenceHeaderItem)){
headerItems.add( item );
}
}{code}
{{}}

{{Not the previous one}}
{code:java}
@Override
public void render(HeaderItem item) {
if( !closed ){
headerItems.add( item );
}
}{code}
{{{}then put this panel or component in a map like hazecast{}}}{{{}{}}}
 
{code:java}
Cache<String,Panel> cache = cacheManager.getCache( cacheName );  cache.put( 
getCacheKey(), panel ); {code}
 
{{}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to