Click
Click Examples

Source Viewer : WEB-INF/classes/org/apache/click/examples/page/general/FlashPage.java

package org.apache.click.examples.page.general;

import org.apache.click.control.Form;
import org.apache.click.control.Submit;
import org.apache.click.control.TextField;
import org.apache.click.examples.page.BorderPage;
import org.apache.click.examples.page.HomePage;

/**
 * Provides an example of a flash session attribute.
 */
public class FlashPage extends BorderPage {

    private static final long serialVersionUID = 1L;

    private Form form = new Form("form");

    private TextField valueField = new TextField("value", "Value:", true);

    public FlashPage() {
        addControl(form);

        form.add(valueField);
        form.add(new Submit("flashPage", "  Flash Page ", this, "onFlashClick"));
        form.add(new Submit("homePage", "  Home Page ", this, "onHomeClick"));
    }

    public boolean onFlashClick() {
        if (form.isValid()) {
            getContext().setFlashAttribute("flash", valueField.getValueObject());
            setRedirect(FlashPage.class);
            return false;
        }
        return true;
    }

    public boolean onHomeClick() {
        if (form.isValid()) {
            getContext().setFlashAttribute("flash", valueField.getValueObject());
            setRedirect(HomePage.class);
            return false;
        }
        return true;
    }

}