Re: dynamic crumb trail

2010-09-25 Thread LutherBaker

Ah yes, a closure of sorts. Thanks, that was exactly what I was looking for.


Since I am passing this to 'super', one issue popped up. I'd like to use a
StringResourceModel (and leverage some parameter substitution) but
obviously, at page instantiation time, my current page doesn't exist and
consequently, can't be used as the StringResourceModel's Component
parameter.


AreaPage.java
...
private static Crumb createCrumb(final Area area) {
return new Crumb() {

private static final long serialVersionUID = 1L;

public WebPage createReponsePage() {
return new AreaPage(area);
}

public IModel label() {
return new 
StringResourceModel(AreaPage.crumb.label,
null,
new Model(area));
}
};
}

public AreaPage(final Area area) {
super(createCrumb(area));


Note the 'null' in the StringResourceModel ctor since I can't pass 'this'
before super(..) completes.


This works for me as long as AreaPage.crumb.label is in my global
properties but the docs discourage said practice so maybe there is another
tweak I can apply?


-Luther





Igor Vaynberg-2 wrote:
 
 create a wrapper that can instantiate pages lazily
 
 interface Crumb { IModel getLabel(); Page gePage(); } put your lazy
 logic into getPage() impl.
 
 -igor
 

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/dynamic-crumb-trail-tp2550978p2713647.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: dynamic crumb trail

2010-09-25 Thread Igor Vaynberg
you dont want to pass a crumb around that contains references to other
pages anyways, i would put all the resources that crumbs need into the
application-scoped properties file.

-igor

On Sat, Sep 25, 2010 at 9:35 AM, LutherBaker lutherba...@gmail.com wrote:

 Ah yes, a closure of sorts. Thanks, that was exactly what I was looking for.


 Since I am passing this to 'super', one issue popped up. I'd like to use a
 StringResourceModel (and leverage some parameter substitution) but
 obviously, at page instantiation time, my current page doesn't exist and
 consequently, can't be used as the StringResourceModel's Component
 parameter.


 AreaPage.java
        ...
        private static Crumb createCrumb(final Area area) {
                return new Crumb() {

                        private static final long serialVersionUID = 1L;

                        public WebPage createReponsePage() {
                                return new AreaPage(area);
                        }

                        public IModel label() {
                                return new 
 StringResourceModel(AreaPage.crumb.label,
                                                null,
                                                new Model(area));
                        }
                };
        }

        public AreaPage(final Area area) {
                super(createCrumb(area));


 Note the 'null' in the StringResourceModel ctor since I can't pass 'this'
 before super(..) completes.


 This works for me as long as AreaPage.crumb.label is in my global
 properties but the docs discourage said practice so maybe there is another
 tweak I can apply?


 -Luther





 Igor Vaynberg-2 wrote:

 create a wrapper that can instantiate pages lazily

 interface Crumb { IModel getLabel(); Page gePage(); } put your lazy
 logic into getPage() impl.

 -igor


 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/dynamic-crumb-trail-tp2550978p2713647.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 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



Re: dynamic crumb trail

2010-09-25 Thread Igor Vaynberg
alternatively, instead of passing the new crumb to super, you can pass
around the entire trail, that way you can say

super(trail);
trail.add(new crumb(getstring(my.page.resource)));

-igor

On Sat, Sep 25, 2010 at 9:53 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 you dont want to pass a crumb around that contains references to other
 pages anyways, i would put all the resources that crumbs need into the
 application-scoped properties file.

 -igor

 On Sat, Sep 25, 2010 at 9:35 AM, LutherBaker lutherba...@gmail.com wrote:

 Ah yes, a closure of sorts. Thanks, that was exactly what I was looking for.


 Since I am passing this to 'super', one issue popped up. I'd like to use a
 StringResourceModel (and leverage some parameter substitution) but
 obviously, at page instantiation time, my current page doesn't exist and
 consequently, can't be used as the StringResourceModel's Component
 parameter.


 AreaPage.java
        ...
        private static Crumb createCrumb(final Area area) {
                return new Crumb() {

                        private static final long serialVersionUID = 1L;

                        public WebPage createReponsePage() {
                                return new AreaPage(area);
                        }

                        public IModel label() {
                                return new 
 StringResourceModel(AreaPage.crumb.label,
                                                null,
                                                new Model(area));
                        }
                };
        }

        public AreaPage(final Area area) {
                super(createCrumb(area));


 Note the 'null' in the StringResourceModel ctor since I can't pass 'this'
 before super(..) completes.


 This works for me as long as AreaPage.crumb.label is in my global
 properties but the docs discourage said practice so maybe there is another
 tweak I can apply?


 -Luther





 Igor Vaynberg-2 wrote:

 create a wrapper that can instantiate pages lazily

 interface Crumb { IModel getLabel(); Page gePage(); } put your lazy
 logic into getPage() impl.

 -igor


 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/dynamic-crumb-trail-tp2550978p2713647.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 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



dynamic crumb trail

2010-09-22 Thread Luther Baker
I have a default template page that contains a ul implementation of a
crumb trail. Therefore, the base class template has both the open and close
tags of the list element. A few links in the crumb trail are manage by the
template class - but I'd like to be able to add a few from the child pages.

I've tried passing a list of 'response' Pages and labels from the child to
the parent but some of the page need to be instantiated and passed arguments
and I end up instantiating response pages before the user ever clicks on a
link.

Can someone chime in with a more elegant approach to this? I feel like I'm
going down a rabbit hole. I guess I could simply create a panel - but then
I'd need to get links from two places ...

Thanks,
-Luther


Re: dynamic crumb trail

2010-09-22 Thread Igor Vaynberg
create a wrapper that can instantiate pages lazily

interface Crumb { IModel getLabel(); Page gePage(); } put your lazy
logic into getPage() impl.

-igor

On Wed, Sep 22, 2010 at 1:01 PM, Luther Baker lutherba...@gmail.com wrote:
 I have a default template page that contains a ul implementation of a
 crumb trail. Therefore, the base class template has both the open and close
 tags of the list element. A few links in the crumb trail are manage by the
 template class - but I'd like to be able to add a few from the child pages.

 I've tried passing a list of 'response' Pages and labels from the child to
 the parent but some of the page need to be instantiated and passed arguments
 and I end up instantiating response pages before the user ever clicks on a
 link.

 Can someone chime in with a more elegant approach to this? I feel like I'm
 going down a rabbit hole. I guess I could simply create a panel - but then
 I'd need to get links from two places ...

 Thanks,
 -Luther


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