You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tinashe B Chipomho <ti...@gmail.com> on 2007/10/15 06:57:42 UTC

Tomcat 6 failing to evaluate EL expressions, Tomcat 6 bug?!!!!

Please tell me this is not a bug in Tomcat 6, its too obvious and to some
extend unacceptable I must be doing something wrong.
Here is my problem, I have written my own custom component to display a div
tag.

the JSP is as follows:

<faces:view>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>My Custom Tags</title>
    </head>
    <body>
      <html:form>
      <h2>Cat In The Rain</h2>
      <mine:mytag title="#{index.title}">Dancing in the rain.</mine:mytag>
      </html:form>
    </body>
</html>
</faces:view>

The tag class is given below:
This text #{index.title} is being interpreted as Literal text which is
obviously wrong, when deployed in glassfish the code works fine.
Output text in my tomcat console is

MyTag.setProperties(): Title is literal text....
MyTag.setProperties():              title value= #{index.title}
MyTag.setProperties(): Title Value expression is null


The Tag class.

public class MyTag extends UIComponentELTag{

  private ValueExpression title;

  public String getComponentType() {
    return "test.MyOutput";
  }

  public String getRendererType() {
    return "test.MyRenderer";
  }

  @Override()
  protected void setProperties(UIComponent component) {
    super.setProperties(component);
    if (null!= title){
      if (!title.isLiteralText()){
        component.setValueExpression("component.title", title);
        System.out.println("MyTag.setProperties(): Its not literal text.");
        System.out.println("MyTag.setProperties():              title value
= "+ title.getValue(getELContext()));
      }
      else{
        component.getAttributes().put("component.title",
title.getExpressionString());
        System.out.println("MyTag.setProperties(): Title is literal
text....");
        System.out.println("MyTag.setProperties():              title value=
"+ title.getExpressionString());
      }
    }
    System.out.println("MyTag.setProperties(): Title Value expression is "+
component.getValueExpression("component.title"));
  }


The component class.
public class MyOutput extends UICommand{
  public MyOutput(){
    setRendererType("test.MyRenderer");
  }

  @Override()
  public String getFamily() {
    return "test.MyOutput";
  }
}

The tld file
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0"
        xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2eeweb-jsptaglibrary_2_0.xsd">
  <tlib-version>1.0</tlib-version>
  <short-name>mine</short-name>
  <uri>http://www.my-tests.com</uri>
  <tag>
    <name>mytag</name>
    <tag-class>test.MyTag</tag-class>
    <body-content>JSP</body-content>
    <description></description>
    <attribute>
      <name>binding</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <deferred-value>
        <type>test.MyOutput</type>
      </deferred-value>
      <description>
          A ValueExpression that resolves to the UIComponent that
corresponds
          to this tag. This binding allows the Java bean that contains the
UIComponent
          to manipulate the UIComponent, its properties, and its children.
      </description>
    </attribute>
    <attribute>
      <name>title</name>
      <required>false</required>
      <deferred-value>
        <type>java.lang.String</type>
      </deferred-value>
      <description></description>
    </attribute>
        <attribute>
            <name>rendered</name>
            <required>false</required>
            <deferred-value>
                <type>boolean</type>
            </deferred-value>
            <description><![CDATA[ Use the rendered attribute to indicate
whether the HTML code for the
 component should be included in the rendered HTML page. If set to false,
 the rendered HTML page does not include the HTML for the component. If
 the component is not rendered, it is also not processed on any subsequent
 form submission.
]]></description>
        </attribute>
        <attribute>
            <name>id</name>
            <required>false</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>

  </tag>

</taglib>