In cases where I have used actions like this, I have generally created inner
classes that can see the WTKX-bound member variables of the outer class; e.g.:
public class MyWindow extends Window implements Bindable {
@WTKX private TextInput input;
public class MyAction extends Action {
@Override
public void perform() {
doSomething(input.getText());
}
}
}
On Mar 29, 2010, at 11:53 AM, Mike Smorul wrote:
> I'm wondering, what is the 'best' way to provide form data to an
> action. What I have been doing follows, first create an action class
> that gets its input from some components.
>
> public class MyAction extends Action
> {
> @WTKX private TextInput input
>
> @Override
> public void perform() {
> doSomething(input.getText());
> }
> }
>
> When the program starts, I'm left adding the actions, then after
> loading the wtkx file, then calling bind on my actions to load
> components.
>
> NamedActionDictionary nd = Action.getNamedActions();
> nd.put("myAction", new MyAction());
> ...
> ...
>
> WTKXSerializer wtkxSerializer = new WTKXSerializer();
> window = (Frame) wtkxSerializer.readObject(this, "mainWindow.wtkx");
> for (String act : Action.getNamedActions())
> {
> wtkxSerializer.bind(Action.getNamedActions().get(act));
> }
>
> Is there a better way?
>
> Thanks,
> -Mike