How to access ui:param value in the managed bean

◇◆丶佛笑我妖孽 提交于 2019-12-01 18:06:41

Where the <ui:param> is under the covers stored is actually implementation dependent. In Mojarra it's stored as an attribute of the FaceletContext and thus available in your backing bean as follows:

FaceletContext faceletContext = (FaceletContext) FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
String formId = (String) faceletContext.getAttribute("formId");

Whether the value would be available is however subject to timing. If your backing code is running while executing the rendering of the include, then it'll be available, else it'll be null.

I recall that MyFaces does it a bit differently, but I don't recall the details anymore and I don't have its source at hand right now.

As to your <h:inputHidden> attempt, the <h:inputHidden> isn't well suited for the sole purpose of passing view-definied hidden parameters along with the form submit. Just use plain HTML instead.

<input type="hidden" name="hiddenFormId" value="#{formId}" />

It'll be available as a request parameter with exactly this name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!