[ 
https://issues.apache.org/jira/browse/MYFACES-1811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568391#action_12568391
 ] 

Leonardo Uribe commented on MYFACES-1811:
-----------------------------------------

Yes, is a maven-faces-plugin bug.

The solution is instead this on MyFacesComponentGenerator :

  public void writePropertyDeclaration(PrettyWriter out,
                                       PropertyBean property) throws IOException

/*************/

        out.println("private " + propertyClass + propertyGenerics + " " +
                fieldPropName + (def == null ? ";" : " = " + def + ";"));       
 

/***********/

Do this

    if (property.isLiteralOnly() || property.isTagAttributeExcluded()){
        //If the property is literal or is tagAttributeExcluded, 
        //the default value goes on the definition of the field
        out.println("private " + propertyClass + propertyGenerics + " " +
                fieldPropName + (def == null ? ";" : " = " + def + ";"));       
 
    }else{        
        //If is a primitive class, has a set field to check if this
        //property is defined, so the default value goes on the 
        //getter method.
        //If is a class, the same applies, because the check
        //is against null
        out.println("private " + propertyClass + propertyGenerics + " " +
                fieldPropName + ";");//(def == null ? ";" : " = " + def + ";")  
      
    }




> 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
>            Assignee: Leonardo Uribe
>            Priority: Critical
>
> 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