如何在我的面部消息bean中获取输入类型隐藏值(当h:commandLink单击时)?

时间:2013-06-22 21:07:15

标签: jsf jsf-1.2

这里的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}" />

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

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"));

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

谢谢!

0 个答案:

没有答案