use of jakarta.faces.component.UIForm in project mojarra by eclipse-ee4j.
the class FileRenderer method encodeBegin.
// If we are in Project Stage Development mode, the parent form
// must have an enctype of "multipart/form-data" for this component.
// If not, produce a message.
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
if (context.isProjectStage(ProjectStage.Development)) {
boolean produceMessage = false;
UIForm form = RenderKitUtils.getForm(component, context);
if (null != form) {
String encType = (String) form.getAttributes().get("enctype");
if (null == encType || !encType.equals("multipart/form-data")) {
produceMessage = true;
}
} else {
produceMessage = true;
}
if (produceMessage) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_WARN, "File upload component requires a form with an enctype of multipart/form-data", "File upload component requires a form with an enctype of multipart/form-data");
context.addMessage(component.getClientId(context), message);
}
}
super.encodeBegin(context, component);
}
Aggregations