开发者

JSF - correct way to build forms

开发者 https://www.devze.com 2022-12-13 00:39 出处:网络
Ok, i wish to know the correct way to build forms in JSF. I have multidatabase app(user can switch databases during runtime, all databases are build on the same scheme) and now i want to build forms f

Ok, i wish to know the correct way to build forms in JSF. I have multidatabase app(user can switch databases during runtime, all databases are build on the same scheme) and now i want to build forms for data input.

I tried build functionalities in NetBeans, where i can generate entity classes from database, but, as far as i understood, this way correctly works only in case, i have one database. For my DB connections i use Hibernate. I already completed part, where i can switch between databases.

Maybe, there are some advic开发者_开发百科es, how i can build forms for app? Preferable will be dynamic form build, it can be from XML file. Looking forward for your replies!


If your application is really divided into independent layers (DAO / Service / presentation for example, or MVC if you prefer), then the presentation layer, which is managed by the JSF framework, must not be impacted by the database connection.

You say that every database uses the same structure, so I don't really think that your JSF forms design and structures will be impacted by the database chosen by the user. This parameter will be taken into consideration in the deeper layers of your application, the ones managed by Hibernate in particular.

So to answer your question, I would say that you don't have to care about this specificity when designing your pages with JSF. So use the "default" best practices for JSF developments.


Have a look at how Seam does it with the Seam-gen tool. It will generate the entire application - including forms - from the database. It's based on Freemarker templates.


There is no such thing as "correct way" of building forms. It all depends on the functional requirements and what all is available.

If the forms are purely meant as kind of "database admin tool", then you need to build from the DB to the UI (bottom-up approach).

If the forms are purely meant to give the enduser some functionality (e.g. register form, order form, contact form, etc), then often a top-down approach (build from UI to DB) is preferred.

In your case it's likely the bottom-up approach. You're lucky, there are much more generators/tools for that available (as you probably already have found out). As long as you keep everything abstract, I don't forsee (re)usability and maintainability problems.

However, it is possible to "convert" some XML file to a JSF (XHTML) page with little help of XSL and a Filter.

0

精彩评论

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

关注公众号