我的JSP中有这个jstl变量:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:useBean id="RECHERCHE_SCENARIO_BEAN"
class="recherche.RechercheScenarioBean"
scope="session" />
<c:set scope="page" var="totoBean"
value="${ RECHERCHE_SCENARIO_BEAN.totoBean }" />
如何在javascript函数中调用totoBean?
答案 0 :(得分:0)
通过“h:inputHidden”标记渲染隐藏字段,通过JavaScript分配新值。
... JSF
<script type="text/javascript">
function setHiddenValue(new_value){
document.getElementById('myForm:hidden2').value = new_value;
}
</script>
<h:form id="myForm">
<h:inputHidden id="hidden2" value="#{user.hidden2}" />
<h:commandButton value="submit" action="..." onclick="setHiddenValue('this is hidden2');" />
</h:form>
我的托管bean
@ManagedBean(name="user")
@SessionScoped
public class UserBean
{
public String hidden2;
public void setHidden2(String hidden2) {
this.hidden2 = hidden2;
}
}