You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by maentele <ma...@gmail.com> on 2007/11/06 15:39:10 UTC

How do I get the current page?

Hi everyone.
I am quite new to Wicket but I start to really like it ;-)
I have a problem on which I spent several hours of research and trying but
it wouldn't solve.

I have a navigation in which the navigationlinks have to be dynamically
added (dependent on which rights the logged-in user has). So I used a
ListView which uses a LoadableDetachableModel to define which links to add
to the navigation.

...
<_li wicket:id="itemList">
  <_a class="menuItem" wicket:id="menuListItem">
    <_span wicket:id="itemName">[itemName]<_/span>
  <_/a>
<_/li>
...

The current page shall have an other CSS-class ("activeMenuItem") .
Therefore the navigation has to know, which page is the current one.

...
if (menuItem.getPage().equals(currentPage)) {
  page.add(new AttributeModifier("class", true, new
Model("activeMenuItem")));
}
...

My question/problem is: how do I get the "currentPage" (the currently active
link)?


I hope the description of the problem is sufficient.

Greetings from Germany
Thomas Jaeckle
-- 
View this message in context: http://www.nabble.com/How-do-I-get-the-current-page--tf4758474.html#a13607965
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: How do I get the current page?

Posted by Al Maw <wi...@almaw.com>.
Martijn Dashorst wrote:
> It doesn't work until after adding the component to the page.

This is true.

So you need something like this (I've modified your variable names to 
make it more obvious what is what):

pageLink.add(new AttributeModifier("class", true,
         new AbstractReadOnlyModel() {
             public Object getObject() {
                 return
                     getPage().getClass().equals(menuItem.getPageClass())
                     ? "activeMenuItem"
                     : AttributeModifier.VALUELESS_ATTRIBUTE_REMOVE;
             }
         }
);

Probably. ;-)

Regards,

Al

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


Re: How do I get the current page?

Posted by Martijn Dashorst <ma...@gmail.com>.
It doesn't work until after adding the component to the page.

Martijn

On 11/6/07, thomas jaeckle <ma...@gmail.com> wrote:
>
>
> Al Maw wrote:
> >
> > Just call Component#getPage()
> >
>
> Shame on me ...
> I thought I tried that once and it didn't work back then ...
> Looks like I did something wrong.
>
> Tanks very much, Al
>
>
> Thomas Jaeckle
> --
> View this message in context: http://www.nabble.com/How-do-I-get-the-current-page--tf4758474.html#a13608876
> 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
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta4/

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


Re: How do I get the current page?

Posted by thomas jaeckle <ma...@gmail.com>.

Al Maw wrote:
> 
> Just call Component#getPage()
> 

Shame on me ...
I thought I tried that once and it didn't work back then ...
Looks like I did something wrong.

Tanks very much, Al


Thomas Jaeckle
-- 
View this message in context: http://www.nabble.com/How-do-I-get-the-current-page--tf4758474.html#a13608876
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: How do I get the current page?

Posted by Martijn Dashorst <ma...@gmail.com>.
if(item.getModelObject().getDestPage().equals(getPage().getClass())) {
    item.add(AttributeModifier.append("class", "active"));
}

Martijn


On Tue, Dec 30, 2014 at 7:48 PM, K <ko...@gmail.com> wrote:
> Hi Aksarben
>
> i have a web application in which there are six links in main menu. i want
> my app to highlight the link that is selected.
>
> <http://apache-wicket.1842946.n4.nabble.com/file/n4668907/Capture.png>
>
> My code:
>
>
> List<HeaderListItems>  is list of pojo item. my pojo has two fields
> label(String) and destPage(Class)
>
> My Mark-up:
>
>
>
>
> -----
> K
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-do-I-get-the-current-page-tp1851661p4668907.html
> Sent from the Users forum 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
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

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


Re: How do I get the current page?

Posted by K <ko...@gmail.com>.
Hi Aksarben

i have a web application in which there are six links in main menu. i want
my app to highlight the link that is selected.

<http://apache-wicket.1842946.n4.nabble.com/file/n4668907/Capture.png> 

My code:


List<HeaderListItems>  is list of pojo item. my pojo has two fields
label(String) and destPage(Class) 

My Mark-up: 

   


-----
K
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-do-I-get-the-current-page-tp1851661p4668907.html
Sent from the Users forum 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: How do I get the current page?

Posted by "Richard W. Adams" <RW...@UP.COM>.
Not inclined to click on untrusted links, for security reasons. When you 
say "get the current page", where do you want to get it FROM? If you're in 
the page code itself, it's just "this." If you want it from somewhere 
else, describe what you're trying to achieve.




From:   K <ko...@gmail.com>
To:     users@wicket.apache.org
Date:   12/30/2014 09:58 AM
Subject:        Re: How do I get the current page?



Hi i am working on the same thing and i have not been able to achieve the
desired outcome. 

i would appericiate any suggestions. i have posted complete details here

http://apache-wicket.1842946.n4.nabble.com/current-page-highlighting-td4668902.html

<
http://apache-wicket.1842946.n4.nabble.com/current-page-highlighting-td4668902.html
> 

Thanks.

-----
K
--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/How-do-I-get-the-current-page-tp1851661p4668903.html

Sent from the Users forum 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




**

This email and any attachments may contain information that is confidential and/or privileged for the sole use of the intended recipient.  Any use, review, disclosure, copying, distribution or reliance by others, and any forwarding of this email or its contents, without the express permission of the sender is strictly prohibited by law.  If you are not the intended recipient, please contact the sender immediately, delete the e-mail and destroy all copies.
**

Re: How do I get the current page?

Posted by K <ko...@gmail.com>.
Hi i am working on the same thing and i have not been able to achieve the
desired outcome. 

i would appericiate any suggestions. i have posted complete details here

http://apache-wicket.1842946.n4.nabble.com/current-page-highlighting-td4668902.html
<http://apache-wicket.1842946.n4.nabble.com/current-page-highlighting-td4668902.html>  

Thanks.

-----
K
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-do-I-get-the-current-page-tp1851661p4668903.html
Sent from the Users forum 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: How do I get the current page?

Posted by Al Maw <wi...@almaw.com>.
maentele wrote:
> My question/problem is: how do I get the "currentPage" (the currently active
> link)?

Just call Component#getPage()

Regards,

Al

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