voyent
How to: 2 SelectOneMenu  XML
Forum Index -> General Help
Author Message
netdaviso

Joined: 05/Oct/2007 00:00:00
Messages: 85
Offline


Hi.
I have 2 SelectOneMenu in my jspx page.

I have 2 Changed method to make my logic. They are related

public void selectOneMenu_01Changed(ValueChangeEvent event);
public void selectOneMenu_02Changed(ValueChangeEvent event);


If I pick an element in selectOneMenu_01, it fired selectOneMenu_01Changed and later selectOneMenu_02Changed, in that order. (In this case no problem)

If I pick an element in selectOneMenu_02, it fired selectOneMenu_01Changed and later selectOneMenu_02Changed, in that order. (In the same order)

My question:
┬┐How can I know, being in one of this method (01 or 02) what element has been selected in the page because always they are fired in the same order you have defined in the .jspx page?

Any suggestions?
Thanks
praveen_el

Joined: 07/Apr/2008 00:00:00
Messages: 11
Offline


I think if you configure correctly only one value change method should be called depending on which select menu you have clicked.
netdaviso

Joined: 05/Oct/2007 00:00:00
Messages: 85
Offline


Hi.

you mean to configure or make the logic in one of them, for instance in 01??

if so, that was an option at the beginning because all the method are called the first time. Later the event are fired corectly and just the method of the selected component in the page.

So the problem is the first time...

I'll try to attach an simple standalone project....

thanks
netdaviso

Joined: 05/Oct/2007 00:00:00
Messages: 85
Offline


Hi.

I have attached (tomcat 6.0) a very simple example to show the behavior of this stuff.

I you take a look, always the 01Method is called before 02Method the first, no matter you choose the 01 or 02 in the .jspx page.

So, being in the method, there is no posibility to know which element is selected in the page..


Any comments?

Thanks in advance

 Filename events.war [Disk] Download
 Description 1.8 DR1 eclipse 3.3 tomcat 6.0.x
 Filesize 6063 Kbytes
 Downloaded:  126 time(s)

mark.collette


Joined: 07/Feb/2005 00:00:00
Messages: 1692
Offline


Most likely, the value actually changed in both. They are called in that sequence, because the code simply iterates over the component tree, processing each one in turn.
[Email]
netdaviso

Joined: 05/Oct/2007 00:00:00
Messages: 85
Offline


Hi.

So, is there a way to put a flag or something to avoid to run the code in a method not needed...

Something like:


method_01 {

if I need to run the method_02 from jspx, avoid to run the rest of the code in method_01
....
}

method_02 {

if I run to run the method_01 from jspx, avoid to run the rest of the code in method_02

.....

}

thanks
StormTAG

Joined: 30/Sep/2008 00:00:00
Messages: 15
Offline


You could set them both to partialSubmit="true" and handle them as they happen, rather than waiting for a full-form submit.

Other than that, you can use one ValueChangeListener for both and use logic to determine which you're dealing with and whether or not you need to keep dealing with them (you can use the e.getComponent() to determine which is which)...
netdaviso

Joined: 05/Oct/2007 00:00:00
Messages: 85
Offline


Hi, Storm

thanks for comments

1.- You could set them both to partialSubmit="true" and handle them as they happen, rather than waiting for a full-form submit.

I can't do it with partialsubmit because I have more components. The code was just a simplified example.

2.-...ValueChangeListener for both and use logic to determine which you're dealing with..

That exactly what I need.

I'll try your comments.

Thanks a lot.
incarnate

Joined: 31/Aug/2008 00:00:00
Messages: 43
Offline


netdaviso wrote:

1.- You could set them both to partialSubmit="true" and handle them as they happen, rather than waiting for a full-form submit.

I can't do it with partialsubmit because I have more components. The code was just a simplified example.
 


Partial submit does not mean that only data related to one component is being submitted.
netdaviso

Joined: 05/Oct/2007 00:00:00
Messages: 85
Offline


thanks incarnate

I'll try yours.


Thanks
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team