Hello

Have recently started using woody+hibernate+flow and absolutely love it.
One thing I don't like however is how items in a repeater-widget is
removed. I've made a small change to my woody.js and wondered if you're
interested. I'll supply a patch if you are (although I might need some
pointers on how to do that since it would be the first time).

The problem was that I wanted to create forms that looked like this:

Name  Age
-------------------
Name1   1  [Remove]
Name2   2  [Remove]
Name3   3  [Remove]
-------------------
[Add name]

This is different to the woody-samples where there is a boolean field
called select on every row and one button that removes all selected.

To be able to do this I needed access to the ActionEvent that is created
when a button is pressed. What I did in woody.js was to add a function
Form.getAction() and edited some of Form.show().

The benefit is that I can now write a formhandler like this:

function formHandler(form) {
    var model = form.getModel();
    switch(form.getSubmitId()) {
    case "remove-name": // NB. singular not plural
        {
            var i = form.getAction().getSource().getParent().getId();
            model.names.remove(i);
        }
        break;
    case "add-name":
        {
            model.names.length++;
        }
        break;
    default:
        return true;
    }
    return false;
}

Cheers

// Jonas


Reply via email to