You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Eric Lemaitre <er...@gmail.com> on 2008/12/02 00:02:47 UTC

Wait confirmation from ModalWindow

Hi all,

I have a confirmation ModalWindow (I expect "yes" or "no") which opens above
another ModalWindow which allows to update a TextArea and a List which feed
a DropDownBox :

final ConfirmationModel confirmationModel = new ConfirmationModel(this);
final DialogWindow confirmPanel = new DialogWindow("confirmPanel",
confirmationModel);
add(confirmPanel);

public class ConfirmationModel extends Observable implements Serializable
.......

// Confirm to Add something
AjaxLink add = new AjaxLink(ADD_COMMAND)
{
    @Override
    public void onClick(AjaxRequestTarget target)
    {
        confirmPanel.setTitle(getString("confirm"));
        confirmPanel.setContent(new DialogPanel(confirmPanel,
parmeters));
        confirmationModel.setCommand(ADD_COMMAND);
        confirmPanel.show(target);

// 1st OPTION: I WOULD LIKE TO BE KEPT WAITING HERE UNTIL CONFIRMATION
OCCURS FROM confirmPanel

// Here below Add command dynamically updates TextArea and List
(session.getUserNotesList()) which feed a DropDownBox (notes)

        target.addComponent(notesForm.get("textArea"));
        // VITAL for the DropDownList to refresh its inner list when an item
is removed
        target.addComponent(form.get("notes"));
        String id = myNotesChapter + "_" +
(session.getUserNotesList().size() + 1);
        Note noteModel = (Note)form.getModelObject();
        Note note = new Note(id, (Person)(session.getUser()),
textArea.getContent());
        session.getUserNotesList().add(note);
        dao.addNoteToUser(session.getUser().getLogin(), note);
        textArea.setModelValue(new String[1]);

................................................................

       public void update(Observable observable, Object object)
       {
           String command = ((ConfirmationModel)observable).getCommand();
           String result = object.toString();
           AjaxRequestTarget target = new AjaxRequestTarget(getPage());


           if(command.equals(ADD_COMMAND))
           {
// 2nd OPTION: REPORT THE DYNAMICAL UPDATES WITH AjaxRequestTarget HERE
               ...........................
_______________________________________________________________________

So with 1st option I cannot block smartly the confirmation confirmPanel
until I get "yes" or "no" just after line: confirmPanel.show(target);

And with 2nd option where I try to deport dynamical updates inside the
update() method of Observer/Observable all works fine BUT the elements don't
refresh properly, I have to close then open again the ModalWindow with its
DropDownList and TextArea to check updates happened.

Is there either a way to block the confirmation ModalWindow until answer
comes, or to make the refresh in deported update() work properly?

TIA, best regards.

-- 
Eric Lemaitre
CNAM IT Engineer, MS/CS

SCJA, SCJP, SCJD, SCWCD, SCBCD, SCEA, Net+, RHCE, RHCX

Senior Java Developer
__________________