You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk> on 2007/11/19 09:51:48 UTC

Forms and Listview questions..?

Hi

I've been "playing" with both forms and listviews. And I wanted to 
extend a form creating my own form that has captcha validation as 
standard, I cant just seem to find where to place the markup when 
extending Form? I then tried doing it with a panel but also ran into 
sometroubles.

Also I've been noticing that if you use a compound model with a listview 
forexample my page has a  compound model called article I add the 
listview new listview("comments"). I would expect my item in the 
populate implementation to get fed a comment compoundmodel, but it does 
only get the compound model for the page, I then have to call 
item.getModelObject and set the compundmodel manually. Is this something 
that has been overseen, or am I missing the bigger picture?

regards

-- 
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms and Listview questions..?

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Hmm yeah, but I might have to give it a second glance. Still I feel it's 
kind of odd that the listItem gets the pageModel and not its own model 
as model when using it as compoundmodel.

-Nino

Gwyn Evans wrote:
> Just to check that, as you're looking at more complex displays, you've
> had a look at the wicket-extension facilities, e.g. those below
> org.apache.wicket.extensions.markup.html.repeater.data, for instance?
>
> Examples at http://www.wicketstuff.org/wicket13/repeater/
>
> /Gwyn
>
> On 21/11/2007, Nino Saturnino Martinez Vazquez Wael
> <ni...@jayway.dk> wrote:
>   
>> Gwyn Evans wrote:
>>     
>>> On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
>>> <ni...@jayway.dk> wrote:
>>>
>>>       
>>>> Gwyn Evans wrote:
>>>>
>>>>         
>>>>> On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
>>>>> <ni...@jayway.dk> wrote:
>>>>>
>>>>>
>>>>>           
>>>>>> Bump for replies..? Does my mail make sense? Do I need to specify
>>>>>> anything further?
>>>>>>
>>>>>> Nino Saturnino Martinez Vazquez Wael wrote:
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> Hi
>>>>>>>
>>>>>>> I've been "playing" with both forms and listviews. And I wanted to
>>>>>>> extend a form creating my own form that has captcha validation as
>>>>>>> standard, I cant just seem to find where to place the markup when
>>>>>>> extending Form?
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>> Well, off-hand, I'd expect that the easiest way would be to do it
>>>>> using markup inheritance -
>>>>> http://wicket.apache.org/examplemarkupinheritance.html.
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> Hm  the link you gave  talks about inheritance for a page. However this
>>>> would mean that I had to put the <wicket:child> into the form in order
>>>> to add stuff to the form right? What about inheritance for a panel, that
>>>> way I could use it as a form. However I got some strange errors when
>>>> trying todo this. Heres some pseduo
>>>>
>>>>
>>>> panel.html
>>>>
>>>> <wicket:panel>
>>>>
>>>> <img wicket:id="myCaptchaimg"></img>
>>>>
>>>> <form wicket:id="form">
>>>>
>>>> <input wicket:id="captchamatchingtext" />
>>>> <wicket:child>
>>>> </form>
>>>> </wicket:panel>
>>>>
>>>> panel.java
>>>>
>>>> private final Form form
>>>>
>>>> panel(String id)
>>>> {
>>>> super(id);
>>>> form=new Form("form");
>>>> add(form);
>>>>
>>>> form.add(new textfield..)
>>>> add(new captcha...);
>>>> }
>>>>
>>>> public addToForm(Component child){
>>>> form.add(child);
>>>> }
>>>>
>>>> Then the extending panels can add more stuff to the form.. Is this
>>>> supposed to work?
>>>>
>>>>         
>>> If I understand it correctly, I'd have thought so, yes, although if
>>> just getting started, I'd be tempted to get things going on a basic
>>> page, then start refactoring.
>>>
>>>       
>> Ok, i'll try to redo the panel, and if I run into troubles i'll provide
>> a quickstart...
>>     
>>>>>>> I then tried doing it with a panel but also ran into
>>>>>>> sometroubles.
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>> Also I've been noticing that if you use a compound model with a
>>>>>>> listview forexample my page has a  compound model called article I add
>>>>>>> the listview new listview("comments"). I would expect my item in the
>>>>>>> populate implementation to get fed a comment compoundmodel, but it
>>>>>>> does only get the compound model for the page, I then have to call
>>>>>>> item.getModelObject and set the compundmodel manually. Is this
>>>>>>> something that has been overseen, or am I missing the bigger picture?
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>> I think so...  Compare this...
>>>>>
>>>>> HTML:
>>>>>         <ul wicket:id="comments">
>>>>>               <li wicket:id="comment">Dummy comment</li>
>>>>>         </ul>
>>>>>
>>>>> Java: (compressed for vertical size!)
>>>>>
>>>>>   class Article {
>>>>>     private List comments = Arrays.asList(new String[]{"Comment One",
>>>>> "Comment Two", "Comment Three"});
>>>>>     public List getComments() { return comments; }
>>>>>   }
>>>>>
>>>>> and
>>>>>
>>>>>   public MyPage(final PageParameters parameters) {
>>>>>     setModel(new CompoundPropertyModel(new Article()));
>>>>>     ListView listView = new ListView("comments") {
>>>>>       protected void populateItem(ListItem item) {
>>>>>         item.add(new Label("comment", (String)item.getModelObject()));
>>>>>       }
>>>>>     };
>>>>>   }
>>>>>   add(listView);
>>>>>
>>>>> gives the following output:
>>>>>
>>>>>     * Comment One
>>>>>     * Comment Two
>>>>>     * Comment Three
>>>>>
>>>>>
>>>>> /Gwyn
>>>>>
>>>>>
>>>>>           
>>>> This is what I meant extending your example a but, it feels odd to make
>>>> an extra compoundpropertymodel:
>>>>
>>>>  class Article {
>>>>     private List<comment> comments=new arraylist<comments>...
>>>>     public List getComments() { return comments; }
>>>>   }
>>>> class Comment{
>>>>         private String text...
>>>>         private String author
>>>>         ....trival getters and setters...
>>>> }
>>>>
>>>>  public MyPage(final PageParameters parameters) {
>>>>     setModel(new CompoundPropertyModel(new Article()));
>>>>     ListView listView = new ListView("comments") {
>>>>       protected void populateItem(ListItem item) {
>>>>         setModel(new *CompundPropertyModel*(item.getModelObject()
>>>> ))
>>>>         item.add(new Label("comment"));
>>>>         item.add(new Label("author"));
>>>>
>>>>       }
>>>>     };
>>>>   }
>>>>   add(listView);
>>>>
>>>>         
>>> I see.  You can do it like that, but personally, for just a cople of
>>> labels I'd just implement populateItem() as follows:
>>>
>>>
>>>       
>> Sure, this was meant to be a simple example.. If you add some complexity
>> to it it's much simpler to use the compound propertymodel, and theres
>> not need for all that code calling all the different acessors since this
>> is what a compoundmodel does.. Im not sure if something else can be
>> gained if you make it detachable?
>>     
>>>  protected void populateItem(ListItem item) {
>>>    final Comment comment = (Comment)item.getModelObject();
>>>    item.add(new Label("text", comment.getText()));
>>>    item.add(new Label("author", comment.getAuthor()));
>>>  }
>>>
>>> By the way, my HTML was incorrect before.  If should be more like this...
>>>
>>>
>>>       
>> No problem, so was mine..
>>     
>>> <ul>
>>>   <li wicket:id="comments">
>>>     <span wicket:id="author"></span>: <span wicket:id="text"></span>
>>>   </li>
>>> </ul>
>>>
>>> /Gwyn
>>>
>>>       
>> --
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>
>   

