Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You

...

can

...

use

...

the

...

same

...

technique

...

described

...

in

...

http://cwiki.apache.org/WICKET/forms-with-dynamic-elements.html

...

Image Added to

...

dynamically

...

add

...

components

...

to

...

a

...

page.

...

Wicket

...

xhtml

...

tag

...

<wicket:container>

...

comes

...

in

...

handy

...

on

...

these

...

cases.

...

Bellow

...

is

...

a

...

simple

...

example

...

of

...

a

...

page

...

with

...

dynamic

...

components:

...

MasterPage.java

{
Code Block
}
public class MasterPage extends WebPage
{
	public MasterPage()
	{
		List<Component> components = new ArrayList<Component>();
		components.add( new Component() );
		components.add( new Component() );
		add( new ListView( "components", components )
		{			
			protected void populateItem(ListItem item)
			{
				item.add( (Component)item.getModelObject() );
			}
		});
	}
}
{code}

MasterPage.html

Code Block
html
html

{code:html}
<html>
<body>
	<wicket:container wicket:id="components">
		<wicket:container wicket:id="component"/>
	</wicket:container> 
</body>
</html>
{code:html}

Component.java

{
Code Block
}
public class Component extends Panel
{
	public Component()
	{
		super( "component" );
                add( new Label( "name" ), "component 1" );
	}
}
Code Block
html
html


Component.html{code}

{code:html}
<html>
<wicket:panel>
	<span wicket:id="name">component name</span>
</wicket:panel>
</html>
{code:html}