开发者

How to go about creating a first startup wizard with Wicket? (Database table creation etc.)

开发者 https://www.devze.com 2023-01-07 16:52 出处:网络
I\'m working on a Java Web Application with Wicket, Spring and Hibernate. The web application is not particularily large (I have one DAO and one service), but I\'d like to offer the users that deploy

I'm working on a Java Web Application with Wicket, Spring and Hibernate. The web application is not particularily large (I have one DAO and one service), but I'd like to offer the users that deploy the application a startup wizard much like the ones found in Wordpress.

When the webpage is accessed for the first time (no database tables are created / no users), I want the user to be able to enter database settings (username, password, database name, database type) and then I want the web application to create all the tables that it will use.

As I'm new to Wicket and Java Web Deve开发者_运维技巧lopment I'm not sure how one would go about achieving this. Usually, when interacting with the DAO (such as creating a user) the database table is created on demand (if it didn't already exist) -- at least that's what it looks like to me.

Is there a way to extract the SQL for mye domain objects that my application will use via the service->DAO layer?

Right now I configure database access via filters; src/main/config/application-DEV.properties for example. If I want to use a wizard such as described I guess I would need to move away from using property files?

Any help is greatly appreciated.


I have often contemplated this, as it is standard practice in many PHP / Perl systems, but seems complicated in java / spring etc.

First of all: use wicket-extensions for the wizard functionality

What I would do then is simple, I'd declare all my spring beans as lazy and use system properties to configure them (with a PropertyPlaceHolderConfigurer). I'd use the wizard to get those properties the first time and then write them to a well-known location in the file system (DB would be better, but that's a chicken / egg problem). Then I'd initialize the application context using the system properties.

The problem here is: I don't think there is a portable way to access the file system from a web application, I think every app server may handle file system access differently, so you need to be careful there.

0

精彩评论

暂无评论...
验证码 换一张
取 消