由于其在它们的属性期待一个bean名(而不是bean实例)一些自定义组件,我需要通过页面之间的实际的bean名称。由于豆本身也被非自定义组件,我想避免使用额外的ui:param
(如这里所描述Passing action in <rich:modalPanel>),因为它基本上将指定同一个bean。小面:通过bean名字与用户界面:参数去action属性
是否有可能使用配备ui:param
bean名称指定组件的操作?
基本上我想要实现以下目标:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/template.xhtml">
<ui:param name="beanName" value="sessionBean"/>
...
</ui:composition>
和的template.xhtml是
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
template="/someothertemplate.xhtml">
</ui:define name="somename">
<h:form>
<a4j:commandButton value="test" action="#{beanName.delete}"/>
</h:form>
</ui:define>
</ui:composition>
虽然delete方法正确定义(与action="#{sessionBean.delete}"
验证)上面的代码给我
javax.faces.FacesException:#{beanName.delete}:javax.el.MethodNotFoundException:/ TEMPL ate.xhtml @ 201,89行动= “#{} beanName.delete”:未找到方法:sessionBean.delete()
一个警告在这里:bean必须已经被实例化,并放置在范围 - 这个表达不会创建一个托管bean。 – McDowell 2009-11-23 14:47:03
谢谢,这解决了它! – orom 2009-11-23 15:21:36
嗨:)非常有趣。但是,'删除'不是一个标签参数,而是一个常量?我的意思是它应该是表达式''#sessionScope [beanName]'。delete'}“'或者在这种情况下如何组合表达式? – user390525 2017-08-16 18:36:09