我试图获取 xe:dialog 中包含的文本区域的文本输入句柄,但没有成功。按下 XPage 上的按钮后,xe:dialog 将“弹出”。这是我的代码:
<xe:dialog id="InputDialog5">
<xe:this.title>"Input Dialog</xe:this.title>
<xp:panel>
<xp:inputTextarea id="InputTextBox5" value="#{document1.InputTextBox5}"
cols="60" rows="4"></xp:inputTextarea>
</xp:panel>
<xe:dialogButtonBar id="dialogButtonBar15">
<xp:button value="OK" id="button37">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete" immediate="true">
<xp:this.action><![CDATA[#{javascript:
var request = facesContext.getExternalContext().getRequest();
var header = request.getHeader("Cookie");
var inputVal = @Middle(header,"InputTextBox5=",";")
setJobReferenceStatus(40,inputVal);
var redirect = "window.location='"+applicationScope.get("redirect")+"'";
facesContext.getViewRoot().postScript(redirect);}]]></xp:this.action>
<xp:this.script><![CDATA[
var inputvalue = document.getElementById("InputTextBox5").value;
alert("inputvalue = " + inputvalue);
dojo.cookie("InputTextBox5", inputvalue, { expires: 1 });
]]></xp:this.script>
</xp:eventHandler>
</xp:button>
</xe:dialogButtonBar>
</xe:dialog>
我的想法是获取文本区域的值,将其添加到 dojo cookie,使用 SSJS 检索 cookie 值,然后将该值传递给 SSJS 函数。然而,代码在获取文本区域值的阶段就已经失败了。 “警报(”输入值=“+输入值);”行不执行并且对话框保持“卡住”状态。关于如何解决这个问题有什么想法吗?
最佳答案
为了从客户端 Javascript 获取文本字段的句柄,您必须知道 XPage 生成的客户端 ID。因此,请执行此操作来计算 CSJS 中的 id:
<xp:this.script><![CDATA[
var inputvalue = document.getElementById("#{id:InputTextBox5}").value;
alert("inputvalue = " + inputvalue);
dojo.cookie("InputTextBox5", inputvalue, { expires: 1 });
]]></xp:this.script>
关于javascript - XPages - 获取对话框内文本区域的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21775983/