Search in sources :

Example 56 with UIForm

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);
}
Also used : UIForm(jakarta.faces.component.UIForm) FacesMessage(jakarta.faces.application.FacesMessage)

Aggregations

UIForm (jakarta.faces.component.UIForm)56 UIComponent (jakarta.faces.component.UIComponent)19 UIViewRoot (jakarta.faces.component.UIViewRoot)15 PrintWriter (java.io.PrintWriter)14 UIOutput (jakarta.faces.component.UIOutput)10 UIInput (jakarta.faces.component.UIInput)8 ClientBehaviorHolder (jakarta.faces.component.behavior.ClientBehaviorHolder)7 FacesContext (jakarta.faces.context.FacesContext)7 ResponseWriter (jakarta.faces.context.ResponseWriter)7 Test (org.junit.Test)7 List (java.util.List)5 UICommand (jakarta.faces.component.UICommand)4 HtmlCommandLink (jakarta.faces.component.html.HtmlCommandLink)4 VisitHint (jakarta.faces.component.visit.VisitHint)4 Locale (java.util.Locale)4 Map (java.util.Map)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 ViewPoolProcessor (org.apache.myfaces.view.facelets.ViewPoolProcessor)4 FacesException (jakarta.faces.FacesException)3 FacesMessage (jakarta.faces.application.FacesMessage)3