0
votes

I have CellTable with password as one column. I want the password column to be editable.

My code is something like follows

public class EditPasswordTextCell extends EditTextCell {


    @Override
    protected void edit(Context context, Element parent, String value) {
        setValue(context, parent, value);
        InputElement input = getInputElement(parent);
        input.setAttribute("type", "password"); //$NON-NLS-1$ //$NON-NLS-2$
        input.focus();
        input.select();
    }
}

This brings up a password box when clicking on the cell. But after finished editing and the value shown in the column is in plain text. Then i decided to override the renderer methods. But most of the methods in EditTextCell class are private, so i ended up overriding

@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
    value = "******"; //$NON-NLS-1$
    super.render(context, value, sb);
}

The above code works fine for first rendering and not for the subsequent.

Now the question arises, should i extend from EditTextCell or AbstractEditableCell?

1
Why do you have a password column at all, if you don't display any useful information in it? I think a better solution will be to put a button into that column (ActionCell), and show change password dialog/page onclick.jusio
I will have 40 to 50 rows in the table, it would be annoying if i need open a popup for the password in each row.Kanagaraj M

1 Answers

0
votes

Easy way

You can pass a SafeHtmlRenderer to the EditTextCell constructor. So that renderer could render the normal view instead of using its default template (normal <input>).

Maybe more formal

It seems your cell is different in view mode as in edit mode so a non-EditTextCell class seems appropiate. But anyway, the first way seems easier...