saving worksheet rows

35 views
Skip to first unread message

Massimiliano Del Matto

unread,
Sep 2, 2011, 6:23:24 AM9/2/11
to JMesa
Hi Jeff, hi all.

In my previous topic I wanted to add a custom row to a worksheet.
This was because of I want to add such row by some input fields in the
form containing the jMesa table.

So, once added the new row to the worksheet and viewing it on the
table, it would be desiderable the row not to be editable, wouldn't
it? Well, this isn't a problem: one can set every column not editable
by HtmlColumn.setEditable(Boolean)...

The problem is when one wants to save the brand new rows in the
worksheet: if a column isn't editable, then the corresponding
WorkSheetColumn has no property, no changedValue, no originalValue...
nothing!
Just like as the brand new record doesn't exists in the worksheet.

Is it a bug or there's a reason for such behaviour?

Thank you. Best regards,
Massimiliano

Jeff Johnston

unread,
Sep 2, 2011, 11:38:26 AM9/2/11
to jm...@googlegroups.com
Its a good question. I cannot remember why this was not supported. I seem to remember the topic coming up though. It is clear in the Worksheet.addRow() method that if the column is not editable that the value does not get put into the worksheet. And if I work it through in my head I believe you would see the value as read-only the first time, but then you would lose it if the page was refreshed (or went to a different page (of the table) and came back).

I was going to say that there would not be a quick fix for this, but I wonder if you could create your own WorksheetEditor and just have it return the value. So you would not apply the worksheet style and not put in the JavaScript.

Take a look at the HtmlWorksheetEditor. What you could do is extend that and override the getWsColumn() method, with the style and JavaScript stripped out. The just plug it into the HtmlColumn.setWorksheetEditor() method. Also be sure to make the column editable, even though your editor will not make that so.


-Jeff Johnston




--
You received this message because you are subscribed to the Google Groups "JMesa" group.
To post to this group, send email to jm...@googlegroups.com.
To unsubscribe from this group, send email to jmesa+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jmesa?hl=en.


Massimiliano Del Matto

unread,
Sep 19, 2011, 1:38:03 PM9/19/11
to JMesa
Yes, creating an empty custom HtmlWorksheetEditor (getValue just
returns the value of the underlying CellEditor, no style and no js is
applied) worked fine, thanks.

On 2 Set, 17:38, Jeff Johnston <jeff.johnston...@gmail.com> wrote:
> Its a good question. I cannot remember why this was not supported. I seem to
> remember the topic coming up though. It is clear in the Worksheet.addRow()
> method that if the column is not editable that the value does not get put
> into the worksheet. And if I work it through in my head I believe you would
> see the value as read-only the first time, but then you would lose it if the
> page was refreshed (or went to a different page (of the table) and came
> back).
>
> I was going to say that there would not be a quick fix for this, but I
> wonder if you could create your own WorksheetEditor and just have it return
> the value. So you would not apply the worksheet style and not put in the
> JavaScript.
>
> Take a look at the HtmlWorksheetEditor. What you could do is extend that and
> override the getWsColumn() method, with the style and JavaScript stripped
> out. The just plug it into the HtmlColumn.setWorksheetEditor() method. Also
> be sure to make the column editable, even though your editor will not make
> that so.
>
> -Jeff Johnston
>
> On Fri, Sep 2, 2011 at 5:23 AM, Massimiliano Del Matto
> <maxdu...@gmail.com>wrote:

Jeff Johnston

unread,
Sep 19, 2011, 2:03:54 PM9/19/11
to jm...@googlegroups.com
I am going to add this into the distribution because to do anything else would be working against how that part of the API works!

Can you post your example in the meantime?


-Jeff
Message has been deleted

Massimiliano Del Matto

unread,
Sep 20, 2011, 4:51:01 AM9/20/11
to JMesa
On 19 Set, 20:03, Jeff Johnston <jeff.johnston...@gmail.com> wrote:

> I am going to add this into the distribution because to do anything else
> would be working against how that part of the API works!

> Can you post your example in the meantime?

> -Jeff

For sure!

Here is the class:

import org.jmesa.worksheet.editor.AbstractWorksheetEditor;

public class CustomHtmlWorksheetRenderer extends
AbstractWorksheetEditor {

/**
* Return just the value of the underlying CellEditor.
*/
public Object getValue(Object item, String property, int
rowcount) {

Object value = null;
value = getValueForWorksheet(item, property,
rowcount);
return value;
}

}

Here are the columns:

// don't set explicitly the column not editable
HtmlColumn notEditable = new HtmlColumn("someProperty");
notEditable.setTitle("Not Editable");
notEditable.setWorksheetEditor(new CustomHtmlWorksheetRenderer());
htmlRow.addColumn(notEditable);

// in the row there can be editable columns too
HtmlColumn editable = new HtmlColumn("someOtherProperty");
editable.setTitle("Editable");
htmlRow.addColumn(editable);
Reply all
Reply to author
Forward
0 new messages