Question

i'm trying to implement an edit/add profile page which looks the following:

  • image upload component (Tomahawk t:inputFileUpload) with upload button
  • several input text fields
  • cancel and save button

As said, this form is used for adding a new profile as well as editing existing ones. At first, i used two elements, one for the text input, one for the upload component. The problem with this is, since the upload componenet does not support ajax/ partial rendering, the whole page is reloaded and any changes on the text inputs is lost. When i use one unified , the validation is triggered on the textfields when the upload button is pressed and the user is forced to fill out all the inputs first, before it is possible to upload an image.

My desired behaviour would be, that if the textinputs are unchanged, i can still upload the picture while changes are being applied to the backing bean and validated. Validation on unchanged/empty fields should only be triggered, when the final submit button is pressed. How can this be done? Any standard scenario/best practice methods for this or do i have to implement a valueChange Listener? Thank you guys in advance and kind regards!

Was it helpful?

Solution

Solved the problem, i wrote a custom validator and checked for the action that triggered the submission of the form using this:

 ctx.getExternalContext().getRequestParameterValuesMap().containsKey("form:uploadButton");

Where ctx is the current instance of FacesContext. Maybe this helps someone, it is a workaround however it does the job.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top