Mojarra 丢失视图参数
我正在尝试在 Mojjara 中实现 post-redirect-get 模式。我有两个页面具有相同的标题和一个搜索表单。
两个页面都在其通用模板中包含了这两个代码
<f:metadata>
<f:viewParam name="searchString" value="#{searchBean.searchString}" />
<f:viewParam name="mutation" value="#{searchBean.mutation}" />
</f:metadata>
...
<h:form id="searchForm">
<div class="search">
<p:autoComplete id="autocomplete" minQueryLength="2" queryDelay="250" completeMethod="#{searchBean.complete}" value="#{searchBean.searchString}" />
<p:watermark for="autocomplete" value="#{msg.search}" />
<p:commandButton action="search?faces-redirect=true&includeViewParams=true" value="#{msg.searchIt}">
<f:setPropertyActionListener target="#{searchBean.mutation}" value="#{facesContext.viewRoot.locale}" />
</p:commandButton>
</div>
</h:form>
当我从 article.xhtml
提交表单时,URL 为 search.xhtml
,当我从 提交表单时>search.xhtml
,我得到了带有模式 /search.xhtml?searchString=stringSearch&mutation=cs
的预期 URL
我是否遗漏了什么?
编辑:支持 bean 在视图和 flash 之间使用某种组合(bean 保存到两个作用域中,并从它所幸存的作用域中检索)。从调试来看,JSF 似乎在将参数保存到 bean 之前就获取了参数(在不正确的用例中)。
I am trying to implement post-redirect-get pattern in Mojjara. I have two pages with the same header and a search form in it.
Both pages have included in their common template these two codes
<f:metadata>
<f:viewParam name="searchString" value="#{searchBean.searchString}" />
<f:viewParam name="mutation" value="#{searchBean.mutation}" />
</f:metadata>
...
<h:form id="searchForm">
<div class="search">
<p:autoComplete id="autocomplete" minQueryLength="2" queryDelay="250" completeMethod="#{searchBean.complete}" value="#{searchBean.searchString}" />
<p:watermark for="autocomplete" value="#{msg.search}" />
<p:commandButton action="search?faces-redirect=true&includeViewParams=true" value="#{msg.searchIt}">
<f:setPropertyActionListener target="#{searchBean.mutation}" value="#{facesContext.viewRoot.locale}" />
</p:commandButton>
</div>
</h:form>
When I submit the form from article.xhtml
, the url is search.xhtml
, when I submit the form from search.xhtml
, I get the expected URL with pattern /search.xhtml?searchString=stringSearch&mutation=cs
Am I missing something?
Edit: the backing bean uses some kind of combination between view and flash (bean is saved into both scopes and is retrieved fron the one, where it had survived). From debugging it seems that JSF get the params before they are saved in the bean (in the incorrect use case).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论