check this out, add the following method to your
WebApplication implementation class.
public ResourceStreamLocator
getResourceStreamLocator()
{ final
ResourceStreamLocator defaultLocator =
super.getResourceStreamLocator();
return new
ResourceStreamLocator(new AbstractResourceStreamLocator()
{ public
IResourceStream locate(ClassLoader loader,final String path, final String style,
final java.util.Locale locale,final String
extension)
{
IResourceStream stream = super.locate(loader, path, style, locale,
extension);
if (stream == null)
{
return defaultLocator.locate(loader,path, style, locale,
extension);
}
return
stream;
}
protected IResourceStream locate(ClassLoader classLoader, String path)
{
String skin =
null;
String skinPath =
null;
skin =
path.substring(path.lastIndexOf('/'),
path.length()); /* if
the page is Foo_Bar.java skin will be
Foo_Bar.html add logic to rename it to
Foo-Bar.html or to what ever based on ur
requrement set the value of skin to your
new html file name skin = new
value */ path
=
path.substring(0,path.lastIndexOf('/')); skinPath
= path.substring(path.lastIndexOf('/'),
path.length())+skin;
try
{
final URL url =
"">
.getResource(skinPath);
if (url != null)
{
return new
UrlResourceStream(url);
}
} catch(MalformedURLException e) {
}
return
null;
}
}); }
----- Original Message -----
Sent: Thursday, October 20, 2005 12:57
PM
Subject: Re: [Wicket-user] Markup and
matching Java class
For Foo_Bar.java wouldn't Wicket be expecting Foo_Bar.html and
not Foo-Bar.html? Unless there is a way I can do some mapping (which I
currently don't know how) telling Wicket that during rendering of
Foo-Bar.html it should use Foo_Bar.java. Or am I missing something
here?
Francis
On 10/20/05, Dipu
<[EMAIL PROTECTED]>
wrote:
If there is any specific pattern in which your
HTML files will be named then you can add
logic to pick up the correspoding HTML
file looking at the java class name.
for example when you are trying to
load page with the name Foo_Bar.java you can map
Foo-Bar.HTML as the mark up.
hope this helps
regards
Dipu
-----
Original Message -----
Sent:
Thursday, October 20, 2005 7:56 AM
Subject:
Re: [Wicket-user] Markup and matching Java class
Juergen,
It seems the howto is talking about
locating markups in different places other than the default class package
where the markup's class is defined. That I know is possible. But let
me be more specific with my question.
Say I have a html
Foo-Bar.html. Wicket requires me to have a class Foo-Bar.java, right? But
as you know Foo-Bar is an illegal name for a Java class because of the
character '-'. How do you create the class for
Foo-Bar.html?
Francis
On 10/19/05, Juergen Donnerstag <[EMAIL PROTECTED]> wrote:
Please
see http://www.wicket-wiki.org.uk/wiki/index.php/Howto and
the two entries in the Configuration
section.
Juergen
On 10/19/05, Francis Amanfo < [EMAIL PROTECTED]>
wrote: > Hi all, > > This requirement of
Wicket that a markup and its corresponding Java class > must have
the same name is violating a usecase that I have. The generated >
markup from sources I have no control on have sometimes filenames
containing > identifiers like the hyphen which is not legal to
appear in Java class > names. So my question is does anyone has a
trick I can use to overcome this > shortcoming? For example,
Foo-Bar.html can't have a class Foo-Bar.java. How > can this be
solved in Wicket without renaming the markup
file? > > Francis >
-------------------------------------------------------
This SF.Net email is sponsored by: Power Architecture Resource
Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________ Wicket-user
mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
|