Question

i have this jstl variable in my JSP :

<%@ 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 }" />

How can i call totoBean in an javascript function ?

Was it helpful?

Solution

Render hidden field via “h:inputHidden” tag, assign new value via 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>

And my managed bean

@ManagedBean(name="user")
@SessionScoped
public class UserBean
{
    public String hidden2;

    public void setHidden2(String hidden2) {
        this.hidden2 = hidden2;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top