-- 
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms and Listview questions..?

Posted by Gwyn Evans <gw...@gmail.com>.
Just to check that, as you're looking at more complex displays, you've
had a look at the wicket-extension facilities, e.g. those below
org.apache.wicket.extensions.markup.html.repeater.data, for instance?

Examples at http://www.wicketstuff.org/wicket13/repeater/

/Gwyn

On 21/11/2007, Nino Saturnino Martinez Vazquez Wael
<ni...@jayway.dk> wrote:
>
>
> Gwyn Evans wrote:
> > On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
> > <ni...@jayway.dk> wrote:
> >
> >> Gwyn Evans wrote:
> >>
> >>> On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
> >>> <ni...@jayway.dk> wrote:
> >>>
> >>>
> >>>> Bump for replies..? Does my mail make sense? Do I need to specify
> >>>> anything further?
> >>>>
> >>>> Nino Saturnino Martinez Vazquez Wael wrote:
> >>>>
> >>>>
> >>>>> Hi
> >>>>>
> >>>>> I've been "playing" with both forms and listviews. And I wanted to
> >>>>> extend a form creating my own form that has captcha validation as
> >>>>> standard, I cant just seem to find where to place the markup when
> >>>>> extending Form?
> >>>>>
> >>>>>
> >>> Well, off-hand, I'd expect that the easiest way would be to do it
> >>> using markup inheritance -
> >>> http://wicket.apache.org/examplemarkupinheritance.html.
> >>>
> >>>
> >>>
> >> Hm  the link you gave  talks about inheritance for a page. However this
> >> would mean that I had to put the <wicket:child> into the form in order
> >> to add stuff to the form right? What about inheritance for a panel, that
> >> way I could use it as a form. However I got some strange errors when
> >> trying todo this. Heres some pseduo
> >>
> >>
> >> panel.html
> >>
> >> <wicket:panel>
> >>
> >> <img wicket:id="myCaptchaimg"></img>
> >>
> >> <form wicket:id="form">
> >>
> >> <input wicket:id="captchamatchingtext" />
> >> <wicket:child>
> >> </form>
> >> </wicket:panel>
> >>
> >> panel.java
> >>
> >> private final Form form
> >>
> >> panel(String id)
> >> {
> >> super(id);
> >> form=new Form("form");
> >> add(form);
> >>
> >> form.add(new textfield..)
> >> add(new captcha...);
> >> }
> >>
> >> public addToForm(Component child){
> >> form.add(child);
> >> }
> >>
> >> Then the extending panels can add more stuff to the form.. Is this
> >> supposed to work?
> >>
> >
> > If I understand it correctly, I'd have thought so, yes, although if
> > just getting started, I'd be tempted to get things going on a basic
> > page, then start refactoring.
> >
> Ok, i'll try to redo the panel, and if I run into troubles i'll provide
> a quickstart...
> >
> >>>>> I then tried doing it with a panel but also ran into
> >>>>> sometroubles.
> >>>>>
> >>>>>
> >>>
> >>>>> Also I've been noticing that if you use a compound model with a
> >>>>> listview forexample my page has a  compound model called article I add
> >>>>> the listview new listview("comments"). I would expect my item in the
> >>>>> populate implementation to get fed a comment compoundmodel, but it
> >>>>> does only get the compound model for the page, I then have to call
> >>>>> item.getModelObject and set the compundmodel manually. Is this
> >>>>> something that has been overseen, or am I missing the bigger picture?
> >>>>>
> >>>>>
> >>> I think so...  Compare this...
> >>>
> >>> HTML:
> >>>         <ul wicket:id="comments">
> >>>               <li wicket:id="comment">Dummy comment</li>
> >>>         </ul>
> >>>
> >>> Java: (compressed for vertical size!)
> >>>
> >>>   class Article {
> >>>     private List comments = Arrays.asList(new String[]{"Comment One",
> >>> "Comment Two", "Comment Three"});
> >>>     public List getComments() { return comments; }
> >>>   }
> >>>
> >>> and
> >>>
> >>>   public MyPage(final PageParameters parameters) {
> >>>     setModel(new CompoundPropertyModel(new Article()));
> >>>     ListView listView = new ListView("comments") {
> >>>       protected void populateItem(ListItem item) {
> >>>         item.add(new Label("comment", (String)item.getModelObject()));
> >>>       }
> >>>     };
> >>>   }
> >>>   add(listView);
> >>>
> >>> gives the following output:
> >>>
> >>>     * Comment One
> >>>     * Comment Two
> >>>     * Comment Three
> >>>
> >>>
> >>> /Gwyn
> >>>
> >>>
> >> This is what I meant extending your example a but, it feels odd to make
> >> an extra compoundpropertymodel:
> >>
> >>  class Article {
> >>     private List<comment> comments=new arraylist<comments>...
> >>     public List getComments() { return comments; }
> >>   }
> >> class Comment{
> >>         private String text...
> >>         private String author
> >>         ....trival getters and setters...
> >> }
> >>
> >>  public MyPage(final PageParameters parameters) {
> >>     setModel(new CompoundPropertyModel(new Article()));
> >>     ListView listView = new ListView("comments") {
> >>       protected void populateItem(ListItem item) {
> >>         setModel(new *CompundPropertyModel*(item.getModelObject()
> >> ))
> >>         item.add(new Label("comment"));
> >>         item.add(new Label("author"));
> >>
> >>       }
> >>     };
> >>   }
> >>   add(listView);
> >>
> >
> > I see.  You can do it like that, but personally, for just a cople of
> > labels I'd just implement populateItem() as follows:
> >
> >
> Sure, this was meant to be a simple example.. If you add some complexity
> to it it's much simpler to use the compound propertymodel, and theres
> not need for all that code calling all the different acessors since this
> is what a compoundmodel does.. Im not sure if something else can be
> gained if you make it detachable?
> >  protected void populateItem(ListItem item) {
> >    final Comment comment = (Comment)item.getModelObject();
> >    item.add(new Label("text", comment.getText()));
> >    item.add(new Label("author", comment.getAuthor()));
> >  }
> >
> > By the way, my HTML was incorrect before.  If should be more like this...
> >
> >
> No problem, so was mine..
> > <ul>
> >   <li wicket:id="comments">
> >     <span wicket:id="author"></span>: <span wicket:id="text"></span>
> >   </li>
> > </ul>
> >
> > /Gwyn
> >
>
> --
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Download Wicket 1.3.0-rc1 now! - http://wicketframework.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms and Listview questions..?

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.

