I would like to make a functional search engine where you can search a word and it compares it with a title of a CSV file. First I tried to make a submit button using JButton and try to combine it with the Jade file. The button was shown but it has no function. These are my two files:
Java Class:
public static void main(String[] args) throws IOException {
staticFiles.location("/public");
CSVParser csvParser;
Scanner scanner;
InputStream inputStream = ClassLoader.getSystemResourceAsStream("comics.csv");
csvParser = new CSVParser();
scanner = new Scanner(inputStream);
String line = scanner.nextLine();
String[] words = csvParser.parseLine(line);
get("/search", (req, res) -> {
JButton buttonA = new JButton("A");
buttonA.addActionListener(
(event) -> { buttonAClicked(); } );
Map<String, Object> map = new HashMap<>();
map.put("words", words);
ModelAndView modelAndView = new ModelAndView(map, "search");
return modelAndView;
}, new JadeTemplateEngine());
}
private static void buttonAClicked() {
System.out.println("hi");
}
public interface ActionListener extends EventListener {
public void actionPerformed(ActionEvent e);
}
Jade File:
html head title Search engine h1 Search
body p | Query term (in title) input(type = 'text' placeholder = 'Query term (title)'). p input(type='checkbox' id='case sensitivity' name='case sensitivity' value='case sensitivity') label(for='case sensitivity') case sensitivity
input(type='checkbox' id='whole word' name='whole word' value='whole word')
label(for='whole word') whole word
p
button(onclick = '#{buttonA}') Submit