cannot set enctype on h:form with el
------------------------------------

                 Key: MYFACES-1811
                 URL: https://issues.apache.org/jira/browse/MYFACES-1811
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-252
    Affects Versions: 1.2.2
         Environment: Windows, Tomcat 6.0.14, facelets 1.1.14
            Reporter: John Singleton


I have the following code in a facelets composition

        <h:form onsubmit="return submitForm()" id="main" enctype="#{(empty 
encoding) ? 'application/x-www-form-urlencoded' : encoding}">

Depending on how the form is used the enctype might need to be 
"multipart/form-data"

I use the composition like so:

<ui:decorate xmlns="http://www.w3.org/1999/xhtml";
          xmlns:t="http://myfaces.apache.org/tomahawk";
      xmlns:ui="http://java.sun.com/jsf/facelets";
      xmlns:h="http://java.sun.com/jsf/html";
      xmlns:f="http://java.sun.com/jsf/core";
       template="#{pqfn:absoluteStyle('homeTemplate.xhtml')}">
        <ui:param name="encoding" value="multipart/form-data" />

This worked prior to MyFaces 1.2. It doesn't work in 1.2+ Looking at 
HtmlForm.java :

  // Property: enctype
  private String _enctype = "application/x-www-form-urlencoded";

  /**
   * Gets The content type used to submit this form to the server.
   *
   * @return  the new enctype value
   */
  public String getEnctype()
  {
    if (_enctype != null)
    {
      return _enctype;
    }
    ValueExpression expression = getValueExpression("enctype");
    if (expression != null)
    {
      return (String)expression.getValue(getFacesContext().getELContext());
    }
    return "application/x-www-form-urlencoded";
  }

As enctype is initialized in it's declaration it is never null. Therefore the 
ValueExpression is never evaluated. This means the enctype cannot be set using 
an EL Expression in the page.

I'm not sure if this is a bug against HtmlForm, or the maven-faces-plugin that 
is generating this class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to