I'd rather use RepeatingView, together with a utility method for
adding the menu items. A ListView refreshes the menu on each render,
and your menu is rather static.

something like:

RepeatingView rv = new RepeatingView("menu");

addMenuItem(rv, "Name of menuitem", PageThatIsLinkedTo.class);

private void addMenuItem(RepeatingView rv, String labelText, Class<?
extends WebPage> page) {
    BookmarkablePageLink link = new BookmarkablePageLink(rv.newChildId(), page);
    link.add(new Label("label", labelText));
    rv.add(link);
}

On Wed, Oct 28, 2009 at 9:58 AM, Lester Chua <cicowic...@gmail.com> wrote:
> Thanks Martijn,
>
> I think I stumbled on the solution just before I saw your hint =).
>
> Please help me take a look and see if the way I approached the problem is
> too cumbersome.
>
> Basically my HTML, in my NavigationalPanel.html:
>
>   <span wicket:id="links">
>       <a href=# wicket:id="link"><span
> wicket:id="displayName"></span></a><br/>
>   </span>
>
> Java, I have a NavigationPanel:
>
> public class NavigationPanel extends Panel {
>
>   public NavigationPanel(String id) {
>       super(id);
>             List<CustomLinkedPage> links = new
> ArrayList<CustomLinkedPage>();
>       links.add(new CustomLinkedPage("Home Page", HomePage.class));
>       links.add(new CustomLinkedPage("Some Page", SomePage.class));
>           add(new ListView("links", links) {
>           public void populateItem(final ListItem item) {
>               final CustomLinkedPage link = (CustomLinkedPage)
> item.getModelObject();
>               item.add(new CustomBookmarkablePageLink("link",
> link.getPageClass(), link.getDisplayName()));
>           }
>       });
>         }
>
>   class CustomLinkedPage {
>       Class pageClass;
>       String displayName;
>             public CustomLinkedPage(String displayName, Class pageClass) {
>           this.pageClass = pageClass;
>           this.displayName = displayName;
>       }
>
>       // remved getters and setters for less verbosity         }
>       class CustomBookmarkablePageLink extends BookmarkablePageLink {
>
>       public CustomBookmarkablePageLink(String id, Class pageClass, String
> displayName) {
>           super(id, pageClass);
>           this.displayName = displayName;
>           add(new Label("displayName", displayName));
>
>       }
>
>       String displayName;
>
>       // remved getters and setters for less verbosity         }
>
> }
>
> I tried subclassing BookmarkablePageLink directly without CustomLinkedPage
> but it created "inelegant" code that made me put "link" at new instance time
> which I hated, because the "link" reference seems to be in the wrong scope.
>
> Spent lots of time researching and had a hard time figuring this out. The
> amount and quality of documents in Wicket is not rich enough for newbies to
> get up to speed quickly enough. Having said that, I totally love the
> component object model. No other framework (I worked with quite a number of
> them) lets me subclass so nicely and having such neat code in html! =)
>
> Regards,
>
> Lester
>
>
> Martijn Dashorst wrote:
>>
>> Use normal BookmarkablePageLinks instead of <wicket:link>. The latter
>> is just convenience and only supports the most basic stuff.
>>
>> Martijn
>>
>> On Wed, Oct 28, 2009 at 7:55 AM, Lester Chua <cicowic...@gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> I think I'm the minority here but I like how wicket's default behaviour
>>> of
>>> placing html with the page.
>>> I have a problem that I hope someone has encountered and solved before.
>>>
>>> Basically, I current my source structure to be as follows
>>>
>>> com/acme/web/HomePage.java
>>> com/acme/web/HomePage.html
>>> com/acme/web/SomePage.java
>>> com/acme/web/SomePage.html
>>> com/acme/panel/NavPanel.java
>>> com/acme/panel/NavPanel.html
>>>
>>> In my NavPanel.html, I have some links to HomePage.html as well as
>>> NavPanel.html. <a href="SomePage.html">Some Page</a>
>>> This works. The debug shows that Wicket is automatically figuring which
>>> page
>>> to link to link to.
>>>
>>> But when I do the following
>>>
>>> com/acme/proga/SomePage.java
>>> com/acme/proga/SomePage.html
>>> com/acme/home/HomePage.java
>>> com/acme/home/HomePage.html
>>> com/acme/panel/NavPanel.java
>>> com/acme/panel/NavPanel.html
>>>
>>> Wicket debug warning shows that it is unable to figure what Page class to
>>> give <a href="SomePage.html">Some Page</a>.
>>> WARN  org.apache.wicket.markup.resolver.AutoLinkResolver - Did not find
>>> corresponding java class: com.acme.home.SomePage
>>>
>>> I am thinking that probably what I'm trying to do is wrong. If so, what
>>> is
>>> the proper way to make the pages available in a Navigator?
>>> I tried building the links dynamically by iterating a list of pages and
>>> getting the paths from there BUT I am stuck trying get a list of Pages of
>>> my
>>> application.
>>>
>>> Is there a way for me to resolve this?
>>>
>>> Thanks in advance.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>>
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.0

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

Reply via email to