You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by ccp999 <cc...@hotmail.com> on 2012/07/05 08:43:27 UTC
Action.getNamedActions() cannot be updated with an new action
Hi,
I followed tutorial example to setup a menu bars. I put dummy action in the
constructor because I need to set a parameter after the initialization of
the screen objects. I set a function to replace the dummy action as:
Action.getNamedActions().put("xxx", new action (){
xxx
});
but the put function doesn't replace the dummy action, even I insert:
Action.getNamedActions().remove("xxx");
it doesn't help.
Did I miss anything? or it is a bug.
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Action-getNamedActions-cannot-be-updated-with-an-new-action-tp4021939.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Action.getNamedActions() cannot be updated with an new action
Posted by Sandro Martini <sa...@gmail.com>.
> Thanks all. I sorted out without to have a dummy one.
Good.
Anyway, inside MenuBarTest (under tests) you can find this (could be useful):
public void startup(Display display, Map<String, String>
properties) throws Exception {
...
// put this before loading the related bxml, or an
IllegalArgumentException will be thrown
Action.getNamedActions().put("about", new Action() {
@Override
public void perform(Component source) {
...
});
BXMLSerializer bxmlSerializer = new BXMLSerializer();
frame2 = (Frame)bxmlSerializer.readObject(MenuBarTest.class,
"menu_bar_test.bxml");
...
> But I'm still finding a bit to understanding why this is a standard behavior.
Me too (for some things ;-) ...).
The trick suggested by Roger is interesting, maybe we can verify if
something like this could be put somewhere in Pivot (maybe under
tests), just for reference ... Roger, what do you think ?
Bye
RE: Action.getNamedActions() cannot be updated with an new action
Posted by ccp999 <cc...@hotmail.com>.
Thanks all. I sorted out without to have a dummy one. But I'm still finding
a bit to understanding why this is a standard behavior.
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Action-getNamedActions-cannot-be-updated-with-an-new-action-tp4021939p4021955.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
RE: Action.getNamedActions() cannot be updated with an new action
Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
What I did, which I think would solve your problem without changing
Pivot, is to use a subclass of Action that I can pass parameters to.
Then my subclass of Action object can be instantiated right away, but
actual working of the action gets the parameter from wherever the
context is stored and passes that at the time the action is invoked.
I'm not explaining it very well, but my feeling is that you shouldn't
really have to make a dummy action and then replace it later. Just
instantiate the real action up front but have the "perform" method get
the context from somewhere so it can do the right thing depending on the
context (after your screen initialization is done).
In our application it is kind of complicated since our actions can be
invoked from several different places and the context has to be gotten
in various ways depending on how the action was invoked, but it is all
very doable without having to change the Action objects once they are
passed to the NamedActions dictionary.
HTH, but let us know if you still need help and I can try to explain
things better. Or perhaps you could post a little more detail on what
you need to achieve. Bottom line: I don't think you should have to
replace any Action objects to do what you need to do.
~Roger Whitcomb
-----Original Message-----
From: ccp999 [mailto:ccp999@hotmail.com]
Sent: Wednesday, July 04, 2012 11:43 PM
To: user@pivot.apache.org
Subject: Action.getNamedActions() cannot be updated with an new action
Hi,
I followed tutorial example to setup a menu bars. I put dummy action in
the
constructor because I need to set a parameter after the initialization
of
the screen objects. I set a function to replace the dummy action as:
Action.getNamedActions().put("xxx", new action (){
xxx
});
but the put function doesn't replace the dummy action, even I insert:
Action.getNamedActions().remove("xxx");
it doesn't help.
Did I miss anything? or it is a bug.
--
View this message in context:
http://apache-pivot-users.399431.n3.nabble.com/Action-getNamedActions-ca
nnot-be-updated-with-an-new-action-tp4021939.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Action.getNamedActions() cannot be updated with an new action
Posted by Sandro Martini <sa...@gmail.com>.
Hi, I found this behaviour some time ago, and I think should be by design
... so we should see what Greg say.
Under tests you can find some example for this with comments.
Now I'm in holidays so for a detailed answer/check on code you have to wait
the second half of next week.
For 2.1 we could even think to update this behaviour unless someone has
objections, but now I can't say more. If you want, make a jira issue in the
meantime.
Bye
Il giorno 05/lug/2012 08:44, "ccp999" <cc...@hotmail.com> ha scritto:
> Hi,
>
> I followed tutorial example to setup a menu bars. I put dummy action in
> the
> constructor because I need to set a parameter after the initialization of
> the screen objects. I set a function to replace the dummy action as:
>
> Action.getNamedActions().put("xxx", new action (){
> xxx
> });
>
> but the put function doesn't replace the dummy action, even I insert:
> Action.getNamedActions().remove("xxx");
>
> it doesn't help.
>
> Did I miss anything? or it is a bug.
>
>
>
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/Action-getNamedActions-cannot-be-updated-with-an-new-action-tp4021939.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>