voyent
simulate checking a checkbox  XML
Forum Index -> General Help
Author Message
akearns

Joined: 22/Nov/2006 00:00:00
Messages: 10
Offline



I would like to simulate the the user checking a checkbox if he changed another control in the same row or form.

I tried using the component showcase to determine what changes needed to be made.

In component showcase in the "Extended Components" Selection example
I tried to simply check the "New User" checkbox if the user changed their
car, drink or language.

I thought I could add: newUser=true

Code:
     public void effectChangeListener(ValueChangeEvent event){
         valueChangeEffect.setFired(false);
     	newUser = true;
     }
 


to the methods that handled the valueChangedListener the effectChangeListener in BaseBean.java

I moved the boolean newUser to the BaseBean for testing, I realize it does
not belong there.

This does not work, shouldn't it?
tyler.johnson


Joined: 18/Apr/2007 00:00:00
Messages: 93
Offline


Hi Arlene,

As a supported customer, please feel free to contact us directly at product.support@icesoft.com. This will ensure that appropriate service levels are met.

Thanks,

Tyler
Product Support
ICEsoft Technologies
StormTAG

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


akearns wrote:

I would like to simulate the the user checking a checkbox if he changed another control in the same row or form.

I tried using the component showcase to determine what changes needed to be made.

In component showcase in the "Extended Components" Selection example
I tried to simply check the "New User" checkbox if the user changed their
car, drink or language.

I thought I could add: newUser=true

Code:
     public void effectChangeListener(ValueChangeEvent event){
         valueChangeEffect.setFired(false);
     	newUser = true;
     }
 


to the methods that handled the valueChangedListener the effectChangeListener in BaseBean.java

I moved the boolean newUser to the BaseBean for testing, I realize it does
not belong there.

This does not work, shouldn't it?
 


Just in case Tyler hasn't sorted it out with Akearns yet, or someone else has a similar problem. This one's pretty simple, though some what annoying.

During the JSF lifecycle, ValueChangeListeners happen BEFORE the Values get updated from the model. What is happening is you are updating your value in the listener, then you're change is getting obliterated by the value from the model, which is false.

I had a similar issue where I had a tree with nested checkboxes which I wanted to cascade. Select at the bottom, and all the parents get checked. Deselect at the top, all the children get unchecked.

What I did was re-queue the event by using the following code:

Code:
 public void someChangeListener(ValueChangeEvent e) {
    if (e.getPhaseId().equals(PhaseId.UPDATE_MODEL_VALUES)) {
       doSomeStuff();
    } else {
       e.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
       e.queue();
    }
 }
 


This will make doSomeStuff() happen AFTER the UPDATE_MODEL_VALUES phase, which is where the values get pulled from the request.
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team