You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paulo Rezende <ja...@pmbr.net> on 2003/12/30 18:42:58 UTC

Adding items to a vector of formbean in the jsp

Struters,

I need help from somebody.

I have a formbean that has a vector property, and my jsp has a iterator that renderizes this:

  <input type="hidden" name="userList[0].id"   value="1"     id="id0">
  <input type="hidden" name="userList[0].name" value="paul" id="name0">

  <input type="hidden" name="userList[1].id"   value="2"     id="id1">
  <input type="hidden" name="userList[1].name" value="john" id="name1">

If i change the value of any of these inputs and submit the page, the requestprocessor parse and update the values of the vector in the formbean correctly.

By if i, dinamicly with dom, create new inputs increasing the index (like in the example below) and submit the page, i get a exception of Beans.populate(), a out of ranger error.

      newInput = document.createElement("input");
      newInput.type = "hidden";
      newInput.name = "userList[2].id";
      newInput.id   = "id2";
      myHmtlBody.appendChild(inp);

      document.getElementById("id2").value = 3;

      newInput = document.createElement("input");
      newInput.type = "hidden";
      newInput.name = "userList[2].name";
      newInput.id   = "name2";
      myHmtlBody.appendChild(inp);

      document.getElementById("name2").value = "peter";

What i really want is that, when i submit the page, the requestprocessor add a new item in the vector and set the values of the new item with the values of the new inputs.

Anybody have any thing to say or suggest, any idea?

thanks, Paulo