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


Java SlingHttpServletRequest.setAttribute方法代码示例

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


在下文中一共展示了SlingHttpServletRequest.setAttribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: doGet

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response)
        throws ServletException, IOException {
    try {
        WorkflowSession workflowSession = request.getResourceResolver().adaptTo(WorkflowSession.class);
        ArrayList<Resource> resources = new ArrayList<>();
        if (workflowSession != null) {
            WorkflowModel[] models = workflowSession.getModels();
            for (WorkflowModel model : models) {
                resources.add(new WorkflowModelResource(model, request.getResourceResolver()));
            }
        }
        SimpleDataSource dataSource = new SimpleDataSource(resources.iterator());
        request.setAttribute(DataSource.class.getName(), dataSource);
    } catch (WorkflowException e) {
        throw new ServletException(e);
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:19,代码来源:WorkflowModelDataSourceServlet.java

示例3: doGet

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response)
        throws ServletException, IOException {
    SimpleDataSource actionTypeDataSource = new SimpleDataSource(getActionTypeResources(
            request.getResourceResolver()).iterator());
    request.setAttribute(DataSource.class.getName(), actionTypeDataSource);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:8,代码来源:FormActionTypeDataSourceServlet.java

示例4: doGet

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response)
        throws ServletException, IOException {
    SimpleDataSource actionTypeSettingsDataSource = new SimpleDataSource(getSettingsDialogs(
            request.getResourceResolver()).iterator());
    request.setAttribute(DataSource.class.getName(), actionTypeSettingsDataSource);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:8,代码来源:FormActionTypeSettingsDataSourceServlet.java

示例5: doGet

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response)
        throws ServletException, IOException {
    boolean hasImageDelegation = false;
    ResourceResolver resourceResolver = request.getResourceResolver();
    ComponentManager componentManager = resourceResolver.adaptTo(ComponentManager.class);
    String suffix = request.getRequestPathInfo().getSuffix();
    if (componentManager != null && StringUtils.isNotEmpty(suffix)) {
        Resource policiesRootPage = getPoliciesRootPage(resourceResolver, suffix);
        if (policiesRootPage != null) {
            String resourceType = suffix.substring(policiesRootPage.getPath().length() + 1, suffix.lastIndexOf('/'));
            com.day.cq.wcm.api.components.Component component = componentManager.getComponent(resourceType);
            if (component != null && component.isAccessible()) {
                String imageDelegate = component.getProperties().get(AbstractImageDelegatingModel.IMAGE_DELEGATE, String.class);
                if (StringUtils.isNotEmpty(imageDelegate)) {
                    hasImageDelegation = true;
                    com.day.cq.wcm.api.components.Component delegate = componentManager.getComponent(imageDelegate);
                    if (delegate != null && delegate.isAccessible()) {
                        ExpressionCustomizer customizer = ExpressionCustomizer.from(request);
                        customizer.setVariable(AbstractImageDelegatingModel.IMAGE_DELEGATE, delegate);
                    }
                }
            }
        }
    }
    request.setAttribute(RenderCondition.class.getName(), new SimpleRenderCondition(hasImageDelegation));
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:28,代码来源:ImageDelegateRenderCondition.java

示例6: 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

示例7: 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

示例8: doGet

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response)
        throws ServletException, IOException {
    SimpleDataSource allowedTypesDataSource = new SimpleDataSource(getAllowedTypes(request).iterator());
    request.setAttribute(DataSource.class.getName(), allowedTypesDataSource);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:7,代码来源:AllowedTitleSizesDataSourceServlet.java

示例9: updateRequestWithAttributes

import org.apache.sling.api.SlingHttpServletRequest; //导入方法依赖的package包/类
private void updateRequestWithAttributes(SlingHttpServletRequest request, Map<String, String> attributes) {
	for (Entry<String, String> attr : attributes.entrySet()) {
		request.setAttribute(WILDCARD_ATTRIBUTE_PREFIX + attr.getKey(), attr.getValue());
	}
}
 
开发者ID:HeroDigital,项目名称:sling-rest,代码行数:6,代码来源:SlingRestServiceServlet.java


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