【发布时间】:2012-09-21 15:48:50
【问题描述】:
我看到这个问题问了很多,但是没有一个得到正确的回答,所以我决定再问一次。所以如果我有这个:如果我在A.xhtml 并且我
<ui:include src="B.xhtml">
<ui:param name="formId" value="awesome Id"/>
</ui:include>
所以在B.xhtml,我可以做到这一点
<h:outputText value="#{formId}"/>
当我运行A.xhtml 时,我会看到awesome Id 打印在屏幕上。但是,我如何访问支持 bean 中的 formId 的值。我查看FacesContext.getCurrentInstance().getAttributes() 和FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap() 内部,但我似乎无法找到它。为了更进一步,所以我尝试:
在B.xhtml里面,我现在有了
<h:inputHidden id="hiddenFormId" value="#{formId}"/>
<h:outputText value="#{formId}"/>
我的想法是我可以在键 hiddenFormId 下的 RequestParameterMap 中访问 formId 的值。但现在如果我有:
<h:form id="myForm">
<ui:include src="B.xhtml">
<ui:param name="formId" value="awesome Id"/>
</ui:include>
<a4j:commandButton render="myForm" value="My Button"/>
</h:form>
如果我查看 POST 请求(在 chrome 或 ff 调试模式下),我会得到这个错误
<partial-response><error><error-name>class javax.faces.component.UpdateModelException</error-name><error-message><![CDATA[/B.xhtml @9,61 value="${formId}": /index.xhtml @27,61 value="awesome Id": Illegal Syntax for Set Operation]]></error-message></error></partial-response>
so 如何访问托管 bean 中的 ui:param 值?
【问题讨论】:
-
this question 是否与您的相似?
-
@mael:我现在正在尝试他的代码,但有些东西我没有得到。如果你理解他/她的代码,你能帮我多一点吗?
hiddenValue是outputLabel的id,UiTreeWalker是什么?