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


Java SlingHttpServletRequest.getAttribute方法代码示例

本文整理汇总了Java中org.apache.sling.api.SlingHttpServletRequest.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java SlingHttpServletRequest.getAttribute方法的具体用法?Java SlingHttpServletRequest.getAttribute怎么用?Java SlingHttpServletRequest.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.sling.api.SlingHttpServletRequest的用法示例。


在下文中一共展示了SlingHttpServletRequest.getAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isApplicable

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
private boolean isApplicable(SlingHttpServletRequest request) {
	Object appliable = request.getAttribute(REQUEST_PROPERTY_AEM_DATALAYER_APPLICABLE);
	if (appliable == null) {
		Resource resource = request.getResource();
		PageManager pMgr = resource.getResourceResolver().adaptTo(PageManager.class);
		Page page = pMgr.getContainingPage(resource);
		AEMDataLayerConfig config = AEMDataLayerConfig.getDataLayerConfig(page);
		if (config != null) {
			DataLayer dataLayer = new DataLayer(config, page);
			request.setAttribute(DataLayerConstants.REQUEST_PROPERTY_AEM_DATALAYER, dataLayer);
			request.setAttribute(REQUEST_PROPERTY_AEM_DATALAYER_APPLICABLE, new Boolean(true));
			return true;
		} else {
			request.setAttribute(REQUEST_PROPERTY_AEM_DATALAYER_APPLICABLE, new Boolean(false));
			return false;
		}
	} else {
		return new Boolean(true).equals(appliable);
	}
}
 
开发者ID:PerficientDigital,项目名称:AEM-DataLayer,代码行数:21,代码来源:AEMDataLayerInterceptorFilter.java

示例2: testDoGet

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Test
public void testDoGet() throws Exception {
    ImageDelegateRenderCondition imageDelegateRenderCondition = new ImageDelegateRenderCondition();
    SlingHttpServletRequest request = prepareRequest();
    imageDelegateRenderCondition.doGet(request, CONTEXT.response());
    RenderCondition renderCondition = (RenderCondition) request.getAttribute(RenderCondition.class.getName());
    assertNotNull(renderCondition);
    assertTrue(renderCondition.check());
    ExpressionCustomizer expressionCustomizer = (ExpressionCustomizer) request.getAttribute(ExpressionCustomizer.class.getName());
    assertNotNull(expressionCustomizer);
    assertTrue(expressionCustomizer.hasVariable(AbstractImageDelegatingModel.IMAGE_DELEGATE));
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:13,代码来源:ImageDelegateRenderConditionTest.java

示例3: doGet

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
        throws ServletException, IOException {
    SlingBindings bindings = (SlingBindings) request.getAttribute(SlingBindings.class.getName());
    Page currentPage = (Page) bindings.get(WCMBindings.CURRENT_PAGE);
    final Locale pageLocale = currentPage.getLanguage(true);
    final ResourceBundle bundle = request.getResourceBundle(pageLocale);
    i18n = new I18n(bundle);
    SimpleDataSource countriesDataSource = new SimpleDataSource(buildCountriesList(request.getResourceResolver()).iterator());
    request.setAttribute(DataSource.class.getName(), countriesDataSource);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:12,代码来源:CountriesFormOptionsDataSource.java

示例4: login

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
public CommerceSession login(SlingHttpServletRequest request, SlingHttpServletResponse response) throws CommerceException {
    // This avoids that the session is instantiated multiple times by multiple components for the same request
    Object session = request.getAttribute(REQUEST_ATTRIBUTE_NAME);
    if (session != null) {
        return (CommerceSession) session;
    }

    CommerceSession commerceSession = new WeRetailCommerceSessionImpl(this, request, response, resource);
    request.setAttribute(REQUEST_ATTRIBUTE_NAME, commerceSession);
    return commerceSession;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:13,代码来源:WeRetailCommerceServiceImpl.java

示例5: activate

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
public void activate() {
    SlingHttpServletRequest request = getRequest();
    SlingHttpServletResponse response = getResponse();
    ResourceResolver resolver = getResourceResolver();

    isAnonymous = "anonymous".equals(resolver.adaptTo(Session.class).getUserID());

    message = (String) request.getAttribute(SlingConstants.ERROR_MESSAGE);
    Integer scObject = (Integer) request.getAttribute(SlingConstants.ERROR_STATUS);

    code = (scObject != null) ? scObject.intValue() : response.SC_INTERNAL_SERVER_ERROR;

    if (message == null) {
        message = statusToString(code);
    }

    // Print stack trace only if the user is not anonymous
    if (!isAnonymous) {
        if (request.getAttribute(SlingConstants.ERROR_EXCEPTION) instanceof Throwable) {
            Throwable throwable = (Throwable) request.getAttribute(SlingConstants.ERROR_EXCEPTION);
            printStackTrace(throwable);
        }
    }

    response.setStatus(code);
    response.setContentType("text/html"); 
    response.setCharacterEncoding("utf-8");
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:30,代码来源:ErrorHandler.java


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