本文整理汇总了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);
}
}
示例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;
}
示例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");
}