Gwyn Evans wrote:
> On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
> <ni...@jayway.dk> wrote:
>   
>> Gwyn Evans wrote:
>>     
>>> On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
>>> <ni...@jayway.dk> wrote:
>>>
>>>       
>>>> Bump for replies..? Does my mail make sense? Do I need to specify
>>>> anything further?
>>>>
>>>> Nino Saturnino Martinez Vazquez Wael wrote:
>>>>
>>>>         
>>>>> Hi
>>>>>
>>>>> I've been "playing" with both forms and listviews. And I wanted to
>>>>> extend a form creating my own form that has captcha validation as
>>>>> standard, I cant just seem to find where to place the markup when
>>>>> extending Form?
>>>>>
>>>>>           
>>> Well, off-hand, I'd expect that the easiest way would be to do it
>>> using markup inheritance -
>>> http://wicket.apache.org/examplemarkupinheritance.html.
>>>
>>>
>>>       
>> Hm  the link you gave  talks about inheritance for a page. However this
>> would mean that I had to put the <wicket:child> into the form in order
>> to add stuff to the form right? What about inheritance for a panel, that
>> way I could use it as a form. However I got some strange errors when
>> trying todo this. Heres some pseduo
>>
>>
>> panel.html
>>
>> <wicket:panel>
>>
>> <img wicket:id="myCaptchaimg"></img>
>>
>> <form wicket:id="form">
>>
>> <input wicket:id="captchamatchingtext" />
>> <wicket:child>
>> </form>
>> </wicket:panel>
>>
>> panel.java
>>
>> private final Form form
>>
>> panel(String id)
>> {
>> super(id);
>> form=new Form("form");
>> add(form);
>>
>> form.add(new textfield..)
>> add(new captcha...);
>> }
>>
>> public addToForm(Component child){
>> form.add(child);
>> }
>>
>> Then the extending panels can add more stuff to the form.. Is this
>> supposed to work?
>>     
>
> If I understand it correctly, I'd have thought so, yes, although if
> just getting started, I'd be tempted to get things going on a basic
> page, then start refactoring.
>   
Ok, i'll try to redo the panel, and if I run into troubles i'll provide 
a quickstart...
>   
>>>>> I then tried doing it with a panel but also ran into
>>>>> sometroubles.
>>>>>
>>>>>           
>>>       
>>>>> Also I've been noticing that if you use a compound model with a
>>>>> listview forexample my page has a  compound model called article I add
>>>>> the listview new listview("comments"). I would expect my item in the
>>>>> populate implementation to get fed a comment compoundmodel, but it
>>>>> does only get the compound model for the page, I then have to call
>>>>> item.getModelObject and set the compundmodel manually. Is this
>>>>> something that has been overseen, or am I missing the bigger picture?
>>>>>
>>>>>           
>>> I think so...  Compare this...
>>>
>>> HTML:
>>>         <ul wicket:id="comments">
>>>               <li wicket:id="comment">Dummy comment</li>
>>>         </ul>
>>>
>>> Java: (compressed for vertical size!)
>>>
>>>   class Article {
>>>     private List comments = Arrays.asList(new String[]{"Comment One",
>>> "Comment Two", "Comment Three"});
>>>     public List getComments() { return comments; }
>>>   }
>>>
>>> and
>>>
>>>   public MyPage(final PageParameters parameters) {
>>>     setModel(new CompoundPropertyModel(new Article()));
>>>     ListView listView = new ListView("comments") {
>>>       protected void populateItem(ListItem item) {
>>>         item.add(new Label("comment", (String)item.getModelObject()));
>>>       }
>>>     };
>>>   }
>>>   add(listView);
>>>
>>> gives the following output:
>>>
>>>     * Comment One
>>>     * Comment Two
>>>     * Comment Three
>>>
>>>
>>> /Gwyn
>>>
>>>       
>> This is what I meant extending your example a but, it feels odd to make
>> an extra compoundpropertymodel:
>>
>>  class Article {
>>     private List<comment> comments=new arraylist<comments>...
>>     public List getComments() { return comments; }
>>   }
>> class Comment{
>>         private String text...
>>         private String author
>>         ....trival getters and setters...
>> }
>>
>>  public MyPage(final PageParameters parameters) {
>>     setModel(new CompoundPropertyModel(new Article()));
>>     ListView listView = new ListView("comments") {
>>       protected void populateItem(ListItem item) {
>>         setModel(new *CompundPropertyModel*(item.getModelObject()
>> ))
>>         item.add(new Label("comment"));
>>         item.add(new Label("author"));
>>
>>       }
>>     };
>>   }
>>   add(listView);
>>     
>
> I see.  You can do it like that, but personally, for just a cople of
> labels I'd just implement populateItem() as follows:
>
>   
Sure, this was meant to be a simple example.. If you add some complexity 
to it it's much simpler to use the compound propertymodel, and theres 
not need for all that code calling all the different acessors since this 
is what a compoundmodel does.. Im not sure if something else can be 
gained if you make it detachable?
>  protected void populateItem(ListItem item) {
>    final Comment comment = (Comment)item.getModelObject();
>    item.add(new Label("text", comment.getText()));
>    item.add(new Label("author", comment.getAuthor()));
>  }
>
> By the way, my HTML was incorrect before.  If should be more like this...
>
>   
No problem, so was mine..
> <ul>
>   <li wicket:id="comments">
>     <span wicket:id="author"></span>: <span wicket:id="text"></span>
>   </li>
> </ul>
>
> /Gwyn
>   

