001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.markup.html.image; 018 019import org.apache.wicket.model.IModel; 020import org.apache.wicket.request.mapper.parameter.PageParameters; 021import org.apache.wicket.request.resource.IResource; 022import org.apache.wicket.request.resource.ResourceReference; 023 024/** 025 * A subclass of {@link Image} that always adds random noise to the url every request to prevent the 026 * browser from caching the image. 027 * 028 * @see Image#shouldAddAntiCacheParameter() 029 * 030 * @author Igor Vaynberg (ivaynberg) 031 */ 032public class NonCachingImage extends Image 033{ 034 /** 035 * 036 */ 037 private static final long serialVersionUID = 1L; 038 039 /** 040 * Construct. 041 * 042 * @see Image#Image(String, IModel) 043 * 044 * @param id 045 * @param model 046 */ 047 public NonCachingImage(String id, IModel<?> model) 048 { 049 super(id, model); 050 } 051 052 /** 053 * Construct. 054 * 055 * @see Image#Image(String, IResource, IResource...) 056 * 057 * @param id 058 * @param imageResource 059 */ 060 public NonCachingImage(String id, IResource imageResource) 061 { 062 super(id, imageResource); 063 } 064 065 /** 066 * Construct. 067 * 068 * @see Image#Image(String, ResourceReference, PageParameters, ResourceReference...) 069 * 070 * @param id 071 * @param resourceReference 072 * @param resourceParameters 073 */ 074 public NonCachingImage(String id, ResourceReference resourceReference, 075 PageParameters resourceParameters) 076 { 077 super(id, resourceReference, resourceParameters); 078 } 079 080 /** 081 * Construct. 082 * 083 * @see Image#Image(String, ResourceReference, ResourceReference...) 084 * 085 * @param id 086 * @param resourceReference 087 */ 088 public NonCachingImage(String id, ResourceReference resourceReference) 089 { 090 super(id, resourceReference); 091 } 092 093 /** 094 * Construct. 095 * 096 * @see Image#Image(String, String) 097 * 098 * 099 * @param id 100 * @param string 101 */ 102 public NonCachingImage(String id, String string) 103 { 104 super(id, string); 105 } 106 107 /** 108 * Construct. 109 * 110 * @see Image#Image(String) 111 * 112 * @param id 113 */ 114 public NonCachingImage(String id) 115 { 116 super(id); 117 } 118 119 /** 120 * Overriden to precent caching. 121 * 122 * @return always {@code true} 123 */ 124 @Override 125 protected boolean shouldAddAntiCacheParameter() 126 { 127 return true; 128 } 129}