Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-7076

JavaScriptReferenceType newly created is not serializable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 9.15.0
    • 10.0.0-M2, 9.16.0
    • wicket-core
    • None

    Description

      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.

       

      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 }
       

      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

      @Override
      public void render(HeaderItem item) {
      //this is just a test to see if code works
      if(!(item instanceof JavaScriptReferenceHeaderItem)){
      headerItems.add( item );
      }
      }

       

      Not the previous one

      @Override
      public void render(HeaderItem item) {
      headerItems.add( item );
      }

      then put this panel or component in a map like hazecast{}
       

      Cache<String,Panel> cache = cacheManager.getCache( cacheName );  cache.put( getCacheKey(), panel ); 

       
      Pull request : https://github.com/apache/wicket/pull/664

      Attachments

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            abuzouzou leclerc cyril
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: