问题描述
我支持我公司最早的和第一个 XPage 应用程序.该应用程序不使用 java 进行任何操作,而是使用 SSJS 进行所有操作.我不想开始使用 java bean 来完成这一项任务.
这个问题涉及用java方式做我需要的同样的事情:使用托管 bean 填充组合框的 selectItems(标签、值)(虽然我知道这是更好的方法,但我试图坚持已经建立的模式)>
应用程序将所有关键字加载到 applicationScope 中,然后在需要时使用它们.我正在尝试加载显示值并在存储时返回关联的值.这与传统 Notes 多年来的表现类似.
我更改了 applicationScope 值以在管道 (|) 之后存储值,但我还没有弄清楚如何使用 SSJS 使用该值.我开始怀疑这是否可能.
我尝试使用核心组合框控件而不是 Dojo 组合框来生成我需要的代码.看起来您不能为标签和值使用单独的公式项".有没有人想出一个解决方案,除了使用 java 集合.
您可以在 SSJS 中使用 Java 解决方案.您只需要 var
而不是 new
引用中的初始类名和完整类名,所以 java.util.ArrayList 而不是 ArrayList 和 javax.faces.model.SelectItem 而不是 SelectItem.请参阅此处 http://www-10.lotus.com/ldd/bpmpblog.nsf/dx/xpages-best-practice-computed-selection-lists?opendocument&comments.
所以你链接到的 StackOverflow 问题中的代码转换成 SSJS 应该是:
var options = new java.util.ArrayList();var option = new javax.faces.model.SelectItem();option.setLabel("这是一个标签");option.setValue("这是一个值");options.add(option);退货选项;
I am supporting my companies oldest and first XPages application. The app does not use java for anything and uses SSJS for everything. I do not wish to start using java beans for just this one task.
This question deals with the java way to do the same thing I need: Populating selectItems of the combobox (label, value) using a managed bean (although this I know this is the better way, I am trying to stick to the pattern established already)
The app loads all keywords into applicationScope and then uses them when needed. I am trying to load display values and return the associated value when stored. This is similar to how traditional Notes behaved for years.
I changed the applicationScope values to store the values after a pipe (|) but I haven't figured out how to use the value using SSJS. I am starting to doubt that it is even possible.
I tried using the core combobox control instead of the Dojo combo box to generate the code I would need. It appears like you cannot use separate "formula items" for label and value. Has anyone out there come up with a solution for this one, short of using a java collection.
You can use the Java solution in SSJS. You just need var
instead of the initial class name and the full class names in the new
references, so java.util.ArrayList instead of ArrayList and javax.faces.model.SelectItem instead of SelectItem. See here http://www-10.lotus.com/ldd/bpmpblog.nsf/dx/xpages-best-practice-computed-selection-lists?opendocument&comments.
So the code in the StackOverflow question you linked to converted to SSJS should be:
var options = new java.util.ArrayList();
var option = new javax.faces.model.SelectItem();
option.setLabel("Here's a label");
option.setValue("Here's a value");
options.add(option);
return options;
这篇关于仅使用 SSJS 来填充 Dojo 组合框并包含单独的 itemLabel 和 itemValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!