You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Felix Japs <fe...@gmx.de> on 2005/10/05 12:05:09 UTC

JavaScript submit() valueChangeListener wrong Phase

Hi,

I use JavaScript to submit the form when a user clicks on a checkbox. The
checkbox fires a valueChangeEvent. I have implemented a valueChangeListener.
When the valueChangeListener is called the attributes which are bind to the
inputText Components have the old values. Probably because the Update Model
Values Phase was called not yet. How can I jump to the right Phase to get
the new inserted attribute values?

Bye Felix


AW: JavaScript submit() valueChangeListener wrong Phase

Posted by Felix Japs <fe...@gmx.de>.
> could you please post some code snippets?? 
> ValueChangeListener/JSP/JSF/JS for form submit...
> 

I've found a solution:

HtmlSelectBooleanCheckbox booleanEingabe = (HtmlSelectBooleanCheckbox)
application.createComponent(HtmlSelectBooleanCheckbox.COMPONENT_TYPE);
booleanEingabe.setOnclick("if(document.forms['modelForm'].onsubmit){document
.forms['modelForm'].onsubmit();}document.forms['modelForm'].submit();");
Class[] argTypesDA = {javax.faces.event.ValueChangeEvent.class};
String methodBindingDisableAttribute = "#{modellerViewMB.disableAttribute}";
MethodBinding mbDisableAttribute =
FacesContext.getCurrentInstance().getApplication().createMethodBinding(metho
dBindingDisableAttribute, argTypesDA);
booleanEingabe.setValueChangeListener(mbDisableAttribute);



public void disableAttribute(ValueChangeEvent event) {
boolean value = (Boolean) event.getNewValue();
// jump to the right phase
if (event.getPhaseId().equals(PhaseId.ANY_PHASE)) {
    ValueChangeEvent vce = new ValueChangeEvent(event.getComponent(),
event.getOldValue(), event.getNewValue());
    vce.setPhaseId(PhaseId.INVOKE_APPLICATION);
    event.getComponent().queueEvent(vce);
} else {
	//my code...
    this.displayAttributes();
}
}


> > 
> > I use JavaScript to submit the form when a user clicks on a 
> checkbox. 
> > The checkbox fires a valueChangeEvent. I have implemented a 
> > valueChangeListener.
> > When the valueChangeListener is called the attributes which 
> are bind 
> > to the inputText Components have the old values. Probably 
> because the 
> > Update Model Values Phase was called not yet. How can I jump to the 
> > right Phase to get the new inserted attribute values?
> > 
> > Bye Felix
> > 
> 
> --
> Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
> Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner
> 


Re: JavaScript submit() valueChangeListener wrong Phase

Posted by Christian Froelich <C....@gmx.de>.

> --- Ursprüngliche Nachricht ---
Hi,

could you please post some code snippets?? 
ValueChangeListener/JSP/JSF/JS for form submit...

Regards,

Christian

> Von: "Felix Japs" <fe...@gmx.de>
> An: "'MyFaces Discussion'" <us...@myfaces.apache.org>
> Betreff: JavaScript submit() valueChangeListener wrong Phase
> Datum: Wed, 5 Oct 2005 12:05:09 +0200
> 
> Hi,
> 
> I use JavaScript to submit the form when a user clicks on a checkbox. The
> checkbox fires a valueChangeEvent. I have implemented a
> valueChangeListener.
> When the valueChangeListener is called the attributes which are bind to
> the
> inputText Components have the old values. Probably because the Update
> Model
> Values Phase was called not yet. How can I jump to the right Phase to get
> the new inserted attribute values?
> 
> Bye Felix
> 

-- 
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner