Re: Dunamic neted List Views

2010-10-11 Thread Arjun Dhar

ok as usual I bet myself to it, here is the answer :

Basically use a ListView over a ListView!


@Override
public void renderMenu() {
IModelMenuItemState modelState = getState();
final MenuItemState rootState = modelState.getObject();

//Add all menu state objects as Ordered List / sub lists

//Model MenuItems per Level (layer) 
ListListMenuItemState menuLayers = new
ArrayListListMenuItemState();   
{
MenuItemState state = rootState;
do {
menuLayers.add(state.getChildren());
state = menuHelper.getFirstFertileChild(state);
} while(state != null); //Keep going (DFS) till Menu 
node bares no child
}

//Render:
final ListViewListMenuItemState multiLevelMenuContainer = 
new
ListViewListMenuItemState(menuContainer, menuLayers) {
@Override
protected void populateItem(final 
ListItemListMenuItemState
menuLayerComponent) {
//Add levels layer by layer (each layer in a 
different div on mark-up.
Items in same layer get same styling
//TODO : Work on mark-up styling for final 
render details.
menuLayerComponent.add(new 
ListViewMenuItemState(menuItems,
menuLayerComponent.getModelObject()) {
@Override
public void populateItem(final 
ListItemMenuItemState
childMenuComponent) {
final MenuItemState 
childItemState =
childMenuComponent.getModelObject();

childMenuComponent.add(new Label(name,
childItemState.getMenuItem().getName()));

childMenuComponent.add(new StaticImage(img, 
new 
Model(childItemState.getMenuItem().getImg())) );

childMenuComponent.add(new StaticImage(rollOverImg, 
new 
Model(childItemState.getMenuItem().getRollOverImg())) );

childMenuComponent.add(new Label(selected,
Boolean.toString(childItemState.isSelected(;
}
}); 
}

};
add(multiLevelMenuContainer);
}


Markup code looks like this:

table wicket:id=menuContainer border='1'
trtd
ul wicket:id=menuItems
li/li
li /li
li /li
li /li
/ul
/td/tr
/table

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Dunamic-neted-List-Views-tp2970644p2989287.html
Sent from the Users forum 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



Dunamic neted List Views

2010-10-10 Thread Arjun Dhar

Hi,
 I just developed a Menu; that is nested many levels. At the point of
rendering in my code I'm slightly confused. ok, Let the code talk:

(The following code assumes a domain model with MenuItemState which is
hiararchial has children. And each child node is a MenuItemState. The
child can either have null or further children.
The renderMenu() is called by a Panel.)


@Override
public void renderMenu() {
IModelMenuItemState modelState = getState();
MenuItemState state = modelState.getObject();
//Add all menu state objects as Ordered List / sub lists.

add(new ListViewMenuItemState(menuItems, 
state.getChildren()) {
@Override
public void populateItem(final ListItemMenuItemState
wrappedChildComponent) {
final MenuItemState childItemState =
wrappedChildComponent.getModelObject();
wrappedChildComponent.add(new Label(name,
childItemState.getMenuItem().getName()));
wrappedChildComponent.add(new 
StaticImage(img, 
new 
Model(childItemState.getMenuItem().getImg())) );
wrappedChildComponent.add(new 
StaticImage(rollOverImg, 
new 
Model(childItemState.getMenuItem().getRollOverImg())) );
wrappedChildComponent.add(new Label(selected,
Boolean.toString(childItemState.isSelected(;
}
});

.. now I can add the children like:

wrappedChildComponent.add(new
ListView(nestedItemsFor_+childItemState.getMenuItem().getName(), 
 childItemState.getChildren() {...} );


Code: Current markup code::

table
tr wicket:id=menuItems
td/td
td /td
td /td
td /td
/tr
/table

..but how will the above markup code generate the name for the nestedItem
Component  know if the item has children. Should I just inject markup
mylsef or using ListView can achieve this cleanly?
I want to introduce nesting from my Model into the markup using ListView!

Ideas?! (I dont wanna keep posting answers to my own questions so quick
replies would help :) ) heh

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Dunamic-neted-List-Views-tp2970644p2970644.html
Sent from the Users forum 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: Dunamic neted List Views

2010-10-10 Thread Arjun Dhar

!...@#$ The subject was meant to be Dynamic Nested List Views! Apologies
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Dunamic-neted-List-Views-tp2970644p2970646.html
Sent from the Users forum 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