Hi all,
I have a page with an AjaxLink which shows a modal window. This modal window
contains a form and when we submit the form, modal window disappear, my page
is reloaded and a second ajaxLink is created. When we click on this second
ajaxLink, another modal window appears.
This part works well, but now, I want that the second modal window appears
after submitting the first form (and so without clicking on the second ajax
Link).
I try this on my form onSubmit method :
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
//[...] some form processing
membreCourant = serviceMembre.enregistrerReponses(membreCourant,
questionnaireCourant);
SessionE4N.get().setMembre(membreCourant);
//reload the page, so first modal window disappears and second ajax link
is created
setResponsePage(QuestionnairesPage.class, new PageParameters("p=3"));
//on affiche le module correspondant au questionnaire qu'on vient de
remplir
qPage.getModuleContentPanel().initialiserModule(questionnaireCourant);
qPage.getModalModule().setTitle("Module
"+questionnaireCourant.getTitre());
qPage.getModalModule().show(target);
}
qPage is initialize on modal window constructor:
public QuestionnaireContentPanel(String id, QuestionnairesPage
questionnairesPage){
super(id);
this.qPage = questionnairesPage;
Form<Void> qForm = creationFormulaireQuestionnaire();
add(qForm);
}
but it doesn't work : second modal window is not shown.
What am I doing wrong?
This code in my page creates modal windows :
modalQuestionnaire = new ModalWindowE4N("modalQuestionnaire",
"");
questionnaireContentPanel = new
QuestionnaireContentPanel(modalQuestionnaire.getContentId(), this);
modalQuestionnaire.setContent(questionnaireContentPanel);
modalQuestionnaire.setInitialWidth(800);
add(modalQuestionnaire);
modalModule = new ModalWindowE4N("modalModule", "");
moduleContentPanel = new
ModuleContentPanel(modalModule.getContentId());
modalModule.setContent(moduleContentPanel);
modalModule.setInitialWidth(800);
add(modalModule);
this code create ajaxLink for second modal windows (code for first modal
window is similar):
//Repeatingview pour la liste des modules
RepeatingView listeModules = new RepeatingView("listeModule");
add(listeModules);
List<ListeQuestionnaire> questionnaires =
membre.getListeQuestionnaires();
for (ListeQuestionnaire questionnaire : questionnaires) {
WebMarkupContainer item = new
WebMarkupContainer(listeModules.newChildId());
listeModules.add(item);
Questionnaire q = questionnaire.getQuestionnaire();
item.add(new Label("titreModule", "Module
"+q.getTitre()));
item.add(new BoutonVisualiserModule("boutonModule", new
Model<Questionnaire>(q)));
}
and BoutonVisualiserModule :
class BoutonVisualiserModule extends Panel
{
public BoutonVisualiserModule(String id, IModel<?> model) {
super(id, model);
//Ajout du lien qui affichera le module
AjaxLink<Void> showModule = new AjaxLink<Void>("visualiser") {
@Override
public void onClick(AjaxRequestTarget target) {
qCourant =
(Questionnaire)getParent().getDefaultModelObject();
target.appendJavascript("Wicket.Window.unloadConfirmation = false;");
moduleContentPanel.initialiserModule(qCourant);
modalModule.setTitle("Module "+qCourant.getTitre());
modalModule.show(target);
}
};
add(showModule);
}
}
--
*Mathilde Pellerin*
Ingénieur en développement de logiciel
STATLIFE
tel : 01.42.11.64.88
mail : [email protected]