Hi all,

I want to generate a Line chart (from Google Visualization API) when I
submit a form.
To do that, I used getAjaxCallDecorator like this :

        AjaxButton submit = new AjaxButton("submit") {
            private int agePersonne;
            private double risque;

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
                agePersonne = age.getModelObject();

                //Récupération du risque via le DAO auquel on passe les
valeurs du formulaire
                //les valeurs doivent donc avoir été validées avant
                risque = risqueDao.getOneByProfil(agePersonne,
agePremieresRegles.getModelObject(),
                        nbParentsAtteints.getModelObject(),
nbBiopsies.getModelObject(),
                        menopauseGroupe.getModelObject(),
ageMenopause.getModelObject(), statutTHS.getModelObject());

            }

            @Override
            protected void onError(AjaxRequestTarget target, Form<?> form) {
                target.add(feedback);
            }

            @Override
            protected IAjaxCallDecorator getAjaxCallDecorator() {
                return new AjaxCallDecorator() {
                    public CharSequence decorateScript(Component c,
CharSequence script){
                        return JavascriptUtils.genererScriptLine("risque",
agePersonne, risque) + script;
                    }
                };
            }
        };
        form.add(submit);

With this code, the static method genererScriptLine() is called on page
loading, so agePersonne and risque are not initialized because they will be
calculated only on form submitting. So when I submit the form, chart is
displayed but not with good values for agePersonne and risque.

I don't understand how to use getAjaxCallDecorator with AjaxButton to be
sure that decorateScript will be called after submitting, and not on page
loading?
What am I doing wrong?

Mathilde

Reply via email to