Hi,

Could any one please help me fixing this panel refresh issue.
first time the panel is refreshed. and that too with (setResponsePage() as
workaround).
Afterwards it is not getting refreshed at all. Always retains the previous
value...

1.I have an Ajaxbutton, on click of it- opens a ModalWindow.
2, In the modal window I am selecting a contact id, and on window call back,
I am painting the panel with all the contact details (like email, phone,
fax...)
3. These fields are basically set of textfields in panel.

Please note first time when I select a id from my Modalwindow.. my panel is
refreshed with correct values..
and also I need to use setResponsePage().. otherwise it does not work..

But, if I try to select a different id for the second timefrom my
ModalWindow... my panel still has the old values.

Please help.

Thanks for your time.

The code is as below..

//ContactPanel.java

public class ContactPanel extends Panel {

        private static final long serialVersionUID = 1L;


        public ContactPanel(String id, IModel model) {
            super(id);           
            setDefaultModel(new CompoundPropertyModel(model));
            add(new
TextField("name").setConvertEmptyInputStringToNull(false));
            add(new
TextField("phone").setConvertEmptyInputStringToNull(false));
            add(new
TextField("email").setConvertEmptyInputStringToNull(false));
            add(new
TextField("fax").setConvertEmptyInputStringToNull(false));           
    }
        
}

//ContactPanel.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
    
<html xmlns="http://www.w3.org/1999/xhtml";
xmlns:wicket="http://wicket.sourceforge.net/"; xml:lang="en"     lang="en">      
        <body>  
                <wicket:panel>                            
                        <tr class="detailH15">
                <th align='right'>Contact:</th>
                <td  nowrap='nowrap'>
                  <input type='text' wicket:id="name"  size='15'
maxlength='40' />&nbsp;Phone:
                  <input type='text' wicket:id="phone" size='12'
maxlength='30'/>
                </td>
              </tr>
             <tr class="detailH15">
                <th  align='right'>Email:</th>          
                <td nowrap='nowrap'>
                  <input type='text' wicket:id="email"  size='20'
maxlength='50'/>
                  Fax 
                  <input type='text' wicket:id="fax" size='12'
maxlength='20' />             
                </td>
              </tr>                             
                </wicket:panel>
        </body>
</html>


//adding panel to a form

Panel contactPanel = new ContactPanel("contactPanel", new
LoadableDetachableModel(){
                        @Override
                        protected Object load() {
                                return 
extraChildrenMawbModel.getObject().getContact();
                        }
                });
                
                contactPanel .setOutputMarkupId(true);
                form.add(contactPanel );



//adding AJax Button to a form

 final IModel inputModel =new Model();
final IModel outputModel =new Model();
                
                 AjaxButton contactLookupBtn = new AjaxButton("contactLookup"){
                        private static final long serialVersionUID = 1L;
                        @Override
                        protected void onSubmit(AjaxRequestTarget target, Form 
arg1) {                          
                                inputModel.setObject("contact");                
                
                                contactLookup.show(target);                     
        
                        }
        };

form.add(contactLookupBtn .setDefaultFormProcessing(false)); 

//adding ModalWindow to the page

final ModalWindow contactLookup;
                add(contactLookup= new ModalWindow("contactLookupWindow"));
                
                contactLookup.setPageMapName("modal-1");

//Modalwindow callback code........
contactLookup.setWindowClosedCallback(new
ModalWindow.WindowClosedCallback(){
            public void onClose(AjaxRequestTarget target){              
          
                Object outputModelObj = outputModel.getObject();
                if (outputModelObj != null) {
                        final Contact contact =
contactDao.loadContact((Long)outputModelObj);                   
                        if (inputModel.getObject().equals("contact")) { 

                  final Panel newContactPanel = new
ContactPanel("contactPanel", new LoadableDetachableModel() {                    
                                        
                                                @Override
                                                protected Object load() {
                                                        // TODO Auto-generated 
method stub
                                                        return 
extraChildrenMawbModel.getObject().getContact();
                                                }
                                        });             
                                        
newContactPanel.setOutputMarkupId(true);                        
                                        
contactPanel.replaceWith(newContactPanel);
                                        contactPanel = newContactPanel; 
                           target.addComponent(newContactPanel);

                   setResponsePage(getPage())
target.addComponent(feedback)
}

//closeButtonCallback

 contactLookup.setCloseButtonCallback(new ModalWindow.CloseButtonCallback(){
            public boolean onCloseButtonClicked(AjaxRequestTarget target) {     
        
                target.addComponent(feedback);
                return true;
            }
        }); 
 

//adding panel to my parent html page...
My main html page as..  

<tr wicket:id="contactPanel"></tr> 

//adding lookup window to the page
<div wicket:id="contactLookupWindow"></div>     

Appreciate your help.
Jamuna  




-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Panel-not-getting-refreshed-when-posted-from-ModalWindow-tp2235350p2235350.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to