Uploaded image for project: 'Keikai'
  1. Keikai
  2. KEIKAI-822

cannot load a file from the classpath web resource path

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • None
    • 6.1.0
    • None
    • None

      Steps to Reproduce

      1. <spreadsheet src="~./blank.xlsx"/>
      2. run the zul

      Current Result

      org.zkoss.zk.ui.UiException: resource for ~./blank.xlsx not found.
      at io.keikai.ui.Spreadsheet.getSBook(Spreadsheet.java:735)
      at io.keikai.ui.Spreadsheet.getSelectedSSheet(Spreadsheet.java:918)
      at io.keikai.ui.Spreadsheet.doInvalidate(Spreadsheet.java:2890)
      at io.keikai.ui.Spreadsheet.invalidate(Spreadsheet.java:2712)
      at io.keikai.ui.Spreadsheet.setSrc(Spreadsheet.java:990)

      Expected Result

      keikai can load the file without the error

      Debug Information

      • almost all zk components can accept classpath web resource path ~./ (https://www.zkoss.org/wiki/ZK_Developer%27s_Reference/UI_Composing/ZUML/Include_a_Page#Classpath_Web_Resource_Path)
      • it allows a spreadsheet in a spring-boot app (jar package) to load file in the classpath
      • Spreadsheet.getSBook()
        					if (_src.startsWith("/")) {// try to load by application
        						// context.
        						WebApp wapp = Executions.getCurrent().getDesktop().getWebApp();
        						String path = wapp.getRealPath(_src);
        						if (path != null) {
        							File file = new File(path);
        //							if (file.isDirectory())
        //								throw new IllegalArgumentException("Your input source is a directory, not a vaild file");
        							if (file.exists())
        								url = file.toURI().toURL();
        						} else
        							url = wapp.getResource(_src); 
        					}
        

        wapp.getResource(_src) can load the ~./ correctly but wrong implementation

            Unassigned Unassigned
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: