本文整理汇总了Java中org.apache.wicket.request.resource.IResource.Attributes方法的典型用法代码示例。如果您正苦于以下问题:Java IResource.Attributes方法的具体用法?Java IResource.Attributes怎么用?Java IResource.Attributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wicket.request.resource.IResource
的用法示例。
在下文中一共展示了IResource.Attributes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ImageModalPanel
import org.apache.wicket.request.resource.IResource; //导入方法依赖的package包/类
public ImageModalPanel(final BaseModal<T> modal, final byte[] content, final PageReference pageRef) {
super(modal, pageRef);
Image image = new Image("image", new Model<IResource>()) {
private static final long serialVersionUID = -8457850449086490660L;
@Override
protected IResource getImageResource() {
return new DynamicImageResource() {
private static final long serialVersionUID = 923201517955737928L;
@Override
protected byte[] getImageData(final IResource.Attributes attributes) {
return content;
}
};
}
};
image.setOutputMarkupId(true);
add(image);
}
示例2: GalleryImageRenderer
import org.apache.wicket.request.resource.IResource; //导入方法依赖的package包/类
/**
* Creates a new instance of <code>GalleryImageRenderer</code>.
*/
public GalleryImageRenderer(String id, String imageResourceId) {
super(id);
if (imageResourceId == null) {
add(new ContextImage("img",new Model(ProfileConstants.UNAVAILABLE_IMAGE)));
return;
}
else if (sakaiProxy.getResource(imageResourceId) == null) {
// may have been deleted in CHS
add(new ContextImage("img",new Model(ProfileConstants.UNAVAILABLE_IMAGE)));
return;
}
final byte[] imageBytes = sakaiProxy.getResource(imageResourceId).getBytes();
if (imageBytes != null && imageBytes.length > 0) {
BufferedDynamicImageResource imageResource = new BufferedDynamicImageResource() {
private static final long serialVersionUID = 1L;
@Override
protected byte[] getImageData(IResource.Attributes ignored) {
return imageBytes;
}
};
Image myPic = new Image("img", new Model(imageResource));
myPic.add(new AttributeModifier("alt", new StringResourceModel("profile.gallery.image.alt",this,null).getString()));
add(myPic);
} else {
add(new ContextImage("img",new Model(ProfileConstants.UNAVAILABLE_IMAGE)));
}
}
示例3: getProfilePictureImage
import org.apache.wicket.request.resource.IResource; //导入方法依赖的package包/类
public IResource getProfilePictureImage() {
final byte[] pictureData = getProfilePicture();
if (pictureData.length > 0) {
DynamicImageResource dir = new DynamicImageResource() {
@Override
protected byte[] getImageData(IResource.Attributes attributes) {
return pictureData;
}
};
dir.setFormat("image/png");
return dir;
} else {
return User.getAnonymousPicture();
}
}
示例4: newResourceResponse
import org.apache.wicket.request.resource.IResource; //导入方法依赖的package包/类
@Override
protected ResourceResponse newResourceResponse(final IResource.Attributes attributes) {
ResourceResponse response = new AbstractResource.ResourceResponse();
response.setContentType(MediaType.TEXT_PLAIN);
try {
HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest();
if (!xsrfCheck(request)) {
LOG.error("XSRF TOKEN does not match");
response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match");
return response;
}
Map<String, String[]> parameters = request.getParameterMap();
String token;
if (parameters.get("token") == null || parameters.get("token").length == 0) {
throw new Exception("A valid token should be provided");
} else {
token = parameters.get("token")[0];
}
if (parameters.get("newPassword") == null || parameters.get("newPassword").length == 0) {
throw new Exception("A new correct password should be provided");
}
SyncopeEnduserSession.get().getService(UserSelfService.class).
confirmPasswordReset(token, parameters.get("newPassword")[0]);
buildResponse(response, Response.Status.OK.getStatusCode(),
"Password successfully updated");
} catch (final Exception e) {
LOG.error("Error while updating user", e);
response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder()
.append("ErrorMessage{{ ")
.append(e.getMessage())
.append(" }}")
.toString());
}
return response;
}
示例5: getImageData
import org.apache.wicket.request.resource.IResource; //导入方法依赖的package包/类
@Override
protected byte[] getImageData(final IResource.Attributes attributes) {
if (thumbnail == null) {
thumbnail = toImageData(getScaledImageInstance());
setLastModifiedTime(Time.now());
}
return thumbnail;
}
示例6: newWriteCallback
import org.apache.wicket.request.resource.IResource; //导入方法依赖的package包/类
/**
* creates a new empty write callback.
*
* @return noop {@link org.apache.wicket.request.resource.AbstractResource.WriteCallback}
*/
protected AbstractResource.WriteCallback newWriteCallback() {
return new AbstractResource.WriteCallback() {
@Override
public void writeData(IResource.Attributes attributes) throws IOException {
}
};
}
示例7: noContentWillBeWrittenToResponse
import org.apache.wicket.request.resource.IResource; //导入方法依赖的package包/类
@Test
public void noContentWillBeWrittenToResponse() throws IOException {
MockWebResponse webResponse = spy(new MockWebResponse());
EmptyResourceResponse response = new EmptyResourceResponse();
IResource.Attributes attr = spy(new IResource.Attributes(new MockWebRequest(Url.parse("./")), webResponse));
response.getWriteCallback().writeData(attr);
verify(webResponse, never()).write(any(CharSequence.class));
verify(webResponse, never()).write(any(byte[].class));
verify(webResponse, never()).write(any(byte[].class), anyInt(), anyInt());
}
示例8: onResourceRequested
import org.apache.wicket.request.resource.IResource; //导入方法依赖的package包/类
public void onResourceRequested() {
IResource.Attributes attributes = new IResource.Attributes(RequestCycle.get().getRequest(),
RequestCycle.get().getResponse());
respond(attributes);
}
示例9: newResourceResponse
import org.apache.wicket.request.resource.IResource; //导入方法依赖的package包/类
@Override
protected ResourceResponse newResourceResponse(final IResource.Attributes attributes) {
ResourceResponse response = new AbstractResource.ResourceResponse();
response.setContentType(MediaType.TEXT_PLAIN);
String[] usernameParam = { "<unknown>" };
try {
HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest();
if (!xsrfCheck(request)) {
LOG.error("XSRF TOKEN does not match");
response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match");
return response;
}
Map<String, String[]> parameters = request.getParameterMap();
usernameParam = parameters.get("username");
if (ArrayUtils.isEmpty(usernameParam)) {
throw new Exception("A valid username should be provided");
}
if (request.getHeader("captcha") == null
|| !captchaCheck(
request.getHeader("captcha"),
request.getSession().getAttribute(SyncopeEnduserConstants.CAPTCHA_SESSION_KEY))) {
throw new IllegalArgumentException("Entered captcha is not matching");
}
if (SyncopeEnduserSession.get().getPlatformInfo().isPwdResetRequiringSecurityQuestions()) {
String[] securityAnswerParam = parameters.get("securityAnswer");
if (ArrayUtils.isEmpty(securityAnswerParam)) {
throw new Exception("A correct security answer should be provided");
}
SyncopeEnduserSession.get().getService(UserSelfService.class).
requestPasswordReset(usernameParam[0], securityAnswerParam[0]);
} else {
SyncopeEnduserSession.get().getService(UserSelfService.class).
requestPasswordReset(usernameParam[0], null);
}
} catch (final Exception e) {
LOG.error("Error while updating user", e);
}
buildResponse(response, Response.Status.OK.getStatusCode(),
"Password reset request sent for user " + usernameParam[0]);
return response;
}