Example usage for org.apache.wicket.util.time Time now

List of usage examples for org.apache.wicket.util.time Time now

Introduction

In this page you can find the example usage for org.apache.wicket.util.time Time now.

Prototype

public static Time now() 

Source Link

Document

Retrieves a Time instance based on the current time.

Usage

From source file:com.eltiland.ui.common.components.captcha.RussianCaptchaImageResource.java

License:Apache License

@Override
protected final byte[] getImageData(final Attributes attributes) {
    // get image data is always called in sync block
    byte[] data = null;
    if (imageData != null) {
        data = imageData.get();/*www .j a v  a 2  s  . c o  m*/
    }
    if (data == null) {
        data = render();
        imageData = new SoftReference<byte[]>(data);
        setLastModifiedTime(Time.now());
    }
    return data;
}

From source file:com.evolveum.midpoint.web.security.WicketRedirectStrategy.java

License:Apache License

@Override
public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url)
        throws IOException {
    response.setStatus(HttpServletResponse.SC_OK);

    response.setContentType("text/xml");

    response.setHeader("Ajax-Location", url);
    // disabled caching
    response.setHeader("Date", Long.toString(Time.now().getMilliseconds()));
    response.setHeader("Expires", Long.toString(Time.START_OF_UNIX_TIME.getMilliseconds()));
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache, no-store");

    Writer writer = response.getWriter();
    writer.write("<ajax-response><redirect><![CDATA[" + url + "]]></redirect></ajax-response>");
}

From source file:com.locke.library.event.AbstractEvent.java

License:Apache License

public void sending() {
    sentAt = Time.now();
}

From source file:com.locke.library.web.panels.caching.CachingPanel.java

License:Apache License

@Override
protected void onRender(MarkupStream markupStream) {
    final RequestCycle cycle = getRequestCycle();
    final Response response = cycle.getResponse();
    if (getRenderState().lastRenderedAt.elapsedSince().greaterThan(getRenderState().maximumContentAge)) {
        getRenderState().lastRenderedAt = Time.now();
        cycle.setResponse(getRenderState().buffer);
        super.onRender(markupStream);
        cycle.setResponse(response);/*  ww  w.  ja  va2 s  .  c o m*/
    } else {
        markupStream.skipComponent();
    }
    response.write(getRenderState().buffer.getBuffer());
}

From source file:com.locke.tricks.c.ExpensivePanel.java

License:Apache License

public ExpensivePanel(String id) {
    super(id, Scope.APPLICATION);
    setMaximumContentAge(Duration.seconds(30));
    add(new Label("label", new AbstractReadOnlyModel<String>() {

        @Override//from   w  ww . j av  a  2s . co m
        public String getObject() {
            return Time.now().toString();
        }
    }));
}

From source file:com.locke.tricks.t.TestWebPage.java

License:Apache License

public TestWebPage(final PageParameters parameters) {
    add(new Label("label", "Test label. The time is " + Time.now()));
}

From source file:com.locke.tricks.u.U.java

License:Apache License

@SuppressWarnings("unchecked")
public U() {// ww  w. ja  va  2  s . c  om

    final IColumn<Utility>[] columns = new IColumn[2];
    columns[0] = new PropertyColumn<Utility>(new Model<String>("Code"), "code", "code");
    columns[1] = new PropertyColumn<Utility>(new Model<String>("Output"), "output", "output");

    final DataTable<Utility> dataTable = new DataTable<Utility>("utilities", columns,
            this.utilitiesDataProvider, Integer.MAX_VALUE);
    dataTable.addTopToolbar(new HeadersToolbar(dataTable, new ISortStateLocator() {

        private ISortState sortState = new SingleSortState();

        public ISortState getSortState() {
            return this.sortState;
        }

        public void setSortState(final ISortState state) {
            this.sortState = state;
        }
    }));
    add(dataTable);

    this.utilities.add(new Utility("Time.now().toString()") {

        @Override
        public String getOutput() {
            return Time.now().toString();
        }
    });
    this.utilities.add(new Utility("Duration.ONE_WEEK.toString()") {

        @Override
        public String getOutput() {
            return Duration.ONE_WEEK.toString();
        }
    });
    this.utilities.add(new Utility("Duration.ONE_WEEK.add(Duration.ONE_DAY).toString()") {

        @Override
        public String getOutput() {
            return Duration.ONE_WEEK.add(Duration.ONE_DAY).toString();
        }
    });
    this.utilities.add(new Utility("Time.now().add(Duration.ONE_WEEK).toString()") {

        @Override
        public String getOutput() {
            return Time.now().add(Duration.ONE_WEEK).toString();
        }
    });
    this.utilities.add(new Utility("Bytes.valueOf(\"512K\") + Bytes.megabytes(1.3)") {

        @Override
        public String getOutput() {
            return Bytes.bytes(Bytes.valueOf("512K").bytes() + Bytes.megabytes(1.3).bytes()).toString();
        }
    });
    this.utilities.add(new Utility("Parsing \'13 + 13\' using MetaPattern") {

        @Override
        public String getOutput() {
            final IntegerGroup a = new IntegerGroup(MetaPattern.DIGITS);
            final IntegerGroup b = new IntegerGroup(MetaPattern.DIGITS);
            final MetaPattern sum = new MetaPattern(new MetaPattern[] { a, MetaPattern.OPTIONAL_WHITESPACE,
                    MetaPattern.PLUS, MetaPattern.OPTIONAL_WHITESPACE, b });
            final Matcher matcher = sum.matcher("13 + 13");
            if (matcher.matches()) {
                return Integer.toString(a.getInt(matcher) + b.getInt(matcher));
            }
            return "Failed to match.";
        }
    });
}

From source file:com.premiumminds.webapp.wicket.PDFResource.java

License:Open Source License

@Override
protected ResourceResponse newResourceResponse(Attributes attributes) {
    ResourceResponse response = new ResourceResponse();

    response.setContentType("application/pdf");
    response.setContentDisposition(ContentDisposition.ATTACHMENT);
    response.setFileName(callback.getFilename());
    response.setLastModified(Time.now());
    response.disableCaching();// w w  w . j av  a  2  s  . com
    response.setWriteCallback(new WriteCallback() {

        @Override
        public void writeData(Attributes attributes) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            callback.generatePDF(baos);

            attributes.getResponse().write(baos.toByteArray());

            try {
                baos.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    });

    return response;
}

From source file:com.premiumminds.webapp.wicket.StringDownloadResource.java

License:Open Source License

@Override
protected ResourceResponse newResourceResponse(Attributes attributes) {
    ResourceResponse response = new ResourceResponse();
    response.setContentType(contentType);
    response.setContentDisposition(ContentDisposition.ATTACHMENT);
    response.setFileName(filename);//from   w  ww .  j  a v a  2 s .c  om
    response.setLastModified(Time.now());
    response.disableCaching();
    response.setWriteCallback(new WriteCallback() {

        @Override
        public void writeData(Attributes attributes) {
            attributes.getResponse().write(getString());
        }
    });
    return response;
}

From source file:com.swordlord.gozer.frame.wicket.BinaryStreamWriter.java

License:Open Source License

@Override
public Time lastModifiedTime() {
    return Time.now();
}