wicket - 单击上一个按钮时页面已过期

时间:2017-07-05 09:37:04

标签: wicket wicket-7

我将wicket 7与有状态页面一起使用,每改变到新页面,我总是使用这样的代码:

public class BasePage extends WebPage {

  private ServletContext servletContext;
  private boolean developmentMode;

  public BasePage() {

    NextApp app = (NextApp) getApplication();      
    servletContext = app.getServletContext();
    developmentMode = app.usesDevelopmentConfig();

    /** other code **/
   }
}

每次更改页面时,都会创建一个新的页面版本,并且页面ID会增加一个。 但是当我尝试加载上一页时,我从浏览器中单击上一个按钮,页面总是过期。

我在程序中使用此getApplication时发现问题我无法加载上一页。如果我排除getApplication,我可以加载上一页。

scala> val rdd = spark.sparkContext.parallelize(Seq(
     |         (1, Array(2.0,5.0,6.3)),
     |         (5, Array(1.0,3.3,9.5)),
     |         (1, Array(5.0,4.2,3.1)),
     |         (2, Array(9.6,6.3,2.3)),
     |         (1, Array(8.5,2.5,1.2)),
     |         (5, Array(6.0,2.4,7.8)),
     |         (2, Array(7.8,9.1,4.2))
     |       )
     | )
rdd: org.apache.spark.rdd.RDD[(Int, Array[Double])] = ParallelCollectionRDD[83] at parallelize at <console>:24

scala> val accum = sc.longAccumulator("My Accumulator")
accum: org.apache.spark.util.LongAccumulator = LongAccumulator(id: 46181, name: Some(My Accumulator), value: 0)

scala> rdd.foreach { x => if(x._1 == 1) accum.add(1) }

scala> accum.value
res38: Long = 3

请帮帮我,如何使用getApplication,我也可以加载上一页?

1 个答案:

答案 0 :(得分:0)

PageExpiredException&#39; javadoc说:

 Thrown when a {@link Page} instance cannot be found by its id in the page stores. The page may be
 * missing because of reasons like:
 * <ul>
 * <li>the page have never been stored there, e.g. an error occurred during the storing process</li>
 * <li>the http session has expired and thus all pages related to this session are erased too</li>
 * <li>the page instance has been erased because the store size exceeded</li>

 * @see HttpSession#setMaxInactiveInterval(int)
 * @see org.apache.wicket.settings.StoreSettings#setMaxSizePerSession(org.apache.wicket.util.lang.Bytes)
 * @see NotSerializableException

检查这些是否属实。

另外,我建议您使用:setResponsePage(SecondPage.class, new PageParameters());