-- 
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms and Listview questions..?

Posted by Gwyn Evans <gw...@gmail.com>.
On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
<ni...@jayway.dk> wrote:
>
>
> Gwyn Evans wrote:
> > On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
> > <ni...@jayway.dk> wrote:
> >
> >> Bump for replies..? Does my mail make sense? Do I need to specify
> >> anything further?
> >>
> >> Nino Saturnino Martinez Vazquez Wael wrote:
> >>
> >>> Hi
> >>>
> >>> I've been "playing" with both forms and listviews. And I wanted to
> >>> extend a form creating my own form that has captcha validation as
> >>> standard, I cant just seem to find where to place the markup when
> >>> extending Form?
> >>>
> >
> > Well, off-hand, I'd expect that the easiest way would be to do it
> > using markup inheritance -
> > http://wicket.apache.org/examplemarkupinheritance.html.
> >
> >
> Hm  the link you gave  talks about inheritance for a page. However this
> would mean that I had to put the <wicket:child> into the form in order
> to add stuff to the form right? What about inheritance for a panel, that
> way I could use it as a form. However I got some strange errors when
> trying todo this. Heres some pseduo
>
>
> panel.html
>
> <wicket:panel>
>
> <img wicket:id="myCaptchaimg"></img>
>
> <form wicket:id="form">
>
> <input wicket:id="captchamatchingtext" />
> <wicket:child>
> </form>
> </wicket:panel>
>
> panel.java
>
> private final Form form
>
> panel(String id)
> {
> super(id);
> form=new Form("form");
> add(form);
>
> form.add(new textfield..)
> add(new captcha...);
> }
>
> public addToForm(Component child){
> form.add(child);
> }
>
> Then the extending panels can add more stuff to the form.. Is this
> supposed to work?

