Thanks for all your help! I have a basic example working now, and I am trying to fix the last separator as per your suggestions. I put a link object (actually a BookmarkablePageLink) in a list for every page to be in the menu and use those in the populateItem(), like this:

<>    public HomePage()
    {

        List links = new ArrayList();

        links.add(new BookmarkablePageLink("item", HomePage.class));

        links.add(new BookmarkablePageLink("item", HomePage2.class));

        add(new ListView("navigation", links)

        {

            static final long serialVersionUID = 100;

            public void populateItem(final ListItem item)

            {

                final BookmarkablePageLink link = (BookmarkablePageLink) item.getModelObject();

                item.add(link);

                item.add(new Label("separator", " | "));

            }

        });
      

        IModel messageModel = new Model(this.getClass().getSimpleName());

        add(new Label("message", messageModel));

        add(new MessageForm("messageInputForm", messageModel));   

    }

and the HTML:

      <div id="navigation">
         <span wicket:id="navigation">
            <a href="" wicket:id="item">Dummy link</a>
            <span wicket:id="separator" class="separator"> | </span>
         </span>
      </div>

Only, the 'Dummy link' text is not replaced. Do I need to put a label in the anchor to get the text there?
Like this?

      <div id="navigation">
         <span wicket:id="navigation">
            <a href="" wicket:id="item"><span wicket:id="itemTitle">Dummy link</span></a>
            <span wicket:id="separator" class="separator"> | </span>
         </span>
      </div>

If some component is not there, because I don't put in the separator for the last item, what happens to the HTML? Or should I still put the component in there  and set it's visibility to false?

Thanks again,

-Stijn

Phil Kulak wrote:
Oh yea, that's much better.

On 11/2/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
  
In that case, better would be to compare the current index of ListItem
(li.getIndex) with the ListView's size (lv.getViewSize()). That way
you won't have to touch the 'internal' model, and it'll work with
sizes that differ from the underlying model.

Eelco


On 11/2/05, Phil Kulak <[EMAIL PROTECTED]> wrote:
    
So you just need to know when the item you're rendering is the last in
the list? Well, you have access to the list (getList()) and the item
(item.getModelObject()), so it should be pretty straight forward, if
not elegant, to find out if the item is the last in the list.

On 11/1/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
      
Yeah, something like that could work pretty well. I think you should
take a look at how paged lists work (package
wicket.markup.html.navigation.paging).

Eelco

On 11/1/05, Stijn de Witt <[EMAIL PROTECTED]> wrote:
        
 <>Hi all,


 I'm a new user to Wicket. I love what I have seen so far. The HelloWorld
example was very convincing for me to give Wicket a try!


I am trying to create a menu to go above my pages. I have been browsing
through the Wiki and looked at the navigation example. The navigation
example uses borders, but before I delve into those, I thought of trying
something else, and I wonder if you could give me some feedback on it.


I thought I might use a ListView. I think I could add a ListView to my page
that would contain Links to WebPages to create a simple navigation bar. I
found some example code and HTML in the javadoc:


A ListView holds ListItem children. Items can be re-ordered and deleted,
either one at a time or many at a time.

 Example: <tbody>
 <tr wicket:id="rows" class="even">
 <td><span wicket:id="id">Test ID</span></td>
 ...


 Though this example is about a HTML table, ListView is not at all limited
to HTML tables. Any kind of list can be rendered using ListView.

 And the related Java code: add(new ListView("rows", listData)
 {
 public void populateItem(final ListItem item)
 {
 final UserDetails user =
(UserDetails)item.getModelObject();
 item.add(new Label("id", user.getId()));
 }
 });





For a navigation bar I could think of this for the HTML: <div
id="navigation">
 <span class="item" wicket:id="navigationitems">
 <a wicket:id="link" href="">Item</a>
 <span class="separator"> | </span>
 </span>
</div>





But I need some way to identify the last separator in the stylesheet, so I
can hide it. In the example the class "even" is used in the table row, but
how is this updated to "odd" ?


Am I on the right track here? Any suggestions,


Greetings,


-Stijn


          
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

        
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

      
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

    


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

  

Reply via email to