在Sightly/AEM6中,当包含一个parsys组件时,如何设置"Drag Components Here"(cq:emptyText)使用本地化字符串的文本?我有几个parsys组件作为自定义组件的子组件,并且每个组件需要不同的文本(例如,在此处拖动图像组件,在此处拖动链接组件).
我正在查看sightly中使用的表达式选项.我尝试了下面的代码行,但似乎只是在页面上呈现文本,有人可以提供一些选项和一些很好的例子.
${'Assets' @ i18n, locale='fr-CH', hint='Translation Hint'}
${'Page {0} of {1}' @ format = [count,total] }
Run Code Online (Sandbox Code Playgroud)
我已经尝试并理解下面的代码来包含parsys
<div data-sly-resource ="${@path='question_list', resourceType='wcm/foundation/components/parsys'}"></div>
Run Code Online (Sandbox Code Playgroud)
此外,我可以从中获取数据狡猾的[元素]的整个列表.
谢谢
如何仅在 AEM 的预览/发布模式下轻松删除装饰标签?
我看过问答:AEM/CQ: Conditional CSS class on decoration tag
这会删除装饰但阻止我编辑组件,因为它也删除了编辑和设计模式下的装饰。需要什么条件才能仅删除预览/发布中的装饰标签?
我还看到可以将以下代码添加到我的 java-use 类的 activate 方法中:
if (!getWcmMode().isEdit() && !getWcmMode().isDesign()) {
IncludeOptions.getOptions(getRequest(), true).setDecorationTagName("");
}
Run Code Online (Sandbox Code Playgroud)
这将删除除一个装饰标签之外的所有标签,请参见下面的示例:
wcmmode=disabled 中的 HTML 没有激活方法中的上述代码:
<ul class="timeline">
<div class="section timelineTag">
<div class="section timelineTag">
<div class="section timelineTag">
<li class="clear"></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
wcmmode=disabled 中的 HTML 在 activate 方法中使用上述代码:
<ul class="timeline">
<div class="section timelineTag">
<li class="event" href="#">
<li class="event" href="#">
<li class="clear"></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
如何删除 ul 中的第一个装饰 DIV 标记,因为当我将指定的代码添加到 activate 方法时它不会消失?
根据此处的要求,详细查看相关组件(2015 年 7 月 5 日更新):
Java类
public class …Run Code Online (Sandbox Code Playgroud) 我正在尝试在AEM 6.1上执行以下操作:
我能够将值提交给servlet,并处理它们(业务逻辑),并将结果处理到requestparamter,以便我可以在UI上检索它们。但是我坚持这些:
代码段:Servlet
@SlingServlet(
methods = { "POST","GET" },
name="com.tti.tticommons.service.servlets.LeadTimeTrendsServlet",
paths = { "/services/processFormData" }
)
public class TTICommonServlet extends SlingAllMethodsServlet{
...
@Override
protected void doPost(SlingHttpServletRequest request,SlingHttpServletResponse response) throws ServletException,IOException {
String result;
try {
Enumeration<String> parameterNames = request.getParameterNames();
Map<String, String> formParametersMap = new HashMap<String, String>();
while (parameterNames.hasMoreElements()) {
paramName = parameterNames.nextElement();
paramValue = request.getParameter(paramName);
.......
.......
}
request.setAttribute("result",result);
response.sendRedirect("/content/ttii/en/**posttest.html**");
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以使用ho来帮助ho收回posttest.html中的上述“结果”。
我目前有一个填充 JS 数组的数据列表,如下所示:
var infoWindowContent = [
<div data-sly-use.ed="Foo"
data-sly-list="${ed.allassets}"
data-sly-unwrap>
['<div class="info_content">' +
'<h3>${item.assettitle @ context='unsafe'}</h3> ' +
'<p>${item.assettext @ context='unsafe'} </p>' + '</div>'],
</div>
];
Run Code Online (Sandbox Code Playgroud)
我需要在这个数组中添加一些逻辑。如果assetFormat属性是“text/html”,那么我想打印<p>标签。如果assetFormat属性是image/png那么我想打印img标签。
我的目标是这样的。这有可能实现吗?
var infoWindowContent = [
<div data-sly-use.ed="Foo"
data-sly-list="${ed.allassets}"
data-sly-unwrap>
['<div class="info_content">' +
'<h3>${item.assettitle @ context='unsafe'}</h3> ' +
if (assetFormat == "image/png")
'<img src="${item.assetImgLink}</img>'
else if (assetFormat == "text/html")
'<p>${item.assettext @ context='unsafe'}</p>'
+ '</div>'],
</div>
];
Run Code Online (Sandbox Code Playgroud) 我想使用它data-sly-resource来包含资源,但是仅当它存在时,例如
<div class="pull-right" data-sly-resource="/content/blog/stats"></div>
Run Code Online (Sandbox Code Playgroud)
如果资源不存在,脚本执行将失败,并显示以下错误消息:找不到用于处理资源/内容/博客/状态的servlet。从“请求进度”列表中,我可以看到它是SyntheticResource:
TIMER_START {resolveServlet(SyntheticResource,type = null,path = / content / blog / stats)}
仅在资源存在的情况下,如何才能有条件地包括该资源?
对于经典UI,我们可以轻松地在rteplugins标签内添加插件,Adobe在他们的Geometrix-Outdoor项目上构建了一个很好的例子:
<summary
jcr:primaryType="cq:Widget"
fieldLabel="Summary"
name="./summary"
xtype="richtext">
<rtePlugins jcr:primaryType="nt:unstructured">
<table
jcr:primaryType="nt:unstructured"
features="*"/>
<format
jcr:primaryType="nt:unstructured"
features="*"/>
<lists
jcr:primaryType="nt:unstructured"
features="*"/>
<justify
jcr:primaryType="nt:unstructured"
features="*"/>
<edit
jcr:primaryType="nt:unstructured"
features="[paste-wordhtml]"/>
<findreplace
jcr:primaryType="nt:unstructured"
features="*"/>
<paraformat
jcr:primaryType="nt:unstructured"
features="*"/>
<subsuperscript
jcr:primaryType="nt:unstructured"
features="*"/>
<misctools
jcr:primaryType="nt:unstructured"
features="*"/>
<links
jcr:primaryType="nt:unstructured"
features="*"/>
<spellcheck
jcr:primaryType="nt:unstructured"
features="*"
invalidStyle="background-color: #ffdddd;"/>
<undo
jcr:primaryType="nt:unstructured"
features="*"/>
<image
jcr:primaryType="nt:unstructured"
features="*"/>
</rtePlugins>
</summary>
Run Code Online (Sandbox Code Playgroud)
但是我们不能在Touch UI环境中应用相同的东西,他们也在Geometrix-Outdoor上做了一个例子,但是插件没有完全显示功能:
<summary
jcr:primaryType="nt:unstructured"
sling:resourceType="cq/gui/components/authoring/dialog/richtext"
fieldLabel="Summary"
name="./summary"
renderReadOnly="{Boolean}true"/>
Run Code Online (Sandbox Code Playgroud)
反正有没有让TouchUi显示器上的插件显示为经典UI?
我<c:forEach>在jstl中使用过.现在我想要使用.
我的用例是打印1到10之间的数字,然后我如何for loop在java中轻松迭代
我有一个组件使用xtype="richtext"我的项目中的Rich Text Edit小部件(),它在整个站点中用作默认文本组件.
用户希望能够使用telURI方案将电话链接插入使用此组件输入的文本中.
该对话框允许他们这样做,但是当稍后在Sightly/HTL中呈现富文本编辑的内容时,将使用html上下文:
{$text @ context='html'}
Run Code Online (Sandbox Code Playgroud)
完成此操作后,将忽略my属性的值.
存储在存储库中的HTML是:
<a href="tel:04242424242">Call us!</a>
Run Code Online (Sandbox Code Playgroud)
在作者实例的页面上实际呈现的是:
<a>Call us!</a>
Run Code Online (Sandbox Code Playgroud)
在发布者上,由于链接检查器,标签会被完全删除.
更改上下文会unsafe导致href渲染,但这不是我愿意接受的解决方案.该组件在很多地方使用,我想确保XSS保护足够.
有没有办法影响htmlHTL中的上下文处理电话链接的方式?
我尝试在叠加层中添加一个额外的正则表达式apps/cq/xssprotection/config.xml:
<regexp name="onsiteURL" value="([\p{L}\p{N}\\\.\#@\$%\+&;\-_~,\?=/!]+|\#(\w)+)"/>
<regexp name="offsiteURL" value="(\s)*((ht|f)tp(s?)://|mailto:)[\p{L}\p{N}]+[\p{L}\p{N}\p{Zs}\.\#@\$%\+&;:\-_~,\?=/!]*(\s)*"/>
<regexp name="telephoneLink" value="tel:\+?[0-9]+"/>
Run Code Online (Sandbox Code Playgroud)
进一步说:
<attribute name="href">
<regexp-list>
<regexp name="onsiteURL"/>
<regexp name="offsiteURL"/>
<regexp name="telephoneLink"/>
</regexp-list>
<!-- Skipped for brevity -->
</attribute>
Run Code Online (Sandbox Code Playgroud)
但这似乎并没有影响Sightly/HTL在html上下文中转义字符串的方式.
我也试过覆盖Sling xss规则,/libs/sling/xss/config.xml但也没有运气.
怎么做到呢?