If I understand it correctly, I'd have thought so, yes, although if
just getting started, I'd be tempted to get things going on a basic
page, then start refactoring.

> >>> I then tried doing it with a panel but also ran into
> >>> sometroubles.
> >>>
> >
> >
> >>> Also I've been noticing that if you use a compound model with a
> >>> listview forexample my page has a  compound model called article I add
> >>> the listview new listview("comments"). I would expect my item in the
> >>> populate implementation to get fed a comment compoundmodel, but it
> >>> does only get the compound model for the page, I then have to call
> >>> item.getModelObject and set the compundmodel manually. Is this
> >>> something that has been overseen, or am I missing the bigger picture?
> >>>
> >
> > I think so...  Compare this...
> >
> > HTML:
> >         <ul wicket:id="comments">
> >               <li wicket:id="comment">Dummy comment</li>
> >         </ul>
> >
> > Java: (compressed for vertical size!)
> >
> >   class Article {
> >     private List comments = Arrays.asList(new String[]{"Comment One",
> > "Comment Two", "Comment Three"});
> >     public List getComments() { return comments; }
> >   }
> >
> > and
> >
> >   public MyPage(final PageParameters parameters) {
> >     setModel(new CompoundPropertyModel(new Article()));
> >     ListView listView = new ListView("comments") {
> >       protected void populateItem(ListItem item) {
> >         item.add(new Label("comment", (String)item.getModelObject()));
> >       }
> >     };
> >   }
> >   add(listView);
> >
> > gives the following output:
> >
> >     * Comment One
> >     * Comment Two
> >     * Comment Three
> >
> >
> > /Gwyn
> >
> This is what I meant extending your example a but, it feels odd to make
> an extra compoundpropertymodel:
>
>  class Article {
>     private List<comment> comments=new arraylist<comments>...
>     public List getComments() { return comments; }
>   }
> class Comment{
>         private String text...
>         private String author
>         ....trival getters and setters...
> }
>
>  public MyPage(final PageParameters parameters) {
>     setModel(new CompoundPropertyModel(new Article()));
>     ListView listView = new ListView("comments") {
>       protected void populateItem(ListItem item) {
>         setModel(new *CompundPropertyModel*(item.getModelObject()
> ))
>         item.add(new Label("comment"));
>         item.add(new Label("author"));
>
>       }
>     };
>   }
>   add(listView);

