You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ArthIT <ar...@innovations.de> on 2008/05/06 16:01:20 UTC
n-Level Page Navigation. How to implement?
Hi everybody,
We’re using wicket at our new project.
I wonder how i can dynamically generate a page navigation with several
levels the best way.
The navigation should know where it is ;) i.e.
if the user navigates to myserver/navpoint the “navpoint” Bookmarkable Link
should be
highlighted.
Lets assume I have the following navigation:
"MainSectionA" has Childs "SubSectionAA" and "SubSectionAB"
"MainSectionB" has only one Child "SubSectionB"
MountingPoints are:
MainSectionA -> /mainA
SubSectionAA -> /mainA/subAA
SubSectionAB -> /mainA/subAB
MainSectionB -> /mainB
SubSectionB -> /subB
If the user clicks on /mainA i want the subnavigation to be replaced with
the childs of /mainA thus subAA and subAB and the default page of /mainA
should be opened.
If the user navigates to /mainA/subAB I want the links mainA and subAB be
highlighted and not clickable.
This way a can provide a breadcrumb navigation too.
I want to have all Navigation links to be BookmarkablePageLinks. But
BookmarkablePageLinks.onClick() Method is final and I can’t do sth like
this:
new BookmarkablePageLink(…){
public void onClick() {
MyNavPanel.this.currentLink = this;
}
}
How can I determine globally on which Page the user currently is or to which
Page the current request was targeted? Independent of the
mountingStrategy... It should work without mounting at all.
If I use PageLink instead of BookmarkablePageLink I can override the
onClick() Method, but the mountedURLs aren’t forced.
Thank you very much for your advices. I hope you can follow my intend.
Our project aims to automatically generate WebUIs out of BusinessRules, just
for your information ;)
--
View this message in context: http://www.nabble.com/n-Level-Page-Navigation.-How-to-implement--tp17083157p17083157.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: n-Level Page Navigation. How to implement?
Posted by ArthIT <ar...@innovations.de>.
Thank you very much igor! I'll try this today.
igor.vaynberg wrote:
>
> you will have to fill in some blanks
>
> ...
>
>
>
--
View this message in context: http://www.nabble.com/n-Level-Page-Navigation.-How-to-implement--tp17083157p17142586.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: n-Level Page Navigation. How to implement?
Posted by Igor Vaynberg <ig...@gmail.com>.
you will have to fill in some blanks
public class MenuItem
{
private MenuItem parent;
private List<MenuItem> children;
private IModel label;
private Class<? extends Page>
}
public class Menu extends Panel
{
private boolean refresh = true;
public MenuItem getPageItem()
{
return ((entrypage)getPage()).getMenuItem();
}
@Override
protected void onBeforeRender()
{
if (refresh)
{
if (get("menu") != null)
{
remove("menu");
}
MenuItem item = getPageItem();
ArrayList<MenuItem> stack = new ArrayList<MenuItem>();
if (!item.getChildren().isEmpty())
{
stack.add(0, item);
}
item = item.getParent();
while (item != null)
{
stack.add(0, item);
item = item.getParent();
}
add(new MenuItemFragment("menu", stack, 0));
refresh = false;
}
super.onBeforeRender();
}
private static class ItemLink extends BookmarkablePageLink
{
private final boolean selected;
public ItemLink(String id, Class<?> pageClass, boolean selected)
{
super(id, pageClass);
this.selected = selected;
}
@Override
protected void onComponentTag(ComponentTag tag)
{
super.onComponentTag(tag);
if (selected)
{
tag.put("class", "on");
}
}
}
private class MenuItemFragment extends Fragment
{
public MenuItemFragment(String id, List<MenuItem> stack, int index)
{
super(id, "menu-panel", Menu.this);
MenuItem current = stack.get(index);
StringBuilder stackPrefix = new StringBuilder();
for (int i = 0; i <= index; i++)
{
stackPrefix.append(stack.get(i).getMarkupId());
stackPrefix.append("__");
}
final String stackPrefixId = stackPrefix.toString();
RepeatingView items = new RepeatingView("items");
add(items);
for (MenuItem child : current.getChildren())
{
if (!child.isVisible(security))
{
continue;
}
final boolean selected = stack.contains(child) ||
child == getPageItem();
WebMarkupContainer item = new
WebMarkupContainer(items.newChildId());
item.setMarkupId(stackPrefixId + child.getMarkupId());
item.setOutputMarkupId(true);
items.add(item);
Link link = new ItemLink("link", child.getPageClass(),
selected);
item.add(link);
link.add(new Label("label", child.getLabel()));
WebMarkupContainer submenu = new WebMarkupContainer("submenu");
item.add(submenu);
if (selected && !child.getChildren().isEmpty())
{
submenu.add(new MenuItemFragment("items", stack,
index + 1));
}
else
{
submenu.setVisible(false);
}
}
}
}
}
<wicket:panel>
<ul id="nav">
<wicket:container wicket:id="menu"></wicket:container>
</ul>
<wicket:fragment wicket:id="menu-panel">
<li wicket:id="items">
<a wicket:id="link"><span wicket:id="label">[[ menu item label ]]</span></a>
<ul wicket:id="submenu">
<wicket:container wicket:id="items"></wicket:container>
</ul>
</li>
</wicket:fragment>
</wicket:panel>
public abstract class entrypage extends webpage {
entrypage() { add(new menu("menu")); }
public abstract MenuItem getMenuItem();
}
-igor
On Thu, May 8, 2008 at 11:25 PM, ArthIT <ar...@innovations.de> wrote:
>
> Nobody has a hint?
> --
> View this message in context: http://www.nabble.com/n-Level-Page-Navigation.-How-to-implement--tp17083157p17142043.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: n-Level Page Navigation. How to implement?
Posted by ArthIT <ar...@innovations.de>.
Nobody has a hint?
--
View this message in context: http://www.nabble.com/n-Level-Page-Navigation.-How-to-implement--tp17083157p17142043.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org