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
>>
>> <table>
>> <tr>
>> <td> # Add Panel </td>
>> </tr>
>> <tr wicket:id="interactiveListView">
>> <td>
>>
>> </td>
>> </tr>
>> </table>
>>
>> InteractivePanelPage.java
>>
>> // ... imports
>> public class InteractivePanelPage extends WebPage {
>> public LinkedList<InteractivePanel> interactivePanels = new
>> LinkedList<InteractivePanel>();
>>
>> private ListView<InteractivePanel> interactiveList;
>>
>> public InteractivePanelPage() {
>> add(new AjaxLink<String>("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<InteractivePanel>("interactiveListView",
>> new PropertyModel<List<InteractivePanel>>(this,
>> "interactivePanels")) {
>> private static final long serialVersionUID = 1L;
>>
>> @Override
>> protected void populateItem(ListItem<InteractivePanel> item) {
>> item.add(item.getModelObject());
>> }
>> };
>>
>> interactiveList.setOutputMarkupId(true);
>>
>> add(interactiveList);
>> }
>>
>> public List<InteractivePanel> getInteractivePanels() {
>> return interactivePanels;
>> }
>> }
>>
>> InteractivePanel.html
>>
>> <html xmlns:wicket>
>> <wicket:panel>
>> <input type="button" value="BLAAA" wicket:id="simpleButton"/>
>> </wicket:panel>
>> </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, [email protected] 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
>>>>>
>>>>> <wicket:panel>
>>>>> <wicket:container wicket:id="panels">
>>>>> <wicket:container wicket:id="panel" />
>>>>> </wicket:container>
>>>>> # add panel
>>>>> </wicket:panel>
>>>>>
>>>>> and here is how I create the container in the constructor of my page
>>>>>
>>>>> ..
>>>>> MyPanelContainer container = new MyPanelContainer("panels_list_1");
>>>>> List<MyPanel> panels = new ArrayList<MyPanel>();
>>>>>
>>>>> for (int j = 0; j < 5; j++) {
>>>>> MyPanel panel = new MyPanel("panel");
>>>>>
>>>>> .....
>>>>>
>>>>> panels.add(panel);
>>>>> .
>>>>>
>>>>>
>>>>> container.add(new ListView<MyPanel>("panels", panels) {
>>>>> protected void populateItem(ListItem<MyPanel> 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: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>
>
> To our success!
>
> Mystic Coders, LLC | Code Magic | www.mysticcoders.com
>
> ANDREW LOMBARDI | [email protected]
> 2321 E 4th St. Ste C-128, Santa Ana CA 92705
> ofc: 714-816-4488
> fax: 714-782-6024
> cell: 714-697-8046
> linked-in: http://www.linkedin.com/in/andrewlombardi
> twitter: http://www.twitter.com/kinabalu
>
> Eco-Tip: Printing e-mails is usually a waste.
>
> ========================================================
> This message is for the named person's use only. You must not, directly or
> indirectly, use,
> disclose, distribute, print, or copy any part of this message if you are
> not the intended recipient.
> ========================================================
>
>
>
--
View this message in context:
http://old.nabble.com/dynamically-adding-components-to-a-ListView-tp26626657p27290113.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]