0

in jsp file.

    <% java.util.Vector <HighlightVO> conditions = bean.getPropVector("HighlightVOList");%>

    <script language="JavaScript">
    var conditions = []; 
        <% for(HighlightVO highlightVO : conditions){ %>
        conditions.push(<%=highlightVO%>); // not working.
        <%}%>

</script>

i am not able to add the highlighVO in conditions[].

Can any one help to do this operations.

3

1 Answer 1

1

The parameters of javascript push must be understanded by javascript. If you look at the javascript code generated, you will probably see something like :

    conditions.push(HighlightVO@6d06d69c)

which is not understanded by javascript.

A solution is to implement the toString() method of HighlightVO in order to return the object in json format.

Adding toString method in HighlightVO class :

  public String toString()
  {
    return '{'+
           'field1:'+field1+','+
           'field2:'+field2+','+
           ...
           '}';
  }

will generate :

conditions.push({field1:1,
                 field2:'2', ...})
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.