当前位置: 首页>>代码示例>>Java>>正文


Java IResource.Attributes方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:syncope,代码行数:24,代码来源:ImageModalPanel.java

示例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)));
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:38,代码来源:GalleryImageRenderer.java

示例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();
	}
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:16,代码来源:LdapUser.java

示例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;
}
 
开发者ID:apache,项目名称:syncope,代码行数:39,代码来源:UserSelfConfirmPasswordReset.java

示例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;
}
 
开发者ID:apache,项目名称:syncope,代码行数:9,代码来源:BinaryPDFPreviewer.java

示例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 {
        }
    };
}
 
开发者ID:l0rdn1kk0n,项目名称:wicket-clientside-logging,代码行数:13,代码来源:EmptyResourceResponse.java

示例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());
}
 
开发者ID:l0rdn1kk0n,项目名称:wicket-clientside-logging,代码行数:13,代码来源:EmptyResourceResponseTest.java

示例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);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:6,代码来源:ImageFileResource.java

示例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;
}
 
开发者ID:apache,项目名称:syncope,代码行数:47,代码来源:UserSelfPasswordReset.java


注:本文中的org.apache.wicket.request.resource.IResource.Attributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。