Java Server Faces表达式语言评估枚举

时间:2013-06-28 02:14:05

标签: jsf el

我想在JSF中评估EL中的枚举。

枚举是

package com.divudi.data;

/**
 *
 * @author Buddhika
 */
public enum InvestigationItemValueType {
    Varchar,
    Memo,
    Double,
    Integer,
    List,
    Image,
    Line,
    Rectangle,
    Circle,

}

EL是

                                <h:inputText value="#{pv.strValue}" rendered="#{pv.investigationItem.ixItemValueType='Varchar'}" ></h:inputText>

例外是

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: /lab_patient_report_dataentry.xhtml @40,139 rendered="#{pv.investigationItem.ixItemValueType='Varchar'}" Error Parsing: #{pv.investigationItem.ixItemValueType='Varchar'}
root cause

javax.faces.view.facelets.TagAttributeException: /lab_patient_report_dataentry.xhtml @40,139 rendered="#{pv.investigationItem.ixItemValueType='Varchar'}" Error Parsing: #{pv.investigationItem.ixItemValueType='Varchar'}
root cause

javax.el.ELException: Error Parsing: #{pv.investigationItem.ixItemValueType='Varchar'}
root cause

com.sun.el.parser.ParseException: Encountered "=" at line 1, column 39.
Was expecting one of:
    "}" ...
    "." ...
    "(" ...
    "[" ...
    ">" ...
    "gt" ...
    "<" ...
    "lt" ...
    ">=" ...
    "ge" ...
    "<=" ...
    "le" ...
    "==" ...
    "eq" ...
    "!=" ...
    "ne" ...
    "&&" ...
    "and" ...
    "||" ...
    "or" ...
    "*" ...
    "+" ...
    "-" ...
    "?" ...
    "/" ...
    "div" ...
    "%" ...
    "mod" ...

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.

1 个答案:

答案 0 :(得分:1)

仔细查看异常消息。 =是否属于预期的运营商?

不,不是。您正在寻找==,正是您用来比较普通Java代码中的对象的运算符。此运算符的文本等效项为eq

请注意,如果双手中的一个是==而不是基元,那么EL中的==与Java中的Object不完全相同。然后它将与Java中的Object#equals()完全相同。在Java中,==仅通过引用来比较对象,而不是通过它们的内部值来比较。