我想为我的XPage应用程序设置一些基本的REST服务.所以我在xpage上添加了xe:restService控件并选择xe:customRestService,其中我引用了一个Java类:
<xe:restService id="restService1" pathInfo="json" state="false">
<xe:this.service>
<xe:customRestService contentType="application/json"
serviceBean="se.banking.desk.CustomSearchHelper">
</xe:customRestService>
</xe:this.service>
</xe:restService>
Run Code Online (Sandbox Code Playgroud)
自己的CustomSearchHelper类仍然很空,但我想知道我是否在正确的轨道上?
这是该类的代码:
package se.banking.desk;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ibm.domino.services.ServiceException;
import com.ibm.domino.services.rest.RestServiceEngine;
import com.ibm.xsp.extlib.component.rest.CustomService;
import com.ibm.xsp.extlib.component.rest.CustomServiceBean;
public class CustomSearchHelper extends CustomServiceBean {
@Override
public void renderService(CustomService service, RestServiceEngine engine) throws ServiceException {
HttpServletRequest request = engine.getHttpRequest();
String method = request.getMethod();
HttpServletResponse response = engine.getHttpResponse();
response.setHeader("Content-Type", "text/javascript; charset=UTF-8");
if(method.equals("GET")){
this.get(engine);
}
else if(method.equals("POST")){
this.post(engine,request);
}
else{
this.other(engine);
}
}
public void get(RestServiceEngine engine){
HttpServletResponse response …Run Code Online (Sandbox Code Playgroud) 我有一个客户端脚本,我在其中启动一些SSJS来收集驻留在strings.properties文件中的字符串值:
function confirmBeforeDelete(){
var msgEmptySelection = "#{javascript:strings['empty']}";
var msgConfirm = "#{javascript:strings['confirm']}";
if(!XSP.isViewPanelRowSelected("#{id:vwPnlDefault}", "col1")) {
!XSP.alert(msgEmptySelection);
return false;
}
if(!XSP.confirm(msgConfirm)) {return false;}
}
Run Code Online (Sandbox Code Playgroud)
这很好用.但是当我将脚本存储在csjs库中时,我的短信变为:#{javascript:strings ['empty']}和#{javascript:strings ['confirm']}.我究竟做错了什么?
有没有办法通过SSJS以更灵活的方式访问Java对象上的字段?
因此,当我的Java对象存储在obj变量中时,我可以通过obj.created访问创建的字段.
但是,我会使我的解决方案更灵活,因此字段的名称将通过自定义控件上的属性定义提供.
我得到的字段的名称:
compositeData.fieldName
Run Code Online (Sandbox Code Playgroud)
我怎样才能把它弯曲成:
var field = compositeData.fieldName;
obj.????
Run Code Online (Sandbox Code Playgroud)
我试过了
obj.getField(field);
Run Code Online (Sandbox Code Playgroud)
(来源:https://www.tutorialspoint.com/java/lang/class_getfield.htm)
给我一个错误:
com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:132)
有人有建议吗?
我有一个来自 ExtLib 的数据视图控件,它已分类。但是,默认情况下类别会扩展。我怎样才能将其设置为折叠?
我已经看到了 viewpanel 控件的代码,但这不适用于 dataview 控件。
在我的xpages应用程序中,我在sessionScope变量中设置了一些对用户会话有效的变量.
我想在我的Java类中使用这些用户设置.
可以在我的java类中读取特定的sessionScope变量,我该怎么做?
对于xp:inputtext控件我想添加属性[aria-required ='true'],但我想知道如何通过attributes属性实现这一点而无需设置标签?
我试过了:
<xp:this.attrs>
<xp:attr>
<xp:this.value><![CDATA[[aria-required='true']]]></xp:this.value>
</xp:attr>
</xp:this.attrs>
Run Code Online (Sandbox Code Playgroud)
但后来我得到了错误信息:
说明资源路径位置类型xp:attr的必需属性"name"不存在.
我正在考虑使用包管理器来避免在 GIT 中注册外部资源。但我想知道我应该如何设置我的项目?
现在在 GIT 中,我将 NSF 代码注册在 ODP 文件夹中,例如 projectx\ODP\ eg projectx\OODP\WebContent\DataTables
当我运行包管理器时,我注意到资源存储在文件夹 node_modules 中包含 package.json 文件的文件夹中。
这是否意味着我应该将 package.json 文件存储在 WebContent 文件夹中,或者我可以在包文件中指定模块的安装位置?
为了避免在 GIT 中为源代码管理注册文件,我应该在 .gitignore 文件中注册它们并声明 ODP\WebContent* 但这也会使 package.json 文件不受源代码管理的影响,我希望将其置于源代码管理之下。
一切都让我困惑。
有人能告诉我您是如何使用包管理器和 GIT 为 XPage 开发设置工作区的吗?