You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Major Péter <ma...@sch.bme.hu> on 2009/02/02 19:12:53 UTC

How to change BookmarkablePageLink Model?

Hi all,

In my project, i would like to change the link for an image in different 
pages, where the image is in the header (which is in the base class of 
pages).
The code snippet i tried:

//This is my base class for the other pages
public class PageTemplate extends WebPage {

...
//The base class constructor
public PageTemplate(){
WebMarkupContainer headerLabelContainer = new 
WebMarkupContainer("headerLabelContainer");
        add(headerLabelContainer);
//I have to set a default value, so it would be declared for wicket, so 
when i have a page, which i don't want to contain this imagelink, there 
won't be a problem
        headerLabelContainer.add(new BookmarkablePageLink("detailView", 
ShowUser.class)).setVisible(false);
                                    }
...

public void setHeaderDetailViewLink(Class pageClass, String param) {
        get("headerLabelContainer").setVisible(true);
//this part is what won't work:
            ((WebMarkupContainer) 
get("headerLabelContainer")).get("detailView").setModel(new 
Model(UserHistory.class));
                // i tried also new bookmarkablepagelink(...), but the 
problem is the same, the link is pointing to the pre-declared page...
...
}

The HTML code is:

<div class="header" wicket:id="headerLabelContainer">
<a wicket:id="detailView" class="btn"><img 
src="images/btnDetailView.gif" alt="Részletes nézet" /></a>
                </div>

So the simple question would be: how to change the bookmarkablepagelink 
model?
The header also has a Label, which changes by pages, with the 
setModel(new Model("new text")); command...
I can't figure out what the problem is.

Regards,
Peter Major

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


Re: How to change BookmarkablePageLink Model?

Posted by jWeekend <jw...@cabouge.com>.
Peter,

Create a Panel or Fragment that takes the page you want to link to in its
constructor (or returns it in an abstract getPageToLinkTo() method). This
will contain your BPL (you can still embed your static img tag in the
associated html) and you can set the whole Panel/Fragment to be invisible by
default (or just do it in your template page) and let subclasses
override/set the visibility as required.

Regards - Cemal
http://www.jWeekend.co.uk jWeekend 


aldaris wrote:
> 
> Hi all,
> 
> In my project, i would like to change the link for an image in different 
> pages, where the image is in the header (which is in the base class of 
> pages).
> The code snippet i tried:
> 
> //This is my base class for the other pages
> public class PageTemplate extends WebPage {
> 
> ...
> //The base class constructor
> public PageTemplate(){
> WebMarkupContainer headerLabelContainer = new 
> WebMarkupContainer("headerLabelContainer");
>         add(headerLabelContainer);
> //I have to set a default value, so it would be declared for wicket, so 
> when i have a page, which i don't want to contain this imagelink, there 
> won't be a problem
>         headerLabelContainer.add(new BookmarkablePageLink("detailView", 
> ShowUser.class)).setVisible(false);
>                                     }
> ...
> 
> public void setHeaderDetailViewLink(Class pageClass, String param) {
>         get("headerLabelContainer").setVisible(true);
> //this part is what won't work:
>             ((WebMarkupContainer) 
> get("headerLabelContainer")).get("detailView").setModel(new 
> Model(UserHistory.class));
>                 // i tried also new bookmarkablepagelink(...), but the 
> problem is the same, the link is pointing to the pre-declared page...
> ...
> }
> 
> The HTML code is:
> 
> <div class="header" wicket:id="headerLabelContainer">
>   images/btnDetailView.gif  
>                 </div>
> 
> So the simple question would be: how to change the bookmarkablepagelink 
> model?
> The header also has a Label, which changes by pages, with the 
> setModel(new Model("new text")); command...
> I can't figure out what the problem is.
> 
> Regards,
> Peter Major
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-change-BookmarkablePageLink-Model--tp21795106p21795544.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