I have a processRows handler now, but I now have the problem of the
table refreshes with the original data. After I go to a different page
and then back to the table it has the correct data. Here is my
handler: I removed some of the processing of columns, but I process
the other columns the same as the "maxCapacity" one below. I will
also include my execute method. So after I make my edits to my
table, I click save and then the cells repopulate with the original
data, until i leave the page and return.
protected void saveWorksheetChanges(Worksheet worksheet){
Collection<WorksheetRow> rows = worksheet.getRows();
ids = new ArrayList();
errorMsg="";
worksheet.processRows(new WorksheetCallbackHandler() {
public void process(WorksheetRow worksheetRow) {
int laneId;
ids.add(worksheetRow.getUniqueProperty().getValue().toString());
if
(worksheetRow.getRowStatus().equals(WorksheetRowStatus.MODIFY) )
//get all the lane ids
{
laneId =
Integer.valueOf(worksheetRow.getUniqueProperty().getValue().toString()).intValue();
Collection<WorksheetColumn> columns =
worksheetRow.getColumns();
// Find the entry with this lane id
LaneCarrierResponseComboDTO entry =
findEntry(entries, laneId);
CarrierResponse intermodalResponse = new
CarrierResponse();
if(entry != null) {
if
(worksheetRow.getColumn("maxCapacity")!=null){
String maxCapacity =
worksheetRow.getColumn("maxCapacity").getChangedValue();
entry.carrierResponse.setMaxCapacity(maxCapacity.length() > 0 && !
maxCapacity.equals("-1") ? Integer.decode(maxCapacity.replaceAll(",",
"")) * 52 : 0);
}
}}} } );}
public String execute() {
if(id == 0) {
return "error";
}
request =
(HttpServletRequest)ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);
TableModel tableModel = new TableModel("projects_ids", request);
tableModel.setMaxRows(20);
tableModel.setMaxRowsIncrements(20);
tableModel.setToolbar(new CustomToolbar());
//if master lock
tableModel.saveWorksheet( new WorksheetSaver() {
public void saveWorksheet(Worksheet worksheet) {
saveWorksheetChanges(worksheet);
}
});
tableModel.setItems(getLaneData());
if (this.isProjectBidding()){
tableModel.setEditable(true);
} else {
tableModel.setEditable(false);
}
tableModel.setTable(generateTable());
setTableData(tableModel.render());
return "success";
}
JSP Code
<form name="projectsForm" action="${pageContext.request.contextPath}/
carrier/bid-project-sheet">
<div id="projects">
<input type="button" value="Save" class="btn" style="margin-top:10px"
onclick="javascript:jQuery.jmesa.setSaveToWorksheet('projects_ids');onInvokeAction('projects_ids','save_worksheet')" /
>
<input type="hidden" name="id" id="id" value="<%=
request.getParameter("id") %> "/>
<input type="hidden" name="unlocked" id="unlocked" value=" <%=
request.getParameter("unlocked") %>" />
${tableData}
<input type="button" value="Save" class="btn" style="margin-top:10px"
onclick="javascript:jQuery.jmesa.setSaveToWorksheet('projects_ids');onInvokeAction('projects_ids','save_worksheet')" /
>
</div>
</form>
<script type="text/javascript">
function onInvokeAction(id) {
$.jmesa.createHiddenInputFieldsForLimitAndSubmit(id);
}
</script>
On Mar 26, 3:18 pm, Jeff Johnston <
jeff.johnston...@gmail.com> wrote:
> Take a look at the worksheet.processRows() method. You should either call
> that, or do something similar to what it is doing.
>
>
http://code.google.com/p/jmesa/source/browse/trunk/jmesa/src/org/jmes...