This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1.3

 
Atif Jamil
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m new to struts...
i have problem in creating a new requisition made by employee.
requisition contains(id,date,requisition items) where requisition items is a list of items containing in table rows.
every row contain one item information containing (item id, description, remarks etc)
my problem is that how i dynamically populate table rows...
i already seen some discussion about indexed properties on the forum but all these have some pre-information stored in database.
they display that information first and then edit/update it.
but i want to create blank requisition form and then add rows dynamically how many i want...then submit it to action class
any suggestion please..thanks in advance
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to dynamically populate with what data? If they are new, wouldn't they be blank?
 
Atif Jamil
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to populate the rows of table dynamically and them submit the table data to action class for further processing.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still don't understand what you mean by dynamically. Can you elaborate?

For example,
The user clicks new requisition form. It gets loaded with one row of form fields for one item. These form fields are three text fields initialized to the empty string. The user sees a "+" button. Clicking that button adds a second row of form fields for the second item.
 
Atif Jamil
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have search field

<td><bean:message key="label.name" />
<td><html:text styleId="pname" property="productName" onkeyup="return getProductList(this.value)" />
<td><div id="results" style="margin-left: 200px;"></div>
<td><bean:message key="label.description" />
<td><html:text styleId="pdescription" property="productDescription" />
<bean:message key="label.remarks" />
<html:text styleId="premarks" property="productRemarks" />
<html:button property="addNewRow" value="Add Line Item" onclick="return addRow('dataTable')"></html:button>

i used ajax to find product description and fill the description field. on clicking "addNewRow" button i want to add the row(productName, description, remarks) in table.
again search for 2nd, 3rd and more products add information to the table. my add row function is

function addRow(tableId) {
var table = document.getElementById(tableId);
var rowCount = table.rows.length;
var newRow = table.insertRow(rowCount);
var indexValue = rowCount - 1;

var cell1 = newRow.insertCell(0);
var element1 = document.createElement("input");
element1.type = "text";
element1.name = "lineItem[" + indexValue + "].lineNumber";
element1.value = rowCount;
cell1.appendChild(element1);

var cell2 = newRow.insertCell(1);
var element2 = document.createElement("input");
element2.type = "text";
element2.name = "lineItem[" + indexValue + "].id";
element2.value = document.getElementById('pname').value;
cell2.appendChild(element2);

var cell3 = newRow.insertCell(2);
var element3 = document.createElement("input");
element3.type = "text";
element3.name = "lineItem[" + indexValue + "].description";
element3.value = document.getElementById('pdescription').value;
cell3.appendChild(element3);

var cell4 = newRow.insertCell(3);
var element4 = document.createElement("input");
element4.type = "text";
element4.name = "lineItem[" + indexValue + "].quantity";
element4.value = document.getElementById('pquantity').value;
cell4.appendChild(element4);

var cell5 = newRow.insertCell(4);
var element5 = document.createElement("input");
element5.type = "text";
element5.name = "lineItem[" + indexValue + "].remarks";
element5.value = document.getElementById('premarks').value;
cell5.appendChild(element5);

var cell6 = newRow.insertCell(5);
var element6 = document.createElement("input");
element6.type = "checkbox";
element6.name = "lineItem[" + indexValue + "].chkbox";
cell6.appendChild(element6);
document.getElementById('submitButton').disabled = false;
}

<table id="dataTable" border="2" >
<thead>
<tr>
<td><bean:message key="label.line" /></td>
<td><bean:message key="label.name" /></td>
<td><bean:message key="label.description" /></td>
<td><bean:message key="label.quantity" /></td>
<td><bean:message key="label.remarks" /></td>
<td><bean:message key="label.delete" /></td>
</tr>
</thead>
<tbody>

</tbody>
</table>
<html:submit styleId="submitButton" property="goto" value="save" disabled="true" />

by clicking "save" button i want to get all rows in action class for further processing.
my problem is that how to get all rows in action class?
 
Atif Jamil
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also check my addNewRow() method is right or not?
i means i used input field name is right or wrong?
 
Atif Jamil
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i saw the example by "Brent Sterling", user of this forum. link to Brent Sterling example
he used indexed properties but he pre populate the table on jsp page with some rows.
my form is blank on load. i search the product then add it to the table.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic