将参数传递给h:outputtext标记中的方法 [英] Passing parameters to a method in h:outputtext tag

查看:189
本文介绍了将参数传递给h:outputtext标记中的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过将属性传递给在backing bean中实现的方法在jsf屏幕中显示文本.我必须将动态值作为属性传递.我尝试了以下操作,但语法似乎不正确-

I would like to display a text in jsf screen by passing an attribute to a method implemented in backing bean. I have to pass a dynamic value as an attribute. I tried the below but it seems to be an incorrect syntax -

<h:outputText value="#{getValue(#{item.product}).component.address}" />

推荐答案

除语法错误(您永远不能嵌套#{#{}}之类的EL表达式)之外,以下内容在EL 2.2中有效,而EL 2.2又是Servlet的一部分3.0/Java EE 6:

Apart from the syntax error (you can never nest EL expressions like as #{#{}}), the following is valid in EL 2.2 which is in turn part of Servlet 3.0 / Java EE 6:

<h:outputText value="#{bean.getValue(item.product).component.address}" />

因此,如果您具有与Servlet 3.0兼容的目标运行时环境(Tomcat 7,Glassfish 3,JBoss 6等)和与Servlet 3.0兼容的web.xml,则可以使用此类参数调用非getter方法.

So if you have a Servlet 3.0 compatible target runtime (Tomcat 7, Glassfish 3, JBoss 6, etc) with a Servlet 3.0 compatible web.xml, then you can invoke non-getter methods with arguments like this.

但是,根据您的问题历史记录,您正在使用JSF 1.2,并且很有可能您还将目标对准了较旧的容器,而上面的容器不起作用.如果它是Servlet 2.5容器,则可以使用 JBoss EL 可以使该EL语法起作用.

However, based on your question history you're using JSF 1.2 and the chance is big that you're also targeting an older container where the above wouldn't work. If it is a Servlet 2.5 container, then you could use JBoss EL to get this EL syntax to work.

这篇关于将参数传递给h:outputtext标记中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