OK, thanks, the original code was copied from
http://www.javatutorials.co.in/jsf-2-2-file-upload-example-using-hinputfile/ , which has an xhtml file and two
Java source files, which I copied exactly before making a few changes.
I changed the xhtml file so that it is as follows:
Apart from a few layout changes, the only changes of consequence are the code between the beginning and end of the AJAX test.
The two Java classes are InputBean.java and FileUploadValidator.java. The only changes I made to the former are to include the following:
I.e. the boolean check and its getter and setter for the AJAX action. The other Java class I didn't change at all.
In the xhtml file, when the encoding type is omitted, the AJAX action fires correctly, and the text "Some text appears here" is displayed or not displayed according to whether the check box is checked or not. This is exactly what is supposed to happen, but the application crashes with the message:
The request content-type is not a multipart/form-data
when attempting to upload a file, which makes sense. However, if I put in enctype="multipart/form-data" in the form, the file upload works without an error, but on clicking the check box, it disappears and no text is rendered. If I refresh the browser (Firefox), the check box reappears as checked, but it does not do anything.