我正试图在Sightly中实现递归算法解决河内塔问题.我知道这种方法可能没有很多明显的实际应用,我将其视为一个难题.我最终得到这样的东西:
<sly data-sly-template.step="${@ n, src, aux, dst}" data-sly-unwrap>
<sly data-sly-test="${n > 0}" data-sly-unwrap>
<sly data-sly-call="${step @ n = (n-1), src = src, aux = dst, dst = aux}" data-sly-unwrap/>
${src} -> ${dst}<br/>
<sly data-sly-call="${step @ n = (n-1), src = aux, aux = src, dst = dst}" data-sly-unwrap/>
</sly>
</sly>
<sly data-sly-call="${step @ n = 3, src = 'A', aux = 'B', dst = 'C'}" data-sly-unwrap/>
Run Code Online (Sandbox Code Playgroud)
但是,它没有编译,因为Sightly不支持算术运算符-.我不需要从3到0计数,我们可能会采用相反的方式,因为这里的方向并不重要.我只需要一些具有以下功能的计数器:
我想过用字符串.空字符串为零,'x'为1,'xx'为2,依此类推.我们可以检查字符串是否等于数字(n == 'xxxx').我们甚至可以使用Sightly string formatter来增加它:
${'x{0}' …Run Code Online (Sandbox Code Playgroud) Adobe AEM parsys组件呈现所有子资源,如果WCM模式设置为适当的值,则显示Drop组件部分,可用于添加新段落.在实施下降成分部分是很奇怪的-这是嵌入式与独立的部件<cq:include> 标签,但路径参数设置为*(星):
<cq:include path="*" resourceType="<%= newType %>"/>
Run Code Online (Sandbox Code Playgroud)
(newType是此行之前设置的Java变量).
这里发生了什么?这颗恒星的目的是什么?
我想用自定义对象扩展Sling绑定,因此它将在所有JSP文件中可用而无需额外的努力.我正在实现BindingsValuesProviderOSGi服务,就像这样(它不是一个真正的代码,但足够类似):
@Component
@Service
public class ContentBranchBindingProvider implements BindingsValuesProvider {
@Override
public void addBindings(Bindings bindings) {
final Resource resource = (Resource) bindings.get("resource");
final String[] splitPath = StringUtils.split(resource.getPath(), '/');
bindings.put("contentBranch", splitPath[1]);
}
}
Run Code Online (Sandbox Code Playgroud)
我希望contentBranch绑定在JSP中可用作脚本变量:
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@include file="/libs/foundation/global.jsp"%>
Your content branch is: ${contentBranch}
Run Code Online (Sandbox Code Playgroud)
但是,上面的JSP不输出内容分支,但是:
您的内容分支是:
我使用调试器来查看addBindings()调用我的方法并将正确的值放入bindingsmap中.如何${contentBranch}在JSP中使用它?
我想使用sling taglib在我的jsp中实例化一个服务对象.在正常情况下,服务类只由一个类实现,它非常简单: -
RegistrationService registrationService = sling.getService(RegistrationService.class);
Run Code Online (Sandbox Code Playgroud)
但是如果服务类有多个实现类,那么我们如何确保为特定类实例化对象.
我的java类是这样的: -
1.接口:RegistrationService
2.实现类1: -
@Properties({@Property(name = "datasource", value = "SBWS"})
@Service
public class RegistrationServiceImpl implements RegistrationService{
}
Run Code Online (Sandbox Code Playgroud)
3.实施类2: -
@Properties({@Property(name = "datasource", value = "SOLR"})
@Service
public class RegistrationServiceImpl implements RegistrationService{
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能确保使用
RegistrationService registrationService = sling.getService(RegistrationService.class);
Run Code Online (Sandbox Code Playgroud)
在jsp中将实例化服务,让我们说实现类1
我需要构建一个 curl 命令,该命令将更改存储库中特定节点上组的读取等权限。我显然可以手动执行此操作,但需要创建一个脚本。我已经看到为用户执行此操作的示例,但我无法使其适用于组。在我下面的示例中,“acme-authors”是一个组。
产生明显正确的响应,但不会改变任何东西
curl -u admin:admin -F:applyTo=acme-authors \
http://server.com:4502/etc/tags/acme.acl.json
Run Code Online (Sandbox Code Playgroud)
给出“没有找到 principalId”错误
curl -u admin:admin -FprincipalId=acme-authors -Fprivilege@jcr:read=denied \
http://server.com:4502/etc/tags/acme.acl.json
curl -u admin:admin -FgroupId=acme-authors -Fprivilege@jcr:read=denied \
http://server.com:4502/etc/tags/acme.acl.json
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何为团体做到这一点?
谢谢!