You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Arjun Dhar <dh...@yahoo.com> on 2011/07/29 21:04:55 UTC
Advanced Mounting & Markup Location
When Locating the Markup for a Page, I want to know the corresponding class
(associated with the page/markup).
Currently Im directing Wicket to my Custom Markup location with the
following code in "Application":
...
final IResourceStreamLocator defaultLocator =
super.getResourceSettings().getResourceStreamLocator();
return new ResourceStreamLocator(){
@Override
public IResourceStream locate(final Class<?> clazz, final String
path) {
...
//Figure alternate path by reading path
....
//if valid URL not found use the defaultLocator
...
}
...
I want to get the associated Component class. I know the String "path"
represents the ClassPath, but its still a String and contains Locale Junk &
an extension with it.
Is there someway I can get Class<?> directly so I don't have to do String
manipulations?
Another thing I want is, when the dynamicPage (which --extends-->
TemplatePage --extends--> WebPage) appears it knows its associated
"Template" DataStructure details.
TemplatePage - Wicket Component
Template - Data Structure
TemplatePage <---> Template
When Mounting, on init() in Application:
application.mount(new QueryStringUrlCodingStrategy(pagePath, [Templace
Class] ));
During the mount itself, is there anyway for me to associate/pass models to
the pages which will be constructed?
Wicket uses no-arg Contstructors for WebPage, but what if I want to pass a
WebPage contexutal info specific to the Page while mounting? (Can i do
this?) --> I believe this would be efficient
-----
Software documentation is like sex: when it is good, it is very, very good; and when it is bad, it is still better than nothing!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Advanced-Mounting-Markup-Location-tp3705032p3705032.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: Advanced Mounting & Markup Location
Posted by Arjun Dhar <dh...@yahoo.com>.
ok its embarassing to have to post the answers to your questions, heh but
this is one is for less fortunate:
In my application I could pass the Class of the MarkupContainer (rather than
the class that loads the markup)
/**
* The {@link DefaultMarkupResourceStreamProvider#getMarkupResourceStream};
derives the path
* from the "Class<?> containerClass" and passes it to the {@link
IResourceStreamLocator#locate} method.<br />
* It also passes the MarkupContainer class to the {@link
IResourceStreamLocator#locate} method. This class is useless in our case,
* and there is more value in getting the actual "Class<?> containerClass".
Simple swap which class is passed to the locate mothod.
*/
protected void tweakMarkupCacheStreamProvider() {
getMarkupSettings().setMarkupCache(new MarkupCache(this) {
private IMarkupResourceStreamProvider markupResourceStreamProvider;
/**
* Get the markup resource stream provider to be used
*
* @param container
* The MarkupContainer requesting the markup resource stream
* @return IMarkupResourceStreamProvider
*/
protected IMarkupResourceStreamProvider getMarkupResourceStreamProvider(
final MarkupContainer container)
{
if (container instanceof IMarkupResourceStreamProvider)
{
return (IMarkupResourceStreamProvider)container;
}
if (markupResourceStreamProvider == null)
{
/*
* Most of the code of the original {@link
DefaultMarkupResourceStreamProvider} is untouched,
* except the line that calls the locate(...) method!
*/
markupResourceStreamProvider = new
DefaultMarkupResourceStreamProvider() {
public IResourceStream getMarkupResourceStream(final MarkupContainer
container, Class<?> containerClass)
{
...
...
//container.getClass() replaced with containerClass below :::
IResourceStream resourceStream = locator.locate(containerClass, path,
style, locale, ext);
...
...
}
};
}
return markupResourceStreamProvider;
}
});
}
Request to the Developers ::
One particularly disturbing thing I've seen in certain wicket components
(maybe an oversight); is that if you dont have POJO style getter() &
setter() on your components; then non final variables should be declared
"protected" not private. There is no point providing overriding methods that
use private variables, to which the child class has no access.
thanks
-----
Software documentation is like sex: when it is good, it is very, very good; and when it is bad, it is still better than nothing!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Advanced-Mounting-Markup-Location-tp3705032p3705848.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