• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 1.3

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic