Tag: el

在expression式语言中转义JavaScript

有时,我需要在JSF页面中使用EL来呈现JavaScriptvariables。 例如 <script>var foo = '#{bean.foo}';</script> 要么 <h:xxx … onclick="foo('#{bean.foo}')" /> 当ELexpression式求值为包含JS特殊字符(如撇号和换行符)的string时,这会失败,并出现JS语法错误。 我如何逃避它?

在JSF 1.2中通过EL调用具有参数的方法

我正在使用一个数据表,每行我有两个button,一个“编辑”和一个“删除”。 我需要这些button是只读的,即禁用,如果某个条件符合所述行。 我在JSF 2中看到,可以将parameter passing给方法调用。 JSF 1.2中有什么等价的东西吗? 理想情况下,我想要的东西就像(循环variables是循环 ,还有另一个bean, 助手 ,其中包含我想要调用的方法): <h:commandButton value="Edit" disabled="#{helper.isEditable(loop.id)}" /> 在这种情况下,向bean中添加isEditable属性并没有语义上的意义,并且在bean周围创build一个包装对象是不现实的。 提前致谢。

h:绑定到String属性的inputText正在提交空string而不是null

我有一个Tomcat的JSF 2.0应用程序与许多<h:inputText>字段在我的数据库中input数据。 有些字段不是必需的。 <h:inputText value="#{registerBean.user.phoneNumber}" id="phoneNumber"> <f:validateLength maximum="20" /> </h:inputText> 当用户离开这个字段为空时,JSF将设置空string""而不是null 。 我怎样才能解决这个问题,而不用检查每个string if (string.equals("")) { string = null; }

如何将parameter passing给jsp:include通过c:set? JSP中variables​​的作用域是什么?

我在welcome.jsp上有这个 <c:set var="pgTitle" value="Welcome"/> <jsp:include page="/jsp/inc/head.jsp" /> 而这在head.jsp中: <title>Site Name – ${pgTitle}</title> 但variables是空白的,输出只是 Site Name – 我读了很多文章,我不知道问题是什么。 如果我在同一个welcome.jsp中的其他地方回显${pgTitle} ,那么它输出很好。 我在两个页面上都包含核心标记库。

c:forEach抛出javax.el.PropertyNotFoundException:在java.lang.Stringtypes中找不到属性'foo'

我的项目是使用hibernate 3.4.0 GA来访问数据库,Spring MVC 2.5.6来处理web请求和jsp(jstl)来渲染视图(网页)。 我通过hibernate从数据库中获取一个实体列表,并将其作为模型添加到jsp的modelmap中。当jsp渲染我的网页时,它抛出一个“javax.el.PropertyNotFoundException”。 javax.el.PropertyNotFoundException:在java.lang.Stringtypes中找不到属性'timestamp' 而例外来自: <c:forEach var="statusHistory" items="statusHistoryList"> ${statusHistory.timestamp} </c:forEach> 这似乎是“statusHistory”被视为一个string,而不是一个对象。 “StatusHistory”类有“timestamp”属性和getter方法: public Class StatusHistory{ … private Date timestamp; public Date getTimestamp(){…} … } 我在谷歌上search了一整天。 有些文章说getter方法不符合约定。 但似乎不是我的情况。 有人可以帮帮我吗? 在此先感谢安德鲁

在<ui:repeat>中指定元素的条件渲染? <c:if>似乎不起作用

我正在尝试使用<ui:repeat>有条件地构build自定义列表。 在列表中每次出现-1作为项目​​值时,我需要添加换行符。 我试图在<ui:repeat> <c:if>里面使用<c:if> ,但似乎不起作用。 它总是评估false 。 <ul> <ui:repeat value="#{topics.list}" var="topicId" > <li>#{topicId}</li> <c:if test="#{topicId eq -1}"> <br/> </c:if> </ui:repeat> </ul> 这可能吗?

如何比较EL中的char属性

我有一个像下面的命令button。 <h:commandButton value="Accept orders" action="#{acceptOrdersBean.acceptOrder}" styleClass="button" rendered="#{product.orderStatus=='N' }"></h:commandButton> 即使product.orderStatus值等于'N' ,命令button也不会显示在我的页面中。 这里product.orderStatus是一个字符属性。

如何连接EL中的string?

如何获得promoPricevariables作为string的一部分打印ONLY $4.67 ? <c:set var="promoPrice" value="4.67" /> <p>${(promoPrice != null) ? "ONLY $${promoPrice}" : "FREE"}</p>

在JavaScript文件中混合使用JSF EL

有没有一种方法可以让expression式语言 (EL)expression式包含JSF对JavaScript文件进行评估? 我希望Seam可以解决这个问题,但是到目前为止还没有运气。 我所要的只是能够在页面间共享的JavaScript函数中使用本地化的消息。

JSP中的$ {employee.id}抛出java.lang.NumberFormatException:对于inputstring:“id”

我有一个JSP页面,当在<c:forEach>显示来自下方的List<Employee>时,可以正常工作。 @RequestMapping(value = { "getAllEmployees", "/" }) public ModelAndView getAllEmployees() { // logger.info("Getting the all Employees."); List<Employee> employeeList = employeeService.getAllEmployees(); return new ModelAndView("employeeList", "employeeList", employeeList); } 而从下面的方法显示List<Employee>时,相同的JSP引发exception。 @RequestMapping("searchEmployee") public ModelAndView searchEmployee(@RequestParam("searchName") String searchName) { // logger.info("Searching the Employee. Employee Names: " + searchName); List<Employee> employeeList = employeeService.getAllEmployees(searchName); System.err.println("Employee count = "+employeeList.size()); return new ModelAndView("employeeList", "employeeList", […]