I see.  You can do it like that, but personally, for just a cople of
labels I'd just implement populateItem() as follows:

 protected void populateItem(ListItem item) {
   final Comment comment = (Comment)item.getModelObject();
   item.add(new Label("text", comment.getText()));
   item.add(new Label("author", comment.getAuthor()));
 }

By the way, my HTML was incorrect before.  If should be more like this...

<ul>
  <li wicket:id="comments">
    <span wicket:id="author"></span>: <span wicket:id="text"></span>
  </li>
</ul>

/Gwyn
-- 
Download Wicket 1.3.0-rc1 now! - http://wicketframework.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms and Listview questions..?

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.

Gwyn Evans wrote:
> On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
> <ni...@jayway.dk> wrote:
>   
>> Bump for replies..? Does my mail make sense? Do I need to specify
>> anything further?
>>
>> Nino Saturnino Martinez Vazquez Wael wrote:
>>     
>>> Hi
>>>
>>> I've been "playing" with both forms and listviews. And I wanted to
>>> extend a form creating my own form that has captcha validation as
>>> standard, I cant just seem to find where to place the markup when
>>> extending Form?
>>>       
>
> Well, off-hand, I'd expect that the easiest way would be to do it
> using markup inheritance -
> http://wicket.apache.org/examplemarkupinheritance.html.
>
>   
Hm  the link you gave  talks about inheritance for a page. However this 
would mean that I had to put the <wicket:child> into the form in order 
to add stuff to the form right? What about inheritance for a panel, that 
way I could use it as a form. However I got some strange errors when 
trying todo this. Heres some pseduo


