Hi all,

I'm a new user to wicket.  I'd heard some good things about it so I thought I'd 
try it out for a mini-web project I have.

Using Wicket 1.4.18 and Java 6.  I have an existing application using Spring 
(@Autowired everywhere) and I want to use some of the existing spring beans.

In the short term I've got an existing set of static web pages done by a web 
designer as a template that I want to have the content driven from our DB.  
Wicket seemed like a good choice because it doesn't touch the view file much 
(add some wicket:id attributes).

I've got a basic Application up, running on embedded Jetty server, with a 
welcome page which use @SpringBean to inject a couple of beans.  That all works 
fine.

However I can't figure out how to get URLs other than / to work.  If I go 
http://localhost:9090/ it works ok, I get the welcome page and the Java 
executes.  If I go to http://localhost:9090/HomePage.html it renders the page 
but doesn't invoke the wicket Java component so the label doesn't get rendered 
with the correct text.  I'm sure this is incredibly basic, but how do I get 
this to work properly?

Cheers.


My Application and home page classes below + web.xml.


// application class
public class WebPortalApplication extends WebApplication
{
    public Class<? extends Page> getHomePage()
    {
        return HomePage.class;
    }

    @Override
    protected void init()
    {
        ClassPathXmlApplicationContext applicationContext = new 
ClassPathXmlApplicationContext( "META-INF/config/spring/web-portal.xml" );
        applicationContext.start();

        addComponentInstantiationListener( new SpringComponentInjector( this, 
applicationContext, false ) );
    }
}


// home page
public class HomePage extends WebPage
{
    @SpringBean
    private HibernateOperations hibernateOperations;

    public HomePage()
    {
        add( new Label( "message", "Hello World!" ) );
    }
}



// web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd";>

<web-app>
    <display-name>Wicket Examples</display-name>
    <filter>
        <filter-name>HelloWorldApplication</filter-name>
        
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
          <param-name>applicationClassName</param-name>
          <param-value>com.xxx.webportal.WebPortalApplication</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>HelloWorldApplication</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

Reply via email to