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