Search code examples
javamavenzk

zk-maven project: in .zul file, window tag's apply attribute got "cannot be resolved to a type" error hint


I am trying to create a zk-maven project from scratch. However, when I want to add [apply="sphinxSpeechRecog"] attribute inside the "window" tag, the eclipse IDE gives me an error-hint floating dialog saying :"sphinxSpeechRecog cannot be resolved to a type". I already check that the path of my class is correct.

I have tried to clean up the project but it didn't help.

the .zul:

<?page title="sphinx" contentType="text/html;charset=UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<window title="sphinx" border="normal" apply="sphinxSpeechRecog">
</window>
</zk>

the .java:

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.SelectorComposer;

public class sphinxSpeechRecog extends SelectorComposer<org.zkoss.zk.ui.Component>{


}

Solution

  • This may be caused by the fact that I'm missing the "src/main/java" package when I create a blank maven project.

      1. On the project, right click "Property" then switch to the "Source" tab.
      2. Click on "sphinx/src/main/java"(which is red-marked now) item and then click "Edit...".
      3. In the popup dialog, type in "src/main/java". And then, click "Next"(NOT "Finish").
      4. At the "Inclusion patterns:" click "Add", and then in the popup dialog type in "src/main/java".
      5. Click "Finish" and then click "Apply and Close".
      6. Now the src/main/java package appears in the Project Explorer!!!
      7. New a class named "SphinxSpeechRecog" under the "src/main/java".sphinx path.
      8. Go to the .zul file and type in {apply="sphinx.SphinxSpeechRecog"}. The red underline will not appear now.

    Referenced solution: with printscreen pictures(step-by-step)