Hi all,

I have a TableViewPage, which has a modal window and the Ajax Link.

The modal window is used to edit item from DataView. 
How do i pass value of the selected item from DataView to the modal window?

Anyone can help me? 
Thanks for spending time to read my codes here. :)
I'm using wicket version 1.2.4

Below is my partial codes:

public class TableViewPage extends CommonPage{

public TableViewPage(){ 
        
        final ModalWindow templateModal;
        add(templateModal = new ModalWindow("templateModal"));
        
        templateModal.setPageMapName("templateModal");
        templateModal.setCookieName("templateModal");
        templateModal.setResizable(false);
        templateModal.setTitle("Edit Template");
        templateModal.setOutputMarkupId(true); 
        

        templateModal.setPageCreator(new ModalWindow.PageCreator()
        {
                public Page createPage()
                {       
                        return new TemplateModalPage(TableViewPage.this, 
templateModal);
                }
        });


        dataView = new DataView("table", dataProvider)
                {       
                        
                        private static final long serialVersionUID = 1L;

                        @Override
                        protected void populateItem(final Item item) {
                                item.add(new AjaxLink("showTemplateLink", 
item.getModel())
                                {
                                        public void onClick(AjaxRequestTarget 
target)
                                        {       
                                                Notification obj = 
(Notification)getParent().getModelObject();
                                                // here i would like to pass 
the obj value to modal window, how do i
achieve this?
                                                templateModal.show(target);
                                                                                
                
                                        }
                                });
                        }
                }
        dataView.setOutputMarkupId(true); 
        add(dataView);  
        }
}

this is my partial codes of TemplateModalPage:

public class TemplateModalPage extends WebPage{

        public TemplateModalPage(TableViewPage tableViewPage, ModalWindow
templateModal){
                add(new TemplateForm("templateForm", tableViewPage));
        }

        private class EmailTemplateForm extends Form{
                private AjaxSubmitButton submitButton;
                private AjaxSubmitButton cancelButton;
                private TextField templateTextField;

                public EmailTemplateForm(String id, final TableViewPage 
tableViewPage) {
                        super(id);
                        
                        CompoundPropertyModel model = new 
CompoundPropertyModel(this);
                        setModel(model);
                                                
                        templateTextField = new TextField("template");
                        add(templateTextField);

                       //here i suppose to get the templateId (from
DataView) before i update the latest changes to the table...

                        submitButton = new AjaxSubmitButton("submitButton", 
this){
                                @Override
                                protected void onSubmit(AjaxRequestTarget 
target, Form form) {

                                        try {
                                                
TemplateManager.getInstance().updateTemplate(persistence, aTransient);
                                                
                                        } catch (Exception e) {
                                                
                                                e.printStackTrace();
                                                error(e.getMessage());
                                        }
                                        ModalWindow.close(target);
                                }
                        }
                        add(submitButton);
                }
        }
}

Thanks.

-- 
View this message in context: 
http://www.nabble.com/Pass-value-of-the-selected-item-from-DataView-to-the-modal-window-tf4072118.html#a11572811
Sent from the Wicket - User mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to