aspose file tools*
The moose likes Struts and the fly likes Struts 1.3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1.3 " Watch "Struts 1.3 " New topic
Author

Struts 1.3

Atif Jamil
Greenhorn

Joined: Aug 11, 2013
Posts: 5
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

Joined: May 26, 2003
Posts: 30758
    
156

You want to dynamically populate with what data? If they are new, wouldn't they be blank?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Atif Jamil
Greenhorn

Joined: Aug 11, 2013
Posts: 5
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

Joined: May 26, 2003
Posts: 30758
    
156

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

Joined: Aug 11, 2013
Posts: 5
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

Joined: Aug 11, 2013
Posts: 5
also check my addNewRow() method is right or not?
i means i used input field name is right or wrong?
Atif Jamil
Greenhorn

Joined: Aug 11, 2013
Posts: 5
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
 
subject: Struts 1.3