action info

3 views
Skip to first unread message

Peter van der Winkel

unread,
Aug 10, 2009, 10:51:39 AM8/10/09
to javabu...@googlegroups.com
I got something like this:

- JButton(name=b1, onAction=myMethod, ...)

Is it possible to give some extra information to the specified onAction
method?

May be:

- JButton(name=b1, onAction=myMethod,
actionArguments="string1,string2" , ...)

and the Java method should be:

public void myMethod(Object[] arguments)


Jacek Furmankiewicz

unread,
Aug 10, 2009, 10:56:21 AM8/10/09
to JavaBuilders
Not at this point. The onAction (and other on* event listeners) were
more thought to be a signal/slot type approach, where you send a
"onAction" signal
and I try to find the slow it should go to, depending on method names
and signatures on the Java side.

But this has come up before, so it is probably a good enhancement. Pls
add an enhancement request for it.
However, I would only support hard-coded values, I don't want to get
into the complexity of passing expressions into the arguments.
Also, it would probably be in the event listener itself, since you can
pass multiple ones, e.g.:

JButton(onAction=[$confirm,save("Some hardcoded param"),cleanup])

On Aug 10, 10:51 am, Peter van der Winkel

Jason S

unread,
Aug 13, 2009, 10:45:04 AM8/13/09
to JavaBuilders
On Aug 10, 10:51 am, Peter van der Winkel
<peter.van.der.win...@gmail.com> wrote:
My take on this, is that if you're getting that complicated, you
should configure the JButton in Java rather than in yaml. It's really
very easy and this seems like unnecessary baggage to impose upon
JavaBuilders. You should either use a no-args method or a String equal
to a fixed action name, or program what you want yourself.

Something like the following would work:


class MyClass {

...

public void init() { // some initialization method where you setup
things
((JButton)buildResult.get("buttonName")).setAction(new
AbstractAction()
{
@Override public void actionPerformed(ActionEvent event) {
myMethod(33, "Napoleon");
}
}
);

public void myMethod(int n, String who)
{
....
}
}

Jacek Furmankiewicz

unread,
Aug 13, 2009, 11:31:44 AM8/13/09
to JavaBuilders
You have a valid point too. Either way, I was not planning to look
into this prior to 1.0.
Reply all
Reply to author
Forward
0 new messages