I am trying to learn Java and Javascript. Currently I following MVC, where i have servlets that will send data from a table to a JSP and I disply the data in table.
i am trying to make this table editable and create a good look and feel of the table using DataTable, however i am not sure how or where to start..Can someone please help me on this. I am a beginner and any simple example on on how to use DataTable would really help?
Thank you!
There are several examples here: http://datatables.net/examples/
Datatables is a great plugin if you want to show the data. But in my experience, it is not simple to interact with the server.. Like... add a new tr and create an instance on database using java. It is complicated this interaction.
In my experience, I would use primefaces datables: http://www.primefaces.org/showcase-labs/ui/datatableBasic.jsf;jsessionid=1si9n7bh9e6921gz0mj3w42ew3
Related
I am planning to implement pagination in my JSP using DataTables. I previously implemented it using DisplayTag Library but looks like it is getting old now. I couldn't find a good example or a resource about Datatables on how to do it in a JSP. I have a list of object in my JSP and intended to show 10 records per page. With DisplayTag I did it very easily but with DataTables I am not exactly sure if it is straight forward and the changes would just be in the JSP. I want some thoughts or if there is any other library out there to help accomplish my goal.
Thanks.
Go with this link.
DatabaleExample
I wrote sql but it takes more time when execute it in jsp. And I want to make faster it. Will grid view make the page faster?
I'm junior in Java. I researched in google but didn't find clear sample about gridview. Can u help me?
I understand you have a web based application backed by the DB.
Note that gridview is not something offered by Java, instead you can create tables by using your web frameworks and render data there.
You say, it takes a lot of time to execute an SQL when running withing JSP. Where the time goes?
Running the SQL itself? Maybe creating a JSP or transmitting it to the client browser in an Html form, or even maybe the rendering of your table in browser?
You should detect the bottleneck in order to understand what you're going to fix
Consider to use profiler and see (at least on server vm) where the time goes.
I think JVisualVM will suit your needs here.
Hope this helps
I would have done this task using following steps
Create one servlet.
Connect to the database and fetch the data which we have to display.
Create a list and keep the data in list it.
Set the list in request and forward the control to JSP.
On JSP, use DisplayTag to show the data in grid form.
Hope this helps you.
My requirement is I need to populate dyanamic graphs in a jsp page. I am using jsf for my project. I planning to use "jfreecharts" but dont know how to bind my jsp page with the back bean. I have some drop downs on the basis of the selection I my BackBean is fetching the data from the DB. Can you please suggest me some procedure to that with some sample code for my reference?
You can use Fiji (Exadel) library.
They have charts, as well as support for wrapping SWF elements and sending properties in JSF.
See an example here. For each component, there is source code as well so you can try it yourself.
Primefaces has a nice chart component as well.
Fiji is very nice but check out this http://www.fusioncharts.com/
Can someone point to jqgrid + java web app solution or especially with populating the grid and sending the form back to server. there are several php examples but nothing on java.
If you want to use some advanced tools like Spring, Hibernate and Maven here is the good example.
http://krams915.blogspot.in/2012/01/spring-mvc-31-jqgrid-and-spring-data_1887.html
EDIT:
See this, if you want to use plain Servlet and JSP. This is very basic example.
http://javahunter.wordpress.com/2010/12/07/jqgrid-example/
Here is one example on the web:
jqGrid Forum: how-use-jqgrid-in-jsp-server-one-example
If you are using struts2 there's a plugin which includes jqueryui and jqgrid components.
http://struts2-jquery.googlecode.com/
For a long time in the Java/JSP world I used to use the Display Tag library to generate a table that would allow you to sort a table, and export the table as a CSV file.
Is there anything like this in a PHP library that I could use?
The answer, from my searching, appears to be no. I wanted one too--love displaytag.
If you want a php only solution, Structures_DataGrid seems to be the best solution. Here's an article about it. This handles paging and sorting, but no exporting. Not sure how supported it is, either.
Another answer appears to be to use javascript to do paging and sorting, and roll your own php export functionality.
The state of the web is significantly different than it was when displaytag was created (ie, AJAX supported with a rich toolset), so I'm not sure there ever will be a full replacement. Why do sorting and paging with a call to the server when you can do it on the client?
Here's a jquery plugin that supports paging and sorting, and here's another one--all you need to do is have your php generate the table correctly.
As far as CSV exporting, there are tons of snippets out there. Here's one that looked good to me.
As far as I know PHP can't dynamically change the page (for sorting the table etc). You'd probably need to use something like javascript. I know that jquery has a table sort library.
PHP could do the CSV output. Make a link to a page that queries the database and uses the header() function to output a csv file - like this. Stackoverflow also has a couple similar solutions.
Good luck!
I think there is a method to deal with CSV in PHP. It is fputcsv(). It doesnt sort a table or anything like that it just converts an array into one line of csv.
Here is a link to it on the PHP website:
http://us.php.net/manual/en/function.fputcsv.php
You could try a scaffolder like -- http://www.aaronharp.com/2008/08/30/php-scaffold-class/ or -- cakephp. I don't think there is an included function that does that though.