panel.html

<wicket:panel>

<img wicket:id="myCaptchaimg"></img>

<form wicket:id="form">

<input wicket:id="captchamatchingtext" />
<wicket:child>
</form>
</wicket:panel>

panel.java

private final Form form

panel(String id)
{
super(id);
form=new Form("form");
add(form);

form.add(new textfield..)
add(new captcha...);
}

public addToForm(Component child){
form.add(child);
}

Then the extending panels can add more stuff to the form.. Is this 
supposed to work?

>>> I then tried doing it with a panel but also ran into
>>> sometroubles.
>>>       
>
>   
>>> Also I've been noticing that if you use a compound model with a
>>> listview forexample my page has a  compound model called article I add
>>> the listview new listview("comments"). I would expect my item in the
>>> populate implementation to get fed a comment compoundmodel, but it
>>> does only get the compound model for the page, I then have to call
>>> item.getModelObject and set the compundmodel manually. Is this
>>> something that has been overseen, or am I missing the bigger picture?
>>>       
>
> I think so...  Compare this...
>
> HTML:
>         <ul wicket:id="comments">
> 	        <li wicket:id="comment">Dummy comment</li>
>         </ul>
>
> Java: (compressed for vertical size!)
>
>   class Article {
>     private List comments = Arrays.asList(new String[]{"Comment One",
> "Comment Two", "Comment Three"});
>     public List getComments() { return comments; }
>   }
>
> and
>
>   public MyPage(final PageParameters parameters) {
>     setModel(new CompoundPropertyModel(new Article()));
>     ListView listView = new ListView("comments") {
>       protected void populateItem(ListItem item) {
>         item.add(new Label("comment", (String)item.getModelObject()));
>       }
>     };
>   }
>   add(listView);
>
> gives the following output:
>
>     * Comment One
>     * Comment Two
>     * Comment Three
>
>
> /Gwyn
>   
This is what I meant extending your example a but, it feels odd to make 
an extra compoundpropertymodel:

 class Article {
    private List<comment> comments=new arraylist<comments>...
    public List getComments() { return comments; }
  }
class Comment{
	private String text...
	private String author
	....trival getters and setters...
}

 public MyPage(final PageParameters parameters) {
    setModel(new CompoundPropertyModel(new Article()));
    ListView listView = new ListView("comments") {
      protected void populateItem(ListItem item) {
	setModel(new *CompundPropertyModel*(item.getModelObject()
))
        item.add(new Label("comment"));
        item.add(new Label("author"));

      }
    };
  }
  add(listView);





