Worksheet visuals (i.e. italics and underline)

49 views
Skip to first unread message

Lorie

unread,
Mar 25, 2012, 10:04:13 PM3/25/12
to jmesa_forum
Hello,
I am using a Jmesa table with a worksheet, everything is working
wonderfully. I do have a question though about the state of the table
after the save button is clicked. After I edit a column, it turn to
italics and is underlined in blue. I would expect this to be removed
after the save button is clicked but it is not removed until I log out
of my application and re enter the app and return to the table. Is
this normal behavior? Is there a way I can make the italics and
underlining go away after the save button is clicked?

Thanks,
Lorie

Jeff Johnston

unread,
Mar 26, 2012, 9:57:27 AM3/26/12
to jmesa...@googlegroups.com
Do you use the worksheet.processRows() method to iterate over the worksheet and get the values? If so then it will remove the rows for you as you save things.

-Jeff Johnston

Lorie

unread,
Mar 26, 2012, 1:46:13 PM3/26/12
to jmesa_forum
No I do not use the processRows, I have a saveWorksheetChanges method,
and I have a for loop to go over the WorksheetRows.

Jeff Johnston

unread,
Mar 26, 2012, 3:18:27 PM3/26/12
to jmesa...@googlegroups.com
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/jmesa/worksheet/Worksheet.java


-Jeff

Lorie

unread,
Mar 27, 2012, 12:57:55 AM3/27/12
to jmesa_forum
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...

Jeff Johnston

unread,
Mar 27, 2012, 9:54:56 AM3/27/12
to jmesa...@googlegroups.com
Use the  tableModel.setItems(AllItems) method. You would use the AllItems if you need to delay calculating the items until some other action, such as saving to a worksheet.

The nice thing about the TableModel is you just need to use the correct (callback) method and then the order that you call things does not matter. That was the main problem with the TableFacade...you had to know which order to call things and it was difficult to get right.

-Jeff
Message has been deleted

Lorie

unread,
Mar 27, 2012, 10:07:09 AM3/27/12
to jmesa...@googlegroups.com
I see how to use it in an example... trying it out now.. Thanks!

On Tuesday, March 27, 2012 10:02:31 AM UTC-4, Lorie wrote:
So use the allItems instead of the way I am setting the items now?  Inside my execute method?
I'm not sure how to use this method, but I will  research.

Jeff Johnston

unread,
Mar 27, 2012, 4:03:21 PM3/27/12
to jmesa...@googlegroups.com
Yep, it is just a simple callback method so that I can control when the items are fetched (after the worksheet save).

-Jeff

Lorie

unread,
Mar 27, 2012, 10:23:38 PM3/27/12
to jmesa...@googlegroups.com
Thanks so much for your speedy replies. I've got everything working beautifuly and its so exciting :)
Reply all
Reply to author
Forward
0 new messages