Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-30 Thread Ned Collyer
Sure I can appreciate that :) However I define my panels to accept certain objects to chuck into the model, so thats fine. It means I can provide translations for pojos from non wicket jars using a method similar to wickets nice 1 class, 1 property file approach. Eg, mypanel extends panel {

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-30 Thread Igor Vaynberg
On Wed, Apr 30, 2008 at 2:55 AM, Ned Collyer [EMAIL PROTECTED] wrote: Still - would be nice if the MarkupInheritanceResolver$TransparentWebMarkupContainer somehow indicated it was the the page (and returned the pages model). Component c=...; boolean page=(c==c.getPage()); -igor I

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Michael Sparer
yepp, then the TransparentWebMarkupContainer gets passed in. And you're right, it's gonna be a filthy hack if you try to find out if its a Page. Unfortunately I've got no further suggestions but it'd be interesting to know why you want to distinguish between pages and other components anyway ...

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Ned Collyer
Thanks for your reply, Maybe it's because I am using a wicket:message key=foobar/ in the markup?! There isn't really any code to show. I put the wicket:message into the page, then i check the params coming in to the method. I'll have a bit more of a play I think, but I would be interested in

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Ned Collyer
I basically want the components Model. It's legitimate for it to be null. So, if I can see which component is a page, then i can easily call the getPage().getModel() Of course if it's TransparentWebMarkupContainer then getModel returns null even if the page has a model set. It appears to work

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Ned Collyer
I did an elegantish... workaround. - the page instantiates a panel - the panel has the model. Basically my pages defer almost everything to panels - and I guess it also aids in their reuse/embeddability. I'm quite familiar with instanceof thanks ;) Michael Sparer wrote: well one (as said

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Igor Vaynberg
Page page=component.getPage() ? -igor On Tue, Apr 29, 2008 at 3:53 AM, Michael Sparer [EMAIL PROTECTED] wrote: well one (as said ugly ;-)) way that comes to my mind is to ask if component.getParent().getParent() instanceof Page (that should also work if you use nested subpages).

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Igor Vaynberg
sorry, but i dont really get what the problem is or why it matters what component stringresourceloader gets. it simply traverses up the hieararchy looking for .properties files -igor On Tue, Apr 29, 2008 at 4:55 PM, Ned Collyer [EMAIL PROTECTED] wrote: Do you know an elegant solution Igor?

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Ned Collyer
I'm writing my own It does this @Override public String loadStringResource(Component component, String key) { if (component == null) { return null; } String result = null; Locale locale = component.getLocale(); String style =

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-29 Thread Igor Vaynberg
hm. dont know if doing localization based on type of model object is a great idea. there are many usecases where model type is quiet aribitrary, and as you have found out yourself you dont know what component you get passed in, so you just need to handle it in a way that makes sense to you. -igor

Re: loadStringResource(Component component, String key) - correct method to check if the component IS a Page?

2008-04-28 Thread Michael Sparer
comp instanceof Page ? or am I misunderstanding somethin? Ned Collyer wrote: Hi, I've written my own class that extends ComponentStringResourceLoader (i might change it to extend some other class) At any rate, when loadStringResource(Component component, String key) is called, and