0

这里对 JSF 来说相当新,所以非常感谢任何帮助。我将 JSF 1.2 与 WebSphere Portal 一起使用。

我的 JSP 中有一个字段,我试图在我的 FMB 中获取值。问题是,当我将值从 FMB 写入日志时,它显示为 NULL。不知道为什么。

从 commandLink 调用 JSF 操作:

<h:commandLink action="#{planDocBean.classAction}">

FMB代码如下:

String state = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("stateValue");
log.debug("stateValue FMB: " + state);

我的 JSP:

<input type="hidden" id="stateValue" value="${stateValue}" />

javascript 片段从 onChange 函数调用状态值下拉以更新隐藏的输入值。这件作品有效。

JSP中的Javascript:

function setStateValue() {
var stateValue = document.getElementById("stateValue").value;
var e = document.getElementById("states");
var selectedState = e.options[e.selectedIndex].value;
document.getElementById("stateValue").value = selectedState;
}

我知道有替代的 h:inputHidden 方法,但我想知道为什么这不起作用。

我也在我的 FMB 中尝试过,但仍然为 NULL:

HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
log.debug("stateValue 1: " + req.getParameter("stateValue"));

再次,我将非常感谢任何帮助。

谢谢!

4

0 回答 0