Reputation: 31
I'm currently maintaining a web application using:
It's basically a CRUD application that lets users view data and manipulate them. It's almost as if it's a replica of the DBMS, only on the web. The code is full of SQL statements everywhere -- in almost each of the servlets in the application.
Currently, my manager is asking me to implement some sort of filters for the data.
Let's say we have a table SomeTable
:
Col1 Col2 Col3 Col4 Col5
---- ---- ---- ---- ----
data2 data3 data4 data5 data6
In the application, if you go to the SomeTable
page, you get to see the exact same data from the SomeTable
table, with the one exception that they're displayed in an HTML table. Now, what my manager wants is for the user of the application to be able to filter the data from a different page (let's call this filter page) and then after applying the filters, go back to SomeTable
page and display the filtered data.
In the filter page, they'll be able to choose something like:
Col1 = data2
Col3 LIKE %some%
Col4 IN 1,2,3
These options are all from select boxes. We currently have a functionality like that in one of the pages but it's ugly. SQL statements being passed around session attributes and concatenated with each other on the end. Plus, I can't really re-use them without copying all the code.
Someone probably invented something to deal with this and I'm wondering if anyone can give me a advice on how to approach this problem. Is there a framework that I can use or would it be easier to do it just by hand since the application is not really that big.
Upvotes: 3
Views: 3270
Reputation: 13512
I will suggest you look Here Primefaces
It is very rich user interface with no any Java Script Headache.
Upvotes: 0
Reputation: 8561
Generic Dao is one way you can make a template for all your DAOs. A lot of expertise have explained the usage of it. So I will just give references.
Single DAO & generic CRUD methods (JPA/Hibernate + Spring)
http://www.ibm.com/developerworks/java/library/j-genericdao/index.html
Upvotes: 1
Reputation: 6344
Another thing you could look at is AppFuse from Matt Raible. Check out the Demo's and Video's. There is one there for CRUD with Struts 2.
I used it ages ago and was really impressed with how it allows you to try different configurations of technology stacks to see how they work together. Well worth a look.
Upvotes: 1
Reputation: 80633
Sounds like your application is becoming more complicated. I've done the servlet/jsp straight to DB thing - it's not pretty. You could slap some prepared statements into the code to handle the new requirements, but in you bones I think you know its time for a framework, even if it's a simple one.
My recommendation would be Play. Its lightweight, fast, and has very little bloat. It also comes with Hibernate which is a helluva ORM framework.
Good luck!
Upvotes: 2