John, sorry for not being helpful. But I think that this kind of posts (this
is my code, why it doesn't work?) will not help you to find the problem. My
suggestion is, try to debug your code, and if you have a more specific
question, post it and somebody for sure will give you an answer. Otherwise,
everybody will just overlook your post. The most of developers are too lazy
to find what exactly is not right with your code.

Alex.




JohnSmith333 wrote:
> 
> The code bellow:
> import java.io.Serializable;
> import java.util.ArrayList;
> import java.util.List;
> import wicket.markup.html.*;
> import wicket.markup.html.basic.Label;
> import wicket.markup.html.form.Form;
> import wicket.markup.html.link.Link;
> import wicket.markup.html.list.ListItem;
> import wicket.markup.html.list.ListView;
> import wicket.markup.html.panel.FeedbackPanel;
> import wicket.markup.html.form.*;
> import wicket.model.*;
> 
> public class TestPage extends WebPage implements Serializable
> {
>       private static final long serialVersionUID = 1L;
>       
>       private List testList=new ArrayList();
> 
>       private ListView testListView;
> 
>       public TestPage()
>       {
> 
>               final FeedbackPanel testFeedback = new 
> FeedbackPanel("testFeedback");
>               add(testFeedback);
>               
>               WebMarkupContainer dataContainer = new 
> WebMarkupContainer("data");
>               dataContainer.setOutputMarkupId(true);
>               this.add(dataContainer);
>               
>               testListView = new ListView("testList", testList){
>                       private static final long serialVersionUID = 1L;
>                       
>                       protected void populateItem(ListItem listItem){
>                               final TestTO 
> to=(TestTO)listItem.getModelObject();
>                                                       
>                               listItem.add(new Label("file", 
> to.getFileInput()));
>                               
> System.out.println("to.getFileInput(0:"+to.getFileInput());
>                               listItem.add(new 
> Label("notes",to.getFileNotes()));             
>                               
>                               listItem.add(new Link("delete"){
>                                       public void onClick()
>                                       {
>                                               testList.remove(to);
> 
>                                       }
>                               });
>                       }                       
>               };
>               
>                dataContainer.add(testListView);
>               
> 
>                Form uploadForm = new Form("uploadform",new 
> CompoundPropertyModel(new
> TestTO())){
>                               private static final long serialVersionUID = 1L;
>                               
>                               protected void onSubmit(){
>                                       
>                                       TestTO to=(TestTO)getModelObject();
>                                       
>                                              System.out.println("****** 
> Input:"+to.getFileInput());
> 
>                               System.out.println("Now size 
> a:"+testList.size());
>                               if(testList.size()>0)
>                               {                                       
>                                        System.out.println("First
> value:"+((TestTO)testList.get(0)).getFileInput());
>                               }
>                               
>                                               testList.add(to);
>                                               
>                                                System.out.println("Now Size 
> b:"+testList.size());
>                                       
>                               }                        
>                };
>               
>                uploadForm.add(new TextArea("fileNotes"));
>                       
>                uploadForm.add(new TextField("fileInput"));
>               
>               add(uploadForm);
> 
>       }
> 
>       private class TestTO implements Serializable{
>                private static final long serialVersionUID = 1L;
>               
>                 private String fileID;
>                
>             private String fileNotes;
>             
>             private String fileInput;
>             
>            public TestTO(){}
>            
>               public String getFileID() {
>                       return fileID;
>               }
> 
>               public void setFileID(String fileID) {
>                       this.fileID = fileID;
>               }
> 
>               public String getFileNotes() {
>                       return fileNotes;
>               }
> 
>               public void setFileNotes(String fileNotes) {
>                       this.fileNotes = fileNotes;
>               }
> 
>               public String getFileInput() {
>                       return fileInput;
>               }
> 
>               public void setFileInput(String fileInput) {
>                       this.fileInput = fileInput;
>               }
>       }
>       
>       }
> 
> and the html code:
> <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml"; >
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
> <title></title>
> </head>
> <body>
> 
>     <form wicket:id="uploadform">
>     
>   <!--   [[ajax upload progressbar]] --> 
>     <table border="1">
>       <tr><td>
>           <label for="file">File</label>
>           </td>
>           <td>
>           <input type="text" wicket:id="fileInput" />
>          <!--  <input wicket:id="fileInput"  type="file" size="20"
> maxlength="20"/> --> 
>           </td></tr>
>           <tr><td>
>           <label for="note">Note</label>
>           </td>
>           <td>
>           <textarea wicket:id="fileNotes" cols="20" rows="5"></textarea>
>           <input type="submit" value="Submit"/>
>           </td></tr>
>           </table>
>     </form>
>        <div>
>                 
>        </div>
> 
>     <div>
> 
>       <table width="240" border="1" bordercolor="orange" wicket:id="data">
>         <tr>
>             <th width="100">File</th>
>             <th width="100">Notes</th>
>             <th width="50">Del</th>
>         </tr>
>         <tr wicket:id="testList">
>             <td wicket:id="file">(file)</td>
>             <td wicket:id="notes">(notes)</td>
>             <td>  img/delete.gif  </td>
>         </tr>
>       </table>
>     </div>
> </body>
> </html>
> 
> ******************* 
> when execute the code, the console show:
> ****** Input:1
> Now size a:0
> Now Size b:1
> to.getFileInput(0:1
> ****** Input:2
> Now size a:1
> First value:2
> Now Size b:2
> to.getFileInput(0:2
> to.getFileInput(0:2
> I first input 1 and then input 2 ,but the two value all become 2,why?
> Could anyone help me to solve this question?
>  http://www.nabble.com/file/p12569419/test2.jpg 
> 

-- 
View this message in context: 
http://www.nabble.com/Help-%21-CompoundPropertyMode-and-ArrayList-Question-tf4405830.html#a12570320
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to