當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。