gpt4 book ai didi

xpages - 如何提取 XPage 中 UIInput 的值

转载 作者:行者123 更新时间:2023-12-01 16:27:52 25 4
gpt4 key购买 nike

我有一个可以操作合约的 Xpages 应用程序。一个过程使用“conService”字段中的契约(Contract)类型值来确定接下来必须发生的情况。下面的代码不会产生任何错误,但第三行似乎没有处理任何结果,事实上甚至似乎没有处理其后的过程中的任何行。如何提取 conService 的值?谢谢

UIInput uifield = (UIInput) JSFUtil.findComponent("conService");
String serviceName ="";
serviceName = uifield.getValue().toString();

最佳答案

你就快到了......

一旦获得了 UIInput 对象,您就可以执行 .getSubscribedValue() 或 .getValue() - 取决于您处于 JSF 生命周期的哪个阶段。然后您只需将其转换为字符串 - 而不是使用 toString()。

所以类似的东西应该可以解决问题:

UIInput uifield = (UIInput) JSFUtil.findComponent("conService");
String serviceName = (String)uifield.getValue();

为了避免考虑使用 getSubscribedValue 或 getValue,我在代码中使用了一个小型实用方法:

ublic static Object getSubmittedValue(UIComponent c) {
// value submitted from the browser
Object o = null;
if (null != c) {
o = ((UIInput) c).getSubmittedValue();
if (null == o) {
// else not yet submitted
o = ((UIInput) c).getValue();
}
}
return o;
}

这只会让生活变得不那么复杂;-)

/约翰

关于xpages - 如何提取 XPage 中 UIInput 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23910386/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com