Re: dynamically adding components to a ListView

2010-01-27 Thread zdmytriv

Yes, the problem was I had to create container and then on onClick()

target.addComponent(newInteractivePanel);

Thanks everybody



RaBe wrote:
> 
> looks as it has been solved here:
> 
> http://stackoverflow.com/questions/2114351/dynamically-add-components-to-listview-in-wicket/
> 
> bert
> 
> On Sun, Jan 24, 2010 at 13:04, Sven Meier  wrote:
>> Hi,
>>
>> you'll have to tell the request target which components to redraw:
>> Put your list inside a markupcontainer and use addComponent().
>>
>> Sven
>>
>> zdmytriv wrote:
>>>
>>> Could anyone tell me why it doesn't work? Thanks
>>>
>>> InteractivePanelPage.html
>>>
>>> 
>>>    
>>>         # Add Panel 
>>>    
>>>    
>>>        
>>>                
>>>    
>>> 
>>>
>>> InteractivePanelPage.java
>>>
>>> // ... imports
>>> public class InteractivePanelPage extends WebPage {
>>>    public LinkedList interactivePanels = new
>>> LinkedList();
>>>
>>>    private ListView interactiveList;
>>>
>>>    public InteractivePanelPage() {
>>>        add(new AjaxLink("addPanelLink") {
>>>            private static final long serialVersionUID = 1L;
>>>
>>>           �...@override
>>>            public void onClick(AjaxRequestTarget target) {
>>>                try {
>>>                    System.out.println("link clicked");
>>>
>>>                    InteractivePanel newInteractivePanel = new
>>> InteractivePanel(
>>>                            "interactiveItemPanel");
>>>                    newInteractivePanel.setOutputMarkupId(true);
>>>
>>>
>>> interactiveList.getModelObject().add(newInteractivePanel);
>>>                } catch (Exception e) {
>>>                    e.printStackTrace();
>>>                }
>>>            }
>>>        });
>>>
>>>        interactivePanels.add(new
>>> InteractivePanel("interactiveItemPanel"));
>>>
>>>        interactiveList = new
>>> ListView("interactiveListView",
>>>                new PropertyModel>(this,
>>> "interactivePanels")) {
>>>            private static final long serialVersionUID = 1L;
>>>
>>>           �...@override
>>>            protected void populateItem(ListItem item)
>>> {
>>>                item.add(item.getModelObject());
>>>            }
>>>        };
>>>
>>>        interactiveList.setOutputMarkupId(true);
>>>
>>>        add(interactiveList);
>>>    }
>>>
>>>    public List getInteractivePanels() {
>>>        return interactivePanels;
>>>    }
>>> }
>>>
>>> InteractivePanel.html
>>>
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> InteractivePanel.java
>>>
>>> // ... imports
>>> public class InteractivePanel extends Panel {
>>>    private static final long serialVersionUID = 1L;
>>>
>>>    public InteractivePanel(String id) {
>>>        super(id);
>>>
>>>        add(new Button("simpleButton"));
>>>    }
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> zkn wrote:
>>>
>>>>
>>>> On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:
>>>>
>>>>
>>>>>
>>>>>
>>>>> http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html
>>>>>
>>>>> In this post you said "You found it". Could you please post how did
>>>>> you
>>>>> do it?
>>>>>
>>>>> Zinovii
>>>>>
>>>>
>>>> in addPanel()
>>>>
>>>> replaced
>>>> panels.add(panel);
>>>>
>>>> with
>>>>
>>>> panels.getModelObject().add(panel);
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On 04.12.2009, at 00:17, zkn wrote:
>>>>
>>>>
>>>>>
>>>>> found it.
>>>>>
>>>>> On 03.12.2009, at 16:19, zkn wrote:
>>>>>
>>>>>
>>>>>>
>>>>

Re: dynamically adding components to a ListView

2010-01-26 Thread Bert
looks as it has been solved here:

http://stackoverflow.com/questions/2114351/dynamically-add-components-to-listview-in-wicket/

bert

On Sun, Jan 24, 2010 at 13:04, Sven Meier  wrote:
> Hi,
>
> you'll have to tell the request target which components to redraw:
> Put your list inside a markupcontainer and use addComponent().
>
> Sven
>
> zdmytriv wrote:
>>
>> Could anyone tell me why it doesn't work? Thanks
>>
>> InteractivePanelPage.html
>>
>> 
>>    
>>         # Add Panel 
>>    
>>    
>>        
>>                
>>    
>> 
>>
>> InteractivePanelPage.java
>>
>> // ... imports
>> public class InteractivePanelPage extends WebPage {
>>    public LinkedList interactivePanels = new
>> LinkedList();
>>
>>    private ListView interactiveList;
>>
>>    public InteractivePanelPage() {
>>        add(new AjaxLink("addPanelLink") {
>>            private static final long serialVersionUID = 1L;
>>
>>           �...@override
>>            public void onClick(AjaxRequestTarget target) {
>>                try {
>>                    System.out.println("link clicked");
>>
>>                    InteractivePanel newInteractivePanel = new
>> InteractivePanel(
>>                            "interactiveItemPanel");
>>                    newInteractivePanel.setOutputMarkupId(true);
>>
>>
>> interactiveList.getModelObject().add(newInteractivePanel);
>>                } catch (Exception e) {
>>                    e.printStackTrace();
>>                }
>>            }
>>        });
>>
>>        interactivePanels.add(new
>> InteractivePanel("interactiveItemPanel"));
>>
>>        interactiveList = new
>> ListView("interactiveListView",
>>                new PropertyModel>(this,
>> "interactivePanels")) {
>>            private static final long serialVersionUID = 1L;
>>
>>           �...@override
>>            protected void populateItem(ListItem item) {
>>                item.add(item.getModelObject());
>>            }
>>        };
>>
>>        interactiveList.setOutputMarkupId(true);
>>
>>        add(interactiveList);
>>    }
>>
>>    public List getInteractivePanels() {
>>        return interactivePanels;
>>    }
>> }
>>
>> InteractivePanel.html
>>
>> 
>> 
>> 
>> 
>> 
>>
>> InteractivePanel.java
>>
>> // ... imports
>> public class InteractivePanel extends Panel {
>>    private static final long serialVersionUID = 1L;
>>
>>    public InteractivePanel(String id) {
>>        super(id);
>>
>>        add(new Button("simpleButton"));
>>    }
>> }
>>
>>
>>
>>
>>
>>
>>
>>
>> zkn wrote:
>>
>>>
>>> On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:
>>>
>>>
>>>>
>>>>
>>>> http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html
>>>>
>>>> In this post you said "You found it". Could you please post how did you
>>>> do it?
>>>>
>>>> Zinovii
>>>>
>>>
>>> in addPanel()
>>>
>>> replaced
>>> panels.add(panel);
>>>
>>> with
>>>
>>> panels.getModelObject().add(panel);
>>>
>>>
>>>
>>>
>>>
>>> On 04.12.2009, at 00:17, zkn wrote:
>>>
>>>
>>>>
>>>> found it.
>>>>
>>>> On 03.12.2009, at 16:19, zkn wrote:
>>>>
>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I'm trying to dynamically add components to an existing ListView but I
>>>>> can't figure out how to do that. Here is my case:
>>>>>
>>>>> MyPanelContainer  class with markup
>>>>>
>>>>> 
>>>>>        
>>>>>                
>>>>>        
>>>>>         # add panel 
>>>>>
>>>>> and here is how I create the container in the constructor of my page
>>>>>
>>>>> ..
>>>>> MyPanelContainer container = new MyPanelContainer("panels_list_1");
>>>>> List panels = new ArrayList();
>>>>>
>>>>>

Re: dynamically adding components to a ListView

2010-01-24 Thread Sven Meier

Hi,

you'll have to tell the request target which components to redraw:
Put your list inside a markupcontainer and use addComponent().

Sven

zdmytriv wrote:

Could anyone tell me why it doesn't work? Thanks

InteractivePanelPage.html



 # Add Panel 









InteractivePanelPage.java

// ... imports
public class InteractivePanelPage extends WebPage {
public LinkedList interactivePanels = new
LinkedList();

private ListView interactiveList;

public InteractivePanelPage() {
add(new AjaxLink("addPanelLink") {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
try {
System.out.println("link clicked");

InteractivePanel newInteractivePanel = new
InteractivePanel(
"interactiveItemPanel");
newInteractivePanel.setOutputMarkupId(true);

   
interactiveList.getModelObject().add(newInteractivePanel);

} catch (Exception e) {
e.printStackTrace();
}
}
});

interactivePanels.add(new InteractivePanel("interactiveItemPanel"));

interactiveList = new
ListView("interactiveListView",
new PropertyModel>(this,
"interactivePanels")) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem item) {
item.add(item.getModelObject());
}
};

