Remove Row Issue

14 views
Skip to first unread message

Sam Welter

unread,
Jun 27, 2012, 11:13:57 AM6/27/12
to jmesa...@googlegroups.com
Hi Jeff - I'm using a worksheet to give users the ability to delete items from the table. I added tableModel.setItems(AllItems) so that the set items would be calculated after the save. However, I have an issue - after the first row remove (delete) operation is committed by pressing "save changes", the row status continues to be "REMOVE" and the system continues to try to delete the row that no longer exists. Here is a code snippet:  
 
        uarTable.saveWorksheet(new WorksheetSaver() {
            public void saveWorksheet(final Worksheet worksheet) {
                worksheet.processRows(new WorksheetCallbackHandler() {
                    public void process(WorksheetRow worksheetRow) {
                        if (worksheetRow.getRowStatus().equals(WorksheetRowStatus.REMOVE)) {
                            String uarIdAsStr = worksheetRow.getUniqueProperty().getValue();
                            if (StringUtils.isNumeric(uarIdAsStr)) {
                                uarService.deleteUarById(Integer.parseInt(uarIdAsStr));
                            }
                        }
                    }
                });
            }
        });
        //etc... (call set items)
 
Is there a way to refresh the table and remove the row that keeps triggering the "delete" method?

Sam Welter

unread,
Jun 27, 2012, 11:26:51 AM6/27/12
to jmesa...@googlegroups.com
Another question: is there a way to combine PageItems and AllItems? I want paginated results, but I also want to set the table items after the worksheet save operation. How might I accomplish this?

 

Jeff Johnston

unread,
Jun 27, 2012, 11:50:28 AM6/27/12
to jmesa...@googlegroups.com
The worksheet.processRows() is a convenience method to remove the colum from the worksheet. Try stepping through the code or just do what that method is doing and see if you can see what it going on. It should work like you expect!

http://code.google.com/p/jmesa/source/browse/trunk/jmesa/src/org/jmesa/worksheet/Worksheet.java

You can use the PageItems and it will work the same. The idea is that if you use a callback then when the items are retrieved is done after the save. Both the AllItems and PageItems will work.

-Jeff

Sam Welter

unread,
Jun 27, 2012, 3:48:59 PM6/27/12
to jmesa...@googlegroups.com
It looks like one of the Jmesa query string parameters is not being removed. Here is the query string as I step through the code:
 
Click Remove Row:
Query String >>>> uarTable_p_=1&uarTable_mr_=15&uarTable_tr_=true&uarTable_rwr_=2536
 
Click Save Changes:
Query String >>>> uarTable_p_=1&uarTable_mr_=15&uarTable_tr_=true&uarTable_sw_=true&uarTable_rwr_=2536
 
Click Remove Row:
Query String >>>> uarTable_p_=1&uarTable_mr_=15&uarTable_tr_=true&uarTable_sw_=true&uarTable_rwr_=2511
(code falls into processRows(); executes service call that tries to delete record 2536)
 
Click Save Changes:
Query String >>>> uarTable_p_=1&uarTable_mr_=15&uarTable_tr_=true&uarTable_sw_=true&uarTable_rwr_=2511
 
Click Next Page:
Query String >>>> uarTable_p_=2&uarTable_mr_=15&uarTable_tr_=true&uarTable_sw_=true&uarTable_rwr_=2511
(code falls into processRows(); executes service call that tries to delete record 2511)
 
The parameters "uarTable_sw_" and "uarTable_rwr_" are not being removed after the Save Changes button is clicked. So every action results in an attempt to delete the record, even though it has already been deleted.

Jeff Johnston

unread,
Jun 27, 2012, 4:29:09 PM6/27/12
to jmesa...@googlegroups.com
What does your onInvokeAction() look like?

Sam Welter

unread,
Jun 27, 2012, 4:42:04 PM6/27/12
to jmesa...@googlegroups.com
    function onInvokeAction(id, action) {
        setExportToLimit(id, '');   // only needed if table can be exported
        if (id == 'uarTable') {
            jmesaArgument = ['uarTable'];
        }
        var sUrl = '${pageContext.request.contextPath}/app/uarSearchJmesaEvent/' + document.getElementById("uarStatusId").value;
        YAHOO.util.Connect.asyncRequest('GET', sUrl + '?' + createParameterStringForLimit(id), { success:jmesaSuccessHandler, failure:jmesaFailureHandler, argument: jmesaArgument });
    }

Jeff Johnston

unread,
Jun 27, 2012, 5:35:03 PM6/27/12
to jmesa...@googlegroups.com
The problem is the saving of the worksheet was not meant to be done as an ajax call. If you did a normal form submit the worksheet flags would be wiped out.

It is a bug though...something that I did not think about when I designed the feature.

What you could do is in the onInvokeAction() check the action param and if a save is being done just do a normal form submit (createHiddenInputFieldsForLimitAndSubmit()).

-Jeff

Sam Welter

unread,
Jun 27, 2012, 7:58:21 PM6/27/12
to jmesa...@googlegroups.com
Rats! The need for this is all over my system. I'll have to figure out some kind of work-around.
 
YUI can set the ajax call to POST the form, but it looks like Jmesa interally handles it the same way as a GET.
 
Thanks for the information.
 
-Sam
Reply all
Reply to author
Forward
0 new messages