jp.javelindev.snippet.ExpireAjaxPage.java Source code

Java tutorial

Introduction

Here is the source code for jp.javelindev.snippet.ExpireAjaxPage.java

Source

/*
 * Copyright 2011 Tsutomu YANO.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jp.javelindev.snippet;

import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.protocol.http.PageExpiredException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author Tsutomu YANO
 */
public class ExpireAjaxPage extends WebPage {
    private static final long serialVersionUID = 1L;
    private static final Logger LOGGER = LoggerFactory.getLogger(ExpireAjaxPage.class);

    private String content = "";

    public ExpireAjaxPage(PageParameters parameters) {
        super(parameters);

        LOGGER.debug("PAGE CREATION.");

        final Label contentLabel = new Label("contentLabel", new PropertyModel<String>(this, "content"));
        contentLabel.setOutputMarkupId(true);
        add(contentLabel);

        add(new AjaxLink<Void>("ajaxButton") {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                LOGGER.debug("CLICKED.");
                content = "??";
                target.addComponent(contentLabel);
            }
        });
    }

}