2017  Kodetalk | Feedback | Privacy Policy | Terms | About

Is possible : javascript extract value from c:forEach tag?

Here is the piece of code where iterating the values through forEach tag.But now I want to get those values

in JavaScript.Is any other-way to retrieve the c:forEach tag value

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>   
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

       <script type="text/javascript">

       function getCTagValue(ctagObject)
          alert("CFor Each Tag Object Value: " + ctagObject);
          // Here i want write code for retrieve the c:forEach tag value  

        <h:form id="cTagForm" >              

            <c:forEach items="${cTagBean.tagList}" var="ctag">
                <c:out value="${ctag.name} : "/>
                <c:out value="${ctag.age}"/></br>

            <a4j:commandButton id="GetCtagId"  value="GetCtag" oncomplete="getCTagValue("#{cTagBean.tagList}")"/>



Here is your answer:

<a4j:commandButton id="GetCtagId" 





function getCTagValue(data) 


    for(var i=0; i<data.length; i++)


        alert("Month : " + data[i].name);

        alert("Value : " + data[i].age);



Answer is