-- 
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Finalizing details for Amsterdam, Netherlands Wicket Meetup Event Nov 30th

Posted by "C. Bergström" <cb...@netsyncro.com>.
Location: Amsterdam, Felix Meritis building (www.felixmeritis.nl)
Next meetup: Friday November 30

I've been loosely following this since the beginning and it's getting
closer to that time we all need to start scheduling this with work.. So
some general questions about finalizing the details..

Please forgive me if some of these questions are obvious as I don't see
it on the wiki.

1) Who wants to/can do a presentation/Q&A and how long will it be?
2) What time should this start?
3) What time does it end?
4) Where do we check-in, what room or how will we know where to go?

I propose a 10:00AM CET start if possible.  Depending on number of
speakers and how much time we can realistically fill we'll figure out
when it will end roughly speaking.  Lets break up the time slots into 15
minute blocks so we can fit in even small talks..

----------------------------------------
I'm pretty sure there's a couple people interested in attending from
outside the Netherlands/Amsterdam.  Maybe one of the natives can help
with instructions or failing that email me off list and I'll do my best.

Cheers,

Christopher Bergström


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms and Listview questions..?

Posted by Gwyn Evans <gw...@gmail.com>.
On 20/11/2007, Nino Saturnino Martinez Vazquez Wael
<ni...@jayway.dk> wrote:
> Bump for replies..? Does my mail make sense? Do I need to specify
> anything further?
>
> Nino Saturnino Martinez Vazquez Wael wrote:
> > Hi
> >
> > I've been "playing" with both forms and listviews. And I wanted to
> > extend a form creating my own form that has captcha validation as
> > standard, I cant just seem to find where to place the markup when
> > extending Form?

Well, off-hand, I'd expect that the easiest way would be to do it
using markup inheritance -
http://wicket.apache.org/examplemarkupinheritance.html.

> > I then tried doing it with a panel but also ran into
> > sometroubles.

> >
> > Also I've been noticing that if you use a compound model with a
> > listview forexample my page has a  compound model called article I add
> > the listview new listview("comments"). I would expect my item in the
> > populate implementation to get fed a comment compoundmodel, but it
> > does only get the compound model for the page, I then have to call
> > item.getModelObject and set the compundmodel manually. Is this
> > something that has been overseen, or am I missing the bigger picture?

I think so...  Compare this...

HTML:
        <ul wicket:id="comments">
	        <li wicket:id="comment">Dummy comment</li>
        </ul>

Java: (compressed for vertical size!)

  class Article {
    private List comments = Arrays.asList(new String[]{"Comment One",
"Comment Two", "Comment Three"});
    public List getComments() { return comments; }
  }

and

  public MyPage(final PageParameters parameters) {
    setModel(new CompoundPropertyModel(new Article()));
    ListView listView = new ListView("comments") {
      protected void populateItem(ListItem item) {
        item.add(new Label("comment", (String)item.getModelObject()));
      }
    };
  }
  add(listView);

gives the following output:

    * Comment One
    * Comment Two
    * Comment Three


/Gwyn
-- 
Download Wicket 1.3.0-rc1 now! - http://wicketframework.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Forms and Listview questions..?

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Bump for replies..? Does my mail make sense? Do I need to specify 
anything further?

Nino Saturnino Martinez Vazquez Wael wrote:
> Hi
>
> I've been "playing" with both forms and listviews. And I wanted to 
> extend a form creating my own form that has captcha validation as 
> standard, I cant just seem to find where to place the markup when 
> extending Form? I then tried doing it with a panel but also ran into 
> sometroubles.
>
> Also I've been noticing that if you use a compound model with a 
> listview forexample my page has a  compound model called article I add 
> the listview new listview("comments"). I would expect my item in the 
> populate implementation to get fed a comment compoundmodel, but it 
> does only get the compound model for the page, I then have to call 
> item.getModelObject and set the compundmodel manually. Is this 
> something that has been overseen, or am I missing the bigger picture?
>
> regards
>

-- 
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org