本文整理汇总了Java中org.thymeleaf.Arguments类的典型用法代码示例。如果您正苦于以下问题:Java Arguments类的具体用法?Java Arguments怎么用?Java Arguments使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Arguments类属于org.thymeleaf包,在下文中一共展示了Arguments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addProductInventoryData
import org.thymeleaf.Arguments; //导入依赖的package包/类
protected void addProductInventoryData(Map<String, Object> attrMap, Arguments arguments) {
List<Long> outOfStockProducts = new ArrayList<Long>();
Set<Product> products = (Set<Product>) ((Map<String, Object>) arguments.getExpressionEvaluationRoot()).get("blcAllDisplayedProducts");
if (products != null) {
for (Product product : products) {
if (product.getDefaultSku() != null) {
Boolean qtyAvailable = inventoryService.isAvailable(product.getDefaultSku(), 1);
if (qtyAvailable != null && !qtyAvailable) {
outOfStockProducts.add(product.getId());
}
}
}
}
attrMap.put("outOfStockProducts", outOfStockProducts);
}
示例2: getModifiedAttributeValues
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
String elementName = element.getNormalizedName();
String useCDN = element.getAttributeValue("useCDN");
if (LINK.equals(elementName) || (useCDN != null && "true".equals(useCDN))) {
attrs = super.getModifiedAttributeValues(arguments, element, attributeName);
String srcAttr = attrs.remove("src");
attrs.put(HREF, srcAttr);
} else {
attrs.put(HREF, element.getAttributeValue(attributeName));
}
return attrs;
}
示例3: getContentItems
import org.thymeleaf.Arguments; //导入依赖的package包/类
/**
* @param contentName name of the content to be looked up (can be null)
* @param maxResults maximum results to return
* @param request servlet request
* @param mvelParameters values that should be considered when filtering the content list by rules
* @param structuredContentType the type of content that should be returned
* @param locale current locale
* @param arguments Thymeleaf Arguments passed into the tag
* @param element element context that this Thymeleaf processor is being executed in
* @return
*/
protected List<StructuredContentDTO> getContentItems(String contentName, Integer maxResults, HttpServletRequest request,
Map<String, Object> mvelParameters,
SandBox currentSandbox,
StructuredContentType structuredContentType,
Locale locale, Arguments arguments, Element element) {
List<StructuredContentDTO> contentItems;
if (structuredContentType == null) {
contentItems = structuredContentService.lookupStructuredContentItemsByName(contentName, locale, maxResults, mvelParameters, isSecure(request));
} else {
if (contentName == null || "".equals(contentName)) {
contentItems = structuredContentService.lookupStructuredContentItemsByType(structuredContentType, locale, maxResults, mvelParameters, isSecure(request));
} else {
contentItems = structuredContentService.lookupStructuredContentItemsByName(structuredContentType, contentName, locale, maxResults, mvelParameters, isSecure(request));
}
}
//add additional fields to the model
extensionManager.getProxy().addAdditionalFieldsToModel(arguments, element);
return contentItems;
}
示例4: getNewLocalVariables
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
protected Map<String, Object> getNewLocalVariables(Arguments arguments, Element element) {
initServices(arguments);
FieldWrapper fieldWrapper = new FieldWrapper();
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue("fieldBuilder"));
String fieldBuilder = (String) expression.execute(arguments.getConfiguration(), arguments);
if (fieldBuilder != null) {
RuleBuilderFieldService ruleBuilderFieldService = ruleBuilderFieldServiceFactory.createInstance(fieldBuilder);
if (ruleBuilderFieldService != null) {
fieldWrapper = ruleBuilderFieldService.buildFields();
}
}
Map<String, Object> newVars = new HashMap<String, Object>();
newVars.put("fieldWrapper", fieldWrapper);
return newVars;
}
示例5: getModifiedAttributeValues
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
BroadleafRequestContext blcContext = BroadleafRequestContext.getBroadleafRequestContext();
HttpServletRequest request = blcContext.getRequest();
String baseUrl = request.getRequestURL().toString();
Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
Integer page = (Integer) expression.execute(arguments.getConfiguration(), arguments);
if (page != null && page > 1) {
params.put(SearchCriteria.PAGE_NUMBER, new String[] { page.toString() });
} else {
params.remove(SearchCriteria.PAGE_NUMBER);
}
String url = ProcessorUtils.getUrl(baseUrl, params);
attrs.put("href", url);
return attrs;
}
示例6: modifyModelAttributes
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
protected void modifyModelAttributes(Arguments arguments, Element element) {
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue("itemId"));
String itemId = String.valueOf(expression.execute(arguments.getConfiguration(), arguments));
RatingSummary ratingSummary = ratingService.readRatingSummary(itemId, RatingType.PRODUCT);
if (ratingSummary != null) {
addToModel(arguments, getRatingsVar(element), ratingSummary);
}
Customer customer = CustomerState.getCustomer();
ReviewDetail reviewDetail = null;
if (!customer.isAnonymous()) {
reviewDetail = ratingService.readReviewByCustomerAndItem(customer, itemId);
}
if (reviewDetail != null) {
addToModel(arguments, "currentCustomerReview", reviewDetail);
}
}
示例7: addAllProductOptionsToModel
import org.thymeleaf.Arguments; //导入依赖的package包/类
private void addAllProductOptionsToModel(Arguments arguments, Product product) {
List<ProductOption> productOptions = product.getProductOptions();
List<ProductOptionDTO> dtos = new ArrayList<ProductOptionDTO>();
for (ProductOption option : productOptions) {
ProductOptionDTO dto = new ProductOptionDTO();
dto.setId(option.getId());
dto.setType(option.getType().getType());
Map<Long, String> values = new HashMap<Long, String>();
for (ProductOptionValue value : option.getAllowedValues()) {
values.put(value.getId(), value.getAttributeValue());
}
dto.setValues(values);
dtos.add(dto);
}
writeJSONToModel(arguments, "allProductOptions", dtos);
}
示例8: getNewLocalVariables
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
protected Map<String, Object> getNewLocalVariables(Arguments arguments, Element element) {
Map<String, Object> localVars = new HashMap<String, Object>();
Map<String, String> creditCardTypes = new HashMap<String, String>();
try {
extensionManager.getProxy().populateCreditCardMap(creditCardTypes);
} catch (Exception e) {
LOG.warn("Unable to Populate Credit Card Types Map for this Payment Module, or card type is not needed.");
}
if (!creditCardTypes.isEmpty()) {
localVars.put("paymentGatewayCardTypes", creditCardTypes);
}
return localVars;
}
示例9: resolveMessage
import org.thymeleaf.Arguments; //导入依赖的package包/类
/**
* Resolve a translated value of an object's property.
*
* @param args
* @param key
* @param messageParams
* @return the resolved message
*/
public MessageResolution resolveMessage(final Arguments args, final String key, final Object[] messageParams) {
Validate.notNull(args, "args cannot be null");
Validate.notNull(args.getContext().getLocale(), "Locale in context cannot be null");
Validate.notNull(key, "Message key cannot be null");
if (I18N_VALUE_KEY.equals(key)) {
Object entity = messageParams[0];
String property = (String) messageParams[1];
Locale locale = args.getContext().getLocale();
if (LOG.isTraceEnabled()) {
LOG.trace(String.format("Attempting to resolve translated value for object %s, property %s, locale %s",
entity, property, locale));
}
String resolvedMessage = translationService.getTranslatedValue(entity, property, locale);
if (StringUtils.isNotBlank(resolvedMessage)) {
return new MessageResolution(resolvedMessage);
}
}
return null;
}
示例10: getModifiedAttributeValues
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
SparkRequestContext blcContext = SparkRequestContext.getSparkRequestContext();
HttpServletRequest request = blcContext.getRequest();
String baseUrl = request.getRequestURL().toString();
Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
Integer page = (Integer) expression.execute(arguments.getConfiguration(), arguments);
if (page != null && page > 1) {
params.put(ProductSearchCriteria.PAGE_NUMBER, new String[] { page.toString() });
} else {
params.remove(ProductSearchCriteria.PAGE_NUMBER);
}
String url = ProcessorUtils.getUrl(baseUrl, params);
attrs.put("href", url);
return attrs;
}
示例11: getModifiedAttributeValues
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
SparkRequestContext blcContext = SparkRequestContext.getSparkRequestContext();
HttpServletRequest request = blcContext.getRequest();
String baseUrl = request.getRequestURL().toString();
Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
SearchFacetDTO facet = (SearchFacetDTO) expression.execute(arguments.getConfiguration(), arguments);
String key = facet.getFacet().getField().getAbbreviation();
params.remove(key);
params.remove(ProductSearchCriteria.PAGE_NUMBER);
String url = ProcessorUtils.getUrl(baseUrl, params);
attrs.put("href", url);
return attrs;
}
示例12: processElement
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
protected ProcessorResult processElement(Arguments arguments, Element element) {
StringBuffer sb = new StringBuffer();
sb.append("<SCRIPT>\n");
sb.append(" var params = \n ");
sb.append(buildContentMap(arguments)).append(";\n ");
sb.append(getUncacheableDataFunction(arguments, element)).append(";\n");
sb.append("</SCRIPT>");
// Add contentNode to the document
Node contentNode = new Macro(sb.toString());
element.clearChildren();
element.getParent().insertAfter(element, contentNode);
element.getParent().removeChild(element);
// Return OK
return ProcessorResult.OK;
}
示例13: modifyModelAttributes
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
protected void modifyModelAttributes(Arguments arguments, Element element) {
String resultVar = element.getAttributeValue("resultVar");
if (resultVar == null) {
resultVar = "value";
}
String attributeName = element.getAttributeValue("name");
String attributeValue = SCSystemProperty.resolveSystemProperty(attributeName);
addToModel(arguments, resultVar, attributeValue);
}
示例14: getModifiedAttributeValues
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
String href = "#";
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
AdminSection section = (AdminSection) expression.execute(arguments.getConfiguration(), arguments);
if (section != null) {
HttpServletRequest request = ((SpringWebContext) arguments.getContext()).getHttpServletRequest();
href = request.getContextPath() + section.getUrl();
}
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("href", href);
return attrs;
}
示例15: getModifiedAttributeValues
import org.thymeleaf.Arguments; //导入依赖的package包/类
@Override
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
PaymentRequestDTO requestDTO = (PaymentRequestDTO) StandardExpressionProcessor.processExpression(arguments, element.getAttributeValue(attributeName));
String url = "";
if (requestDTO != null) {
if ( element.getAttributeValue("complete_checkout") != null) {
Boolean completeCheckout = (Boolean) StandardExpressionProcessor.processExpression(arguments,
element.getAttributeValue("complete_checkout"));
element.removeAttribute("complete_checkout");
requestDTO.completeCheckoutOnCallback(completeCheckout);
}
try {
PaymentResponseDTO responseDTO = paymentGatewayHostedService.requestHostedEndpoint(requestDTO);
url = responseDTO.getResponseMap().get(NullPaymentGatewayConstants.HOSTED_REDIRECT_URL).toString();
} catch (PaymentException e) {
throw new RuntimeException("Unable to Create Null Payment Gateway Hosted Link", e);
}
}
attrs.put("action", url);
return attrs;
}