interactiveList.setOutputMarkupId(true);

add(interactiveList);
}

public List getInteractivePanels() {
return interactivePanels;
}
}

InteractivePanel.html







InteractivePanel.java

// ... imports
public class InteractivePanel extends Panel {
private static final long serialVersionUID = 1L;

public InteractivePanel(String id) {
super(id);

add(new Button("simpleButton"));
}
}








zkn wrote:
  

On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:



http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html

In this post you said "You found it". Could you please post how did you
do it?

Zinovii
  

in addPanel()

replaced 


panels.add(panel);

with

panels.getModelObject().add(panel);





On 04.12.2009, at 00:17, zkn wrote:



found it.

On 03.12.2009, at 16:19, zkn wrote:

  

Hi,

I'm trying to dynamically add components to an existing ListView but I
can't figure out how to do that. Here is my case:

MyPanelContainer  class with markup





	 # add panel 



and here is how I create the container in the constructor of my page

..
MyPanelContainer container = new MyPanelContainer("panels_list_1");
List panels = new ArrayList();

for (int j = 0; j < 5; j++) {
MyPanel panel = new MyPanel("panel");

.

panels.add(panel);
.


container.add(new ListView("panels", panels) {
protected void populateItem(ListItem item) {
item.add( item.getModelObject());
}
});
add(Container);
..

This works fine and I can see all  MyPanel inside the container.

Now I'm trying to add another MyPanel inside the container on user
click. Here is the constructor of MyPanelContainer

public MyPanelContainer(String id) {
super(id);

add(new Link("addPanel") {
@Override
public void onClick() {
addPanel();
}

});
.

..
public void addPanel() {

ListView< MyPanel > panels = (ListView< MyPanel >) 
get("panels");

MyPanel panel = new MyPanel("panel");
...
panels.add(panel);
}

Basically addPanel() does the same thing as in page constructor to add
panels to the list but nothing shows up.

Thanks in advance for your help

Ozkan







  



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



Re: dynamically adding components to a ListView

2010-01-23 Thread zdmytriv

It doesn't create new panel on addPanelLink click.




kinabalu wrote:
> 
> might want to specify what isn't working exactly?
> 
> On Jan 23, 2010, at 1:15 PM, zdmytriv wrote:
> 
>> 
>> Could anyone tell me why it doesn't work? Thanks
>> 
>> InteractivePanelPage.html
>> 
>> 
>>
>> # Add Panel 
>>
>>
>>
>> 
>>
>>
>> 
>> 
>> InteractivePanelPage.java
>> 
>> // ... imports
>> public class InteractivePanelPage extends WebPage {
>>public LinkedList interactivePanels = new
>> LinkedList();
>> 
>>private ListView interactiveList;
>> 
>>public InteractivePanelPage() {
>>add(new AjaxLink("addPanelLink") {
>>private static final long serialVersionUID = 1L;
>> 
>>@Override
>>public void onClick(AjaxRequestTarget target) {
>>try {
>>System.out.println("link clicked");
>> 
>>InteractivePanel newInteractivePanel = new
>> InteractivePanel(
>>"interactiveItemPanel");
>>newInteractivePanel.setOutputMarkupId(true);
>> 
>> 
>> interactiveList.getModelObject().add(newInteractivePanel);
>>} catch (Exception e) {
>>e.printStackTrace();
>>}
>>}
>>});
>> 
>>interactivePanels.add(new
>> InteractivePanel("interactiveItemPanel"));
>> 
>>interactiveList = new
>> ListView("interactiveListView",
>>new PropertyModel>(this,
>> "interactivePanels")) {
>>private static final long serialVersionUID = 1L;
>> 
>>@Override
>>protected void populateItem(ListItem item) {
>>item.add(item.getModelObject());
>>}
>>};
>> 
>>interactiveList.setOutputMarkupId(true);
>> 
>>add(interactiveList);
>>}
>> 
>>public List getInteractivePanels() {
>>return interactivePanels;
>>}
>> }
>> 
>> InteractivePanel.html
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> InteractivePanel.java
>> 
>> // ... imports
>> public class InteractivePanel extends Panel {
>>private static final long serialVersionUID = 1L;
>> 
>>public InteractivePanel(String id) {
>>super(id);
>> 
>>add(new Button("simpleButton"));
>>}
>> }
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> zkn wrote:
>>> 
>>> 
>>> On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:
>>> 
>>>> http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html
>>>> 
>>>> In this post you said "You found it". Could you please post how did you
>>>> do it?
>>>> 
>>>> Zinovii
>>> 
>>> in addPanel()
>>> 
>>> replaced 
>>> 
>>> panels.add(panel);
>>> 
>>> with
>>> 
>>> panels.getModelObject().add(panel);
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On 04.12.2009, at 00:17, zkn wrote:
>>> 
>>>> found it.
>>>> 
>>>> On 03.12.2009, at 16:19, zkn wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>> I'm trying to dynamically add components to an existing ListView but I
>>>>> can't figure out how to do that. Here is my case:
>>>>> 
>>>>> MyPanelContainer  class with markup
>>>>> 
>>>>> 
>>>>>   
>>>>>   
>>>>>   
>>>>># add panel 
>>>>> 
>>>>> 
>>>>> and here is how I create the container in the constructor of my page
>>>>> 
>>>>> ..
>>>>> MyPanelContainer container = new MyPanelContainer("panels_list_1");
>>>>> List panels = new ArrayList();
>>>>> 
>>>>> for (int j = 0; j < 5; j++) {
>>>>>   MyPanel panel = new MyPanel("panel");
>>>>>   
>>>>>   .
>>>>>   
>>>>>   panels.add(panel);
>>>

Re: dynamically adding components to a ListView

2010-01-23 Thread Andrew Lombardi
might want to specify what isn't working exactly?

On Jan 23, 2010, at 1:15 PM, zdmytriv wrote:

> 
> Could anyone tell me why it doesn't work? Thanks
> 
> InteractivePanelPage.html
> 
> 
>
> # Add Panel 
>
>
>
> 
>
>
> 
> 
> InteractivePanelPage.java
> 
> // ... imports
> public class InteractivePanelPage extends WebPage {
>public LinkedList interactivePanels = new
> LinkedList();
> 
>private ListView interactiveList;
> 
>public InteractivePanelPage() {
>add(new AjaxLink("addPanelLink") {
>private static final long serialVersionUID = 1L;
> 
>@Override
>public void onClick(AjaxRequestTarget target) {
>try {
>System.out.println("link clicked");
> 
>InteractivePanel newInteractivePanel = new
> InteractivePanel(
>"interactiveItemPanel");
>newInteractivePanel.setOutputMarkupId(true);
> 
> 
> interactiveList.getModelObject().add(newInteractivePanel);
>} catch (Exception e) {
>e.printStackTrace();
>}
>}
>});
> 
>interactivePanels.add(new InteractivePanel("interactiveItemPanel"));
> 
>interactiveList = new
> ListView("interactiveListView",
>new PropertyModel>(this,
> "interactivePanels")) {
>private static final long serialVersionUID = 1L;
> 
>@Override
>protected void populateItem(ListItem item) {
>item.add(item.getModelObject());
>}
>};
> 
>interactiveList.setOutputMarkupId(true);
> 
>add(interactiveList);
>}
> 
>public List getInteractivePanels() {
>return interactivePanels;
>}
> }
> 
> InteractivePanel.html
> 
> 
> 
> 
> 
> 
> 
> InteractivePanel.java
> 
> // ... imports
> public class InteractivePanel extends Panel {
>    private static final long serialVersionUID = 1L;
> 
>public InteractivePanel(String id) {
>super(id);
> 
>add(new Button("simpleButton"));
>}
> }
> 
> 
> 
> 
> 
> 
> 
> 
> zkn wrote:
>> 
>> 
>> On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:
>> 
>>> http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html
>>> 
>>> In this post you said "You found it". Could you please post how did you
>>> do it?
>>> 
>>> Zinovii
>> 
>> in addPanel()
>> 
>> replaced 
>> 
>> panels.add(panel);
>> 
>> with
>> 
>> panels.getModelObject().add(panel);
>> 
>> 
>> 
>> 
>> 
>> On 04.12.2009, at 00:17, zkn wrote:
>> 
>>> found it.
>>> 
>>> On 03.12.2009, at 16:19, zkn wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I'm trying to dynamically add components to an existing ListView but I
>>>> can't figure out how to do that. Here is my case:
>>>> 
>>>> MyPanelContainer  class with markup
>>>> 
>>>> 
>>>>
>>>>
>>>>
>>>> # add panel 
>>>> 
>>>> 
>>>> and here is how I create the container in the constructor of my page
>>>> 
>>>> ..
>>>> MyPanelContainer container = new MyPanelContainer("panels_list_1");
>>>> List panels = new ArrayList();
>>>> 
>>>> for (int j = 0; j < 5; j++) {
>>>>MyPanel panel = new MyPanel("panel");
>>>>
>>>>.
>>>>
>>>>panels.add(panel);
>>>> .
>>>> 
>>>> 
>>>> container.add(new ListView("panels", panels) {
>>>>protected void populateItem(ListItem item) {
>>>>item.add( item.getModelObject());
>>>>}
>>>> });
>>>> add(Container);
>>>> ..
>>>> 
>>>> This works fine and I can see all  MyPanel inside the container.
>>>> 
>>>> Now I'm trying to add another MyPanel inside the container on user
>>>> click. Here is the constructor of MyPanelContainer
>>>> 
>>>> public MyPanelContainer(String id) {
>>>>super(id);
>>&g

Re: dynamically adding components to a ListView

2010-01-23 Thread zdmytriv

Could anyone tell me why it doesn't work? Thanks

InteractivePanelPage.html



 # Add Panel 








InteractivePanelPage.java

// ... imports
public class InteractivePanelPage extends WebPage {
public LinkedList interactivePanels = new
LinkedList();

private ListView interactiveList;

public InteractivePanelPage() {
add(new AjaxLink("addPanelLink") {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
try {
System.out.println("link clicked");

InteractivePanel newInteractivePanel = new
InteractivePanel(
"interactiveItemPanel");
newInteractivePanel.setOutputMarkupId(true);

   
interactiveList.getModelObject().add(newInteractivePanel);
} catch (Exception e) {
e.printStackTrace();
}
}
});

interactivePanels.add(new InteractivePanel("interactiveItemPanel"));

interactiveList = new
ListView("interactiveListView",
new PropertyModel>(this,
"interactivePanels")) {
private static final long serialVersionUID = 1L;

@Override
protected void populateItem(ListItem item) {
item.add(item.getModelObject());
}
};

interactiveList.setOutputMarkupId(true);

add(interactiveList);
}

public List getInteractivePanels() {
return interactivePanels;
}
}

InteractivePanel.html







InteractivePanel.java

// ... imports
public class InteractivePanel extends Panel {
private static final long serialVersionUID = 1L;

public InteractivePanel(String id) {
super(id);

add(new Button("simpleButton"));
}
}








zkn wrote:
> 
> 
> On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:
> 
>> http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html
>> 
>> In this post you said "You found it". Could you please post how did you
>> do it?
>> 
>> Zinovii
> 
> in addPanel()
> 
> replaced 
> 
> panels.add(panel);
> 
> with
> 
> panels.getModelObject().add(panel);
> 
> 
> 
> 
> 
> On 04.12.2009, at 00:17, zkn wrote:
> 
>> found it.
>> 
>> On 03.12.2009, at 16:19, zkn wrote:
>> 
>>> Hi,
>>> 
>>> I'm trying to dynamically add components to an existing ListView but I
>>> can't figure out how to do that. Here is my case:
>>> 
>>> MyPanelContainer  class with markup
>>> 
>>> 
>>> 
>>> 
>>> 
>>>  # add panel 
>>> 
>>> 
>>> and here is how I create the container in the constructor of my page
>>> 
>>> ..
>>> MyPanelContainer container = new MyPanelContainer("panels_list_1");
>>> List panels = new ArrayList();
>>> 
>>> for (int j = 0; j < 5; j++) {
>>> MyPanel panel = new MyPanel("panel");
>>> 
>>> .
>>> 
>>> panels.add(panel);
>>> .
>>> 
>>> 
>>> container.add(new ListView("panels", panels) {
>>> protected void populateItem(ListItem item) {
>>> item.add( item.getModelObject());
>>> }
>>> });
>>> add(Container);
>>> ..
>>> 
>>> This works fine and I can see all  MyPanel inside the container.
>>> 
>>> Now I'm trying to add another MyPanel inside the container on user
>>> click. Here is the constructor of MyPanelContainer
>>> 
>>> public MyPanelContainer(String id) {
>>> super(id);
>>> 
>>> add(new Link("addPanel") {
>>> @Override
>>> public void onClick() {
>>>         addPanel();
>>> }
>>> 
>>> });
>>> .
>>> 
>>> ..
>>> public void addPanel() {
>>> 
>>> ListView< MyPanel > panels = (ListView< MyPanel >) 
>>> get("panels");
>>> 
>>> MyPanel panel = new MyPanel("panel");
>>> ...
>>> panels.add(panel);
>>> }
>>> 
>>> Basically addPanel() does the same thing as in page constructor to add
>>> panels to the list but nothing shows up.
>>> 
>>> Thanks in advance for your help
>>> 
>>> Ozkan
>>> 
>> 
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/dynamically-adding-components-to-a-ListView-tp26626657p27289986.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: dynamically adding components to a ListView

2010-01-23 Thread zdmytriv

I think you meant 
container.getModelObject().add(panel);





zdmytriv wrote:
> 
> panels.getModelObject().add(panel);
> 
> panels is ArrayList and it doesn't have getModelObject() method.
> 
> 
> 
> 
> zkn wrote:
>> 
>> 
>> On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:
>> 
>>> http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html
>>> 
>>> In this post you said "You found it". Could you please post how did you
>>> do it?
>>> 
>>> Zinovii
>> 
>> in addPanel()
>> 
>> replaced 
>> 
>> panels.add(panel);
>> 
>> with
>> 
>> panels.getModelObject().add(panel);
>> 
>> 
>> 
>> 
>> 
>> On 04.12.2009, at 00:17, zkn wrote:
>> 
>>> found it.
>>> 
>>> On 03.12.2009, at 16:19, zkn wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I'm trying to dynamically add components to an existing ListView but I
>>>> can't figure out how to do that. Here is my case:
>>>> 
>>>> MyPanelContainer  class with markup
>>>> 
>>>> 
>>>>
>>>>
>>>>
>>>> # add panel 
>>>> 
>>>> 
>>>> and here is how I create the container in the constructor of my page
>>>> 
>>>> ..
>>>> MyPanelContainer container = new MyPanelContainer("panels_list_1");
>>>> List panels = new ArrayList();
>>>> 
>>>> for (int j = 0; j < 5; j++) {
>>>>MyPanel panel = new MyPanel("panel");
>>>>
>>>>.
>>>>
>>>>panels.add(panel);
>>>> .
>>>> 
>>>> 
>>>> container.add(new ListView("panels", panels) {
>>>>protected void populateItem(ListItem item) {
>>>>item.add( item.getModelObject());
>>>>}
>>>> });
>>>> add(Container);
>>>> ..
>>>> 
>>>> This works fine and I can see all  MyPanel inside the container.
>>>> 
>>>> Now I'm trying to add another MyPanel inside the container on user
>>>> click. Here is the constructor of MyPanelContainer
>>>> 
>>>> public MyPanelContainer(String id) {
>>>>super(id);
>>>>
>>>>    add(new Link("addPanel") {
>>>>@Override
>>>>public void onClick() {
>>>>addPanel();
>>>>}
>>>>
>>>>});
>>>> .
>>>> 
>>>> ..
>>>> public void addPanel() {
>>>>
>>>>ListView< MyPanel > panels = (ListView< MyPanel >) 
>>>> get("panels");
>>>>
>>>>MyPanel panel = new MyPanel("panel");
>>>>...
>>>>panels.add(panel);
>>>>}
>>>> 
>>>> Basically addPanel() does the same thing as in page constructor to add
>>>> panels to the list but nothing shows up.
>>>> 
>>>> Thanks in advance for your help
>>>> 
>>>> Ozkan
>>>> 
>>> 
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/dynamically-adding-components-to-a-ListView-tp26626657p27289411.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: dynamically adding components to a ListView

2010-01-23 Thread zdmytriv

panels.getModelObject().add(panel);

panels is ArrayList and it doesn't have getModelObject() method.





zkn wrote:
> 
> 
> On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:
> 
>> http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html
>> 
>> In this post you said "You found it". Could you please post how did you
>> do it?
>> 
>> Zinovii
> 
> in addPanel()
> 
> replaced 
> 
> panels.add(panel);
> 
> with
> 
> panels.getModelObject().add(panel);
> 
> 
> 
> 
> 
> On 04.12.2009, at 00:17, zkn wrote:
> 
>> found it.
>> 
>> On 03.12.2009, at 16:19, zkn wrote:
>> 
>>> Hi,
>>> 
>>> I'm trying to dynamically add components to an existing ListView but I
>>> can't figure out how to do that. Here is my case:
>>> 
>>> MyPanelContainer  class with markup
>>> 
>>> 
>>> 
>>> 
>>> 
>>>  # add panel 
>>> 
>>> 
>>> and here is how I create the container in the constructor of my page
>>> 
>>> ..
>>> MyPanelContainer container = new MyPanelContainer("panels_list_1");
>>> List panels = new ArrayList();
>>> 
>>> for (int j = 0; j < 5; j++) {
>>> MyPanel panel = new MyPanel("panel");
>>> 
>>> .
>>> 
>>> panels.add(panel);
>>> .
>>> 
>>> 
>>> container.add(new ListView("panels", panels) {
>>> protected void populateItem(ListItem item) {
>>> item.add( item.getModelObject());
>>> }
>>> });
>>> add(Container);
>>> ..
>>> 
>>> This works fine and I can see all  MyPanel inside the container.
>>> 
>>> Now I'm trying to add another MyPanel inside the container on user
>>> click. Here is the constructor of MyPanelContainer
>>> 
>>> public MyPanelContainer(String id) {
>>> super(id);
>>> 
>>> add(new Link("addPanel") {
>>> @Override
>>> public void onClick() {
>>> addPanel();
>>>             }
>>> 
>>> });
>>> .
>>> 
>>> ..
>>> public void addPanel() {
>>> 
>>> ListView< MyPanel > panels = (ListView< MyPanel >) 
>>> get("panels");
>>> 
>>> MyPanel panel = new MyPanel("panel");
>>> ...
>>> panels.add(panel);
>>> }
>>> 
>>> Basically addPanel() does the same thing as in page constructor to add
>>> panels to the list but nothing shows up.
>>> 
>>> Thanks in advance for your help
>>> 
>>> Ozkan
>>> 
>> 
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/dynamically-adding-components-to-a-ListView-tp26626657p27289281.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: dynamically adding components to a ListView

2010-01-22 Thread Pedro Santos
You are putting view objects inside the model of other view object. Models
are meant to keep your application domain data, and over that you create
your view. So:
For what MyPanel was designed?
1 - For present MyData

container.add(new ListView("panels", panels) {
   protected void populateItem(ListItem item) {
   item.add( new MyPanel("panel", item.getModelObject()));
   }
});

then you write:
panels.getModelObject().add(new MyData());
more some code to update panels like
target.addComponent(container);

2 - For present some static markup on template
so consider to use an less sophisticated repeater, like RepeatingView


On Fri, Jan 22, 2010 at 1:04 PM, zkn  wrote:

>
> On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:
>
> >
> http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html
> >
> > In this post you said "You found it". Could you please post how did you
> do it?
> >
> > Zinovii
>
> in addPanel()
>
> replaced
>
> panels.add(panel);
>
> with
>
> panels.getModelObject().add(panel);
>
>
>
>
>
> On 04.12.2009, at 00:17, zkn wrote:
>
> > found it.
> >
> > On 03.12.2009, at 16:19, zkn wrote:
> >
> >> Hi,
> >>
> >> I'm trying to dynamically add components to an existing ListView but I
> can't figure out how to do that. Here is my case:
> >>
> >> MyPanelContainer  class with markup
> >>
> >> 
> >>  
> >>  
> >>  
> >>  add panel
> >> 
> >>
> >> and here is how I create the container in the constructor of my page
> >>
> >> ..
> >> MyPanelContainer container = new MyPanelContainer("panels_list_1");
> >> List panels = new ArrayList();
> >>
> >> for (int j = 0; j < 5; j++) {
> >>  MyPanel panel = new MyPanel("panel");
> >>
> >>  .
> >>
> >>  panels.add(panel);
> >> .
> >>
> >>
> >> container.add(new ListView("panels", panels) {
> >>  protected void populateItem(ListItem item) {
> >>  item.add( item.getModelObject());
> >>  }
> >> });
> >> add(Container);
> >> ..
> >>
> >> This works fine and I can see all  MyPanel inside the container.
> >>
> >> Now I'm trying to add another MyPanel inside the container on user
> click. Here is the constructor of MyPanelContainer
> >>
> >> public MyPanelContainer(String id) {
> >>  super(id);
> >>  
> >>  add(new Link("addPanel") {
> >>  @Override
> >>  public void onClick() {
> >>  addPanel();
> >>  }
> >>
> >>  });
> >> .
> >>
> >> ..
> >> public void addPanel() {
> >>
> >>  ListView< MyPanel > panels = (ListView< MyPanel >)
> get("panels");
> >>
> >>  MyPanel panel = new MyPanel("panel");
> >>  ...
> >>  panels.add(panel);
> >>  }
> >>
> >> Basically addPanel() does the same thing as in page constructor to add
> panels to the list but nothing shows up.
> >>
> >> Thanks in advance for your help
> >>
> >> Ozkan
> >>
> >
>
>


-- 
Pedro Henrique Oliveira dos Santos


Re: dynamically adding components to a ListView

2010-01-22 Thread Alexander Monakhov
Hi, guys.

Just use PropertyModel.

Instead of this:


container.add(new ListView("panels", panels) { ... }


use this


container.add( new ListView>( this, "panels" ) ) { ... }


where 'this' is referenced to instance of class that contains list of panels
as it's property.
And check PropertyModel description at Doc API.


Best regards, Alexander.


Re: dynamically adding components to a ListView

2010-01-22 Thread zkn

On 22.01.2010, at 03:18, vasil.pup...@gmail.com wrote:

> http://old.nabble.com/dynamically-adding-components-to-a-ListView-td26626657.html
> 
> In this post you said "You found it". Could you please post how did you do it?
> 
> Zinovii

in addPanel()

replaced 

panels.add(panel);

with

panels.getModelObject().add(panel);





On 04.12.2009, at 00:17, zkn wrote:

> found it.
> 
> On 03.12.2009, at 16:19, zkn wrote:
> 
>> Hi,
>> 
>> I'm trying to dynamically add components to an existing ListView but I can't 
>> figure out how to do that. Here is my case:
>> 
>> MyPanelContainer  class with markup
>> 
>> 
>>  
>>  
>>  
>>  add panel
>> 
>> 
>> and here is how I create the container in the constructor of my page
>> 
>> ..
>> MyPanelContainer container = new MyPanelContainer("panels_list_1");
>> List panels = new ArrayList();
>> 
>> for (int j = 0; j < 5; j++) {
>>  MyPanel panel = new MyPanel("panel");
>>  
>>  .
>>  
>>  panels.add(panel);
>> .
>> 
>> 
>> container.add(new ListView("panels", panels) {
>>  protected void populateItem(ListItem item) {
>>  item.add( item.getModelObject());
>>  }
>> });
>> add(Container);
>> ..
>> 
>> This works fine and I can see all  MyPanel inside the container.
>> 
>> Now I'm trying to add another MyPanel inside the container on user click. 
>> Here is the constructor of MyPanelContainer
>> 
>> public MyPanelContainer(String id) {
>>  super(id);
>>  
>>  add(new Link("addPanel") {
>>  @Override
>>  public void onClick() {
>>  addPanel();
>>  }
>>  
>>  });
>> .
>> 
>> ..
>> public void addPanel() {
>>  
>>  ListView< MyPanel > panels = (ListView< MyPanel >) 
>> get("panels");
>>  
>>  MyPanel panel = new MyPanel("panel");
>>  ...
>>  panels.add(panel);
>>  }
>> 
>> Basically addPanel() does the same thing as in page constructor to add 
>> panels to the list but nothing shows up.
>> 
>> Thanks in advance for your help
>> 
>> Ozkan
>> 
> 



Re: dynamically adding components to a ListView

2009-12-03 Thread zkn
found it.

On 03.12.2009, at 16:19, zkn wrote:

> Hi,
> 
> I'm trying to dynamically add components to an existing ListView but I can't 
> figure out how to do that. Here is my case:
> 
> MyPanelContainer  class with markup
> 
> 
>   
>   
>   
>   add panel
> 
> 
> and here is how I create the container in the constructor of my page
> 
> ..
> MyPanelContainer container = new MyPanelContainer("panels_list_1");
> List panels = new ArrayList();
> 
> for (int j = 0; j < 5; j++) {
>   MyPanel panel = new MyPanel("panel");
>   
>   .
>   
>   panels.add(panel);
> .
> 
> 
> container.add(new ListView("panels", panels) {
>   protected void populateItem(ListItem item) {
>   item.add( item.getModelObject());
>   }
> });
> add(Container);
> ..
> 
> This works fine and I can see all  MyPanel inside the container.
> 
> Now I'm trying to add another MyPanel inside the container on user click. 
> Here is the constructor of MyPanelContainer
> 
> public MyPanelContainer(String id) {
>   super(id);
>   
>   add(new Link("addPanel") {
>   @Override
>   public void onClick() {
>   addPanel();
>   }
>   
>   });
> .
> 
> ..
> public void addPanel() {
>   
>   ListView< MyPanel > panels = (ListView< MyPanel >) 
> get("panels");
>   
>   MyPanel panel = new MyPanel("panel");
>   ...
>   panels.add(panel);
>   }
> 
> Basically addPanel() does the same thing as in page constructor to add panels 
> to the list but nothing shows up.
> 
> Thanks in advance for your help
> 
> Ozkan
> 


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



dynamically adding components to a ListView

2009-12-03 Thread zkn
Hi,

I'm trying to dynamically add components to an existing ListView but I can't 
figure out how to do that. Here is my case:

MyPanelContainer  class with markup





add panel


and here is how I create the container in the constructor of my page

...
MyPanelContainer container = new MyPanelContainer("panels_list_1");
List panels = new ArrayList();

for (int j = 0; j < 5; j++) {
MyPanel panel = new MyPanel("panel");

.

panels.add(panel);
}

container.add(new ListView("panels", panels) {
protected void populateItem(ListItem item) {
item.add( item.getModelObject());
}
});
add(Container);
...

This works fine and I can see all  MyPanel inside the container.

Now I'm trying to add another MyPanel inside the container on user click. Here 
is the constructor of MyPanelContainer

public MyPanelContainer(String id) {
super(id);

add(new Link("addPanel") {
@Override
public void onClick() {
addPanel();
}

});
}
...
public void addPanel() {

ListView< MyPanel > panels = (ListView< MyPanel >) 
get("panels");

MyPanel panel = new MyPanel("panel");
...
panels.add(panel);
}

Basically addPanel() does the same thing as in page constructor to add panels 
to the list but nothing shows up.

Thanks in advance for your help

Ozkan