I want to nest list of answers in Data Table which already have data provider
.Below code  gives error
IColumn[] columns= { new PropertyColumn(new Model("ID"),"questiontext"),
        new AbstractColumn(new Model("Answer Body"))
        {
            public void populateItem(Item cell,String componentId,IModel
rowmodel)
            {
                MCSSQuestion q=(MCSSQuestion)rowmodel.getObject();
                List a=q.getMcssans();
                ListView view=new ListView("lists",a)
                {
                    protected void populateItem(ListItem item)
                    {
                        final MCSSAns ans=(MCSSAns)item.getModelObject();
                        
                        item.setModel(new CompoundPropertyModel(ans));
                        item.add(new Label("ansbody"));
                        
                    }
                };
               cell.add(view);
            }

igor.vaynberg wrote:
> 
> see ListDataProvider
> 
> -igor
> 
> On Feb 13, 2008 7:44 AM, wiki <[EMAIL PROTECTED]> wrote:
>>
>> Hi I have a little problem with displaying list inside datatable.
>> I have a list of questions and each question has a list of answers.My
>> design
>> requirement is to  display one question per page(that's why used Data
>> Provider) and within that page I have to display list of relevant
>> answers.I
>> have a java classes(User,Questionaire,Questions,Answers) User class has
>> List
>> of Questionaire and that(Questionaire) has list of questions Then
>> Question
>> class has a list of Answers.So from Lecturer  WebPage I can click a
>> questionaire link to go to questionaire Page which display list of
>> questionaire(using ListView).From questionaire I did manage to display
>> Questions.Could anybody   know how to embed list in Data Table to display
>> answers.
>>
>> Thanks
>>
>> public class ShowQuestions extends WebPage
>>
>> {
>>
>> //
>> //    /** Creates a new instance of ShowQuestions */
>> //        List questions=qaire.getMcssquestion();
>> //        ListView list=new ListView("questionaire",questions)
>> //        {
>> //            protected void populateItem(ListItem item)
>> //            {
>> //                final MCSSQuestion
>> mcssquestion=(MCSSQuestion)item.getModelObject();
>> //
>> //                item.setModel(new CompoundPropertyModel(mcssquestion));
>> //                item.add(new Label("questiontext"));
>> //                item.add(new Label("questionaire.Title"));
>> //
>> //
>> //            }
>> //
>> //        };
>> //        add(list);
>> //    }
>>     public ShowQuestions(final Questionaire qaire)
>>     {
>>
>>         SortableDataProvider provider= new SortableDataProvider()
>>         {
>>             // Return how many rows there are
>>             public int size()
>>             {
>>                 return qaire.getMcssquestion().size();
>>             }
>>             // convert each row object as a model
>>             public IModel model(Object object)
>>             {
>>                 MCSSQuestion mcss=(MCSSQuestion)object;
>>                 return new Model((Serializable) mcss);
>>             }
>>             public Iterator iterator(int first, int count)
>>             {
>>                 return qaire.selectEntries(first,count).iterator();
>>             }
>>         };
>>         IColumn[] columns= { new PropertyColumn(new
>> Model("ID"),"questiontext")
>>         };
>>
>>         DefaultDataTable datatable=new
>> DefaultDataTable("eachentry",columns,provider,1);
>>         add(datatable);
>>     }
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-Display-List-in-DataTable-tp15459611p15459611.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-Display-List-in-DataTable-tp15459611p15480790.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to