标签: flash-scope

JSF Flash Scope 记住太多消息

我的应用程序中有一个简单的流程 - 如果您在一个表单上填写并按保存(如果一切顺利),您将被重定向到带有列表的第二个视图。现在我想添加一条消息,说“您成功添加了一个对象”,但由于我使用的是我记得的重定向,因此我需要使用 Flash 范围。所以我做到了。问题是,在第一次“保存”期间,它正确地只显示了 1 条消息,但是当我导航回表单并点击“保存”时,它会向我显示当前消息和旧消息!更奇怪的是,当(第三次)我返回表单并点击“保存”时,我再次只收到 1 条消息(依此类推 1-2-1-2-1-2 等......)。我做错了什么还是jsf中的错误?我的意思是我正在调用相同的方法并得到不同的结果......

我正在使用 primefaces 和最新的 mojarr:

jsf-api-2.1.1-b04
jsf-impl-2.1.1-b04
primefaces-2.2.1

这是代码(至少是最相关的部分):

保存表格.xhtml:

    <div id="content-box" class="content-box">
        <p:panel id="content-panel" header="Dane raportu"
            styleClass="content-panel">
            <div class="content-box">
                <h:form prependId="false">
                    <h:panelGrid id="grid" columns="2" styleClass="content-panel">

                        <!-- some inputs and labels -->

                        <p:commandButton value="#{msg['thesis.save.button']}"
                            action="#{thesisBean.saveThesis}" />    
                    </h:panelGrid>
                </h:form>
            </div>
        </p:panel>
    </div>
Run Code Online (Sandbox Code Playgroud)

保存论文方法:

public String saveThesis() {
            //this creates a Hibernate entity and saves it to the DB
    thesisService.addThesis(createThesisEntity());

    FacesContext context = FacesContext.getCurrentInstance();
    context.getExternalContext().getFlash().setKeepMessages(true);
    ResourceBundle bundle = context.getApplication().getResourceBundle(
            context, "msg");

    context.addMessage(null, …
Run Code Online (Sandbox Code Playgroud)

jsf primefaces jsf-2 flash-scope

5
推荐指数
1
解决办法
3536
查看次数

部署Grails 3 App会引发FlashScope异常

将新版本的Grails 3.1.1应用程序战争部署到正在运行的Tomcat时,在部署后访问它时会出现异常.

Oct 13, 2016 11:39:58 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [grailsDispatcherServlet] in context with path [/acses] threw exception
java.lang.ClassCastException: org.grails.web.servlet.GrailsFlashScope cannot be cast to grails.web.mvc.FlashScope
        at org.grails.web.servlet.DefaultGrailsApplicationAttributes.getFlashScope(DefaultGrailsApplicationAttributes.java:173)
        at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:68)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
        at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:113)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
        at org.springframework.boot.context.web.ErrorPageFilter.forwardToErrorPage(ErrorPageFilter.java:188)
        at org.springframework.boot.context.web.ErrorPageFilter.handleException(ErrorPageFilter.java:171)
        at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:135)
        at org.springframework.boot.context.web.ErrorPageFilter.access$000(ErrorPageFilter.java:61) …
Run Code Online (Sandbox Code Playgroud)

grails flash-scope grails3

5
推荐指数
0
解决办法
89
查看次数

Spring MVC FlashMap 和 RedirectAttributes 请求映射

昨天我下载了新的 Spring 3.1RC 来测试 Spring MVC 中刚刚引入的对 flash 作用域变量的支持。不幸的是我无法让它工作......

我有一个 HTML 表单,其中包含一些没有 spring:forms 标签的复选框。像这样的东西:

<form action="/deleteaction" method="post">
<input type="checkbox" name="itemId" value="1" />
<input type="checkbox" name="itemId" value="2" />
<input type="submit" name="delete" value="Delete items" />
</form>
Run Code Online (Sandbox Code Playgroud)

在 Flash 范围支持之前,我的带注释的控制器如下所示:

@RequestMapping(value = "/deleteaction", method = RequestMethod.POST, params={"delete"})
public String deleteItems(@RequestParam(value="itemId", required=false) String itemId[]) {
Run Code Online (Sandbox Code Playgroud)

或者,我可以使用 anHttpServletRequest代替@RequestParam

@RequestMapping(value = "/deleteaction", method = RequestMethod.POST, params={"delete"})
public String deleteItems(HttpServletRequest request) {
    String itemIds[] = request.getParameterValues("itemId");
Run Code Online (Sandbox Code Playgroud)

两种方法都运行良好。如果我尝试将 添加到RedirectAttributes方法参数中,Spring 将抛出异常:

@RequestMapping(value = …
Run Code Online (Sandbox Code Playgroud)

model-view-controller redirect spring flash-scope

4
推荐指数
1
解决办法
6210
查看次数

禁用oam.Flash.RENDERMAP.TOKEN

我正在使用Apache MyFaces 2.0.我注意到oam.Flash.RENDERMAP.TOKEN为每个视图创建了一个cookie ,即使我没有使用Flash范围而且我已经设置了org.apache.myfaces.DISABLE_FLASH_SCOPE=true.

我该如何删除oam.Flash.RENDERMAP.TOKENcookie?这是WebSphere特定的问题

websphere myfaces jsf-2 flash-scope

4
推荐指数
2
解决办法
3628
查看次数