Dear all,

I use listView and RadioGroup, radio , as the following codes, Can someone
give me some idea? thanks in advance

everything is ok until i click the button "btnSaveAll", it throw the 
excepation:


2008-09-03 19:35:41,751 ERROR [org.apache.wicket.RequestCycle] - <Attempt to
set model object on null model of component:
tabpanel:panel:attachedFilesPanelContainer:saveUploadFilesForm:group>
java.lang.IllegalStateException: Attempt to set model object on null model
of component:
tabpanel:panel:attachedFilesPanelContainer:saveUploadFilesForm:group
        at org.apache.wicket.Component.setModelObject(Component.java:2820)
        at
org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:992)
        at
org.apache.wicket.markup.html.form.Form$14.validate(Form.java:1615)
        at
org.apache.wicket.markup.html.form.Form$ValidationVisitor.formComponent(Form.java:152)

java codes:

    private class SaveUploadFilesForm extends Form {

        private boolean photoMainStatus = false;

        
        public SaveUploadFilesForm(String id, final List<FileObj> files){
            super(id);
            //boolean photoMainStatus = false;
            
            final RadioGroup group = new RadioGroup("group");
            
            ListView fileListView = new ListView("fileList", files) {

                @Override
                protected void populateItem(final ListItem item) {
                    System.out.println("**********************in
AttachedFilesPanel() ");
                    item.size();
                    final FileObj fileObj = (FileObj) item.getModelObject();

                    System.out.println("fileObj.getId():" +
fileObj.getId());
                    System.out.println("fileObj.getOriginalFileName():" +
fileObj.getOriginalFileName());
                    System.out.println("fileObj.getDescription():" +
fileObj.getDescription());
                    System.out.println("fileObj.isMain():" +
fileObj.isMain());

                    item.add(new Label("file",
fileObj.getOriginalFileName()));
                    item.add(new Label("description",
fileObj.getDescription()));
                    item.add(new PictureUploadActionPanel("actions",
item.getModel(), files, page));

                    if (fileObj.isMain()) {
                        setPhotoMainStatus(true);
                    }
                    
                    Radio r = new Radio("radio", new
PropertyModel(getParent().getParent(), "photoMainStatus"));
                    
                    r.add(new AjaxEventBehavior("onchange") {

                        @Override
                        protected void onEvent(AjaxRequestTarget target) {
                            setPhotoMainStatus(true);                           
 
                            System.out.println("----------------in the
checkbox, onEvent,fileObj.getId()" + fileObj.getId());
                        }
                    });
                    item.add(r);                    
                    
                    item.add(new AttributeModifier("class", true, new
AbstractReadOnlyModel() {

                        @Override
                        public Object getObject() {
                            return ((item.getIndex() % 2) == 1) ? "even" :
"odd";
                        }
                    }));
                }
            };

            add(fileListView);
            AjaxButton btnSaveAllFiles = new AjaxButton("btnSaveAll") {

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form form)
{
                    System.out.println("********click button 'btnSaveAll'");
                    if (files.size() > 0) {
                        Iterator it = files.iterator();
                        while (it.hasNext()) {
                            FileObj fileObj = (FileObj) it.next();
  
                            }
                        }

      
                    }
                }
            };

            btnSaveAllFiles.setModel(new Model("Save All Files"));
            add(btnSaveAllFiles);
            
            group.add(fileListView);
            //group.add(btnSaveAllFiles);
            add(group);

        }
        
        public boolean getPhotoMainStatus() {
            return photoMainStatus;
        }

        public void setPhotoMainStatus(boolean photoMainStatus) {
            this.photoMainStatus = photoMainStatus;
        }

    }

Html codes:

                  <form wicket:id="saveUploadFilesForm">
                    
                    <table width="50%">
                        <table class="dataview">
                            <tr class="title">
                                <th>Actions</th>
                                <th>File Name</th>
                                <th>Description</th>
                                <th>Main status</th>
                            </tr>
                    
                            <tr wicket:id="fileList" class="row">
                                <td width="100">[Action]</td>
                                <td width="200">[File]</td>
                                <td>[Description]</td>
                                <td width="100">
                                    <input type="radio" wicket:id="radio"/>
                                </td>
                            </tr>
                    
                            <tr>
                                <td><input type="button"
wicket:id="btnSaveAll" class="button"/></td>
                            </tr-->
                        </table>
                            <tr><td>&nbsp;</td></tr>
                            <tr>
                                <td><input type="button"
wicket:id="btnSaveAll" class="button"/></td>
                            </tr>
                        
                    </table>
                </form>


-- 
View this message in context: 
http://www.nabble.com/using-listView%2Cradiogroup%2C-error%3Ajava.lang.IllegalStateException%3A-Attempt-to-set-model-object-on-null-model-of-component-tp19301538p19301538.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to