Submit Datatable: Spring - spring

I have a datatable on my jsp populated by a "java.util.Set" collection that came from a Hibernate search. I want to make this datatable editable and then save the edited table on my database. I'm able to do it if the datatable is formed through List collection object. All my POJO objects are formed with Set Collection and I'm trying to avoid changing all of them.
I'm using Spring MVC and as I told before Hibernate.
Thanks.
Regards.

It seems that it's possible to use a Set to display data in a JSP but you can't modify them.
Take a look of this link.

Related

How to create html element for each object in collection?

I have String like this:
{"response":{"count":997,"items":[{"id":2943,"first_name":"Vasya","last_name":"Babich","can_access_closed":true,"is_closed":false,"screen_name":"antanubis","track_code":"24fc13d6ZwhuhzyM9V1oRkohiruY-zXeoP1aliqA-1dA4qgxJrQAYSTQYe6kVWsTTKkXWWybQrHU"},{"id":231329886,"first_name":"Vasya","last_name":"Babich","can_access_closed":true,"is_closed":false,"screen_name":"lydka_lydka_lydka","track_code":"a348ab0aAo3CxaTAGsTDu4mpMdBMMjYxgAmOnr7PvUWgaanh141l5NGe_PlLz8a8unX1eOUxXj-GCo6esKk"}]}}
I want to show each value of "items" to user in browser and then user should be able to select one of them and save in database and in his own page in the website. I guess I should use loop and create html element for each item. But how to do this? What data type should I use to manipulate this data and store it?
Thymeleaf is the most widely used view/template engine with Spring Boot and can handle your loop requirement. Spring MVC enables you to manage your app behavior and define the data bound to HTML pages (views). You will need a database and there are lots of options. Check out Spring Data which makes it easy to work with all major database technologies.

creating dynamic records in single form using JS and store the info in a List or set object using spring mvc

I need to create form fields like name , age and city inside a form and this should happen every time i click add record. i dont want multiple forms all dynamic group should be created within a single form. on submitting the data should be taken by controller using modelattribute, and store in arraylist or any ...help out to find it. i have used following links and almost got it but unfortunately got deleted.
https://viralpatel.net/blogs/spring-mvc-multi-row-submit-java-list/
http://www.nobukimi.com/?p=237
answer
https://netjs.blogspot.com/2018/09/spring-mvc-binding-list-of-objects-example.html

JSF update changed values only

I´ve tried to get some informations about my idea, but still haven´t.
I wan´t to know, if there´s a way to achieve this:
I´m using a primefaces <p:dataTable> to display a list of items. For updating my table if some entries changed, I´m using datatableWidgetVar.filter() within the oncomplete event of <p:ajax>. Because the handled lists are pretty big (~50k-100k entries) it takes a few secs to 'update' the dataTable by its filter method and there is a 'flickering' I´d like to remove...
I don´t want the user to see, that components are reloaded, I mean it should be more 'smooth'. Is there a way to compare those 2 lists and only update the changed rows, so I don´t need to rerender 50,000 items? Or shall I pass the changed items (by id maybe?) to my jsf page and select the rows that are affected? Does primefaces offer such a algorithm?
Thanks in advance, let me know if you need some code or more details ;)
EDIT:
I´ve been thinking about that again and what about:
access the dataTable´s underlying list of items (client-side)
compare the server-side (newer) list with the (older) client-side one
get the changed (modified,added,removed) entries
force my dataTable to update only those 'rows'
Is this a good practise?

LINQ to filter properties by custom attributes

I am using EF code-first and I have put a custom attribute on some of the fields in a model, which I want to exclude(like, I dont want to send the Id attribute value to client side).
Now, I need to return only the columns which doesn't have the attribute.
Right now, I am thinking to do it in 2 steps: Get all the data then filter by the attribute.
But I know, this can be done in a single query.
Please help.

How to Bind Data coming from DB to spring input tag

i have the following scenario.
I have a list of auctions coming from the DB. I am displaying each auction properties on the JSP page as a record.
I am using spring 3.0.5, Tomcat 6.0.29 and eclipselink as JPA provider.
In my controller i am seeting this list as model attribute and passing it to the JSp page.
I want to use spring tags (form:input) to display the data.
Using Form backing bean we can display default values on a form. But in my case is there any way to bind data to form:input tag in the JSP?
Thanks
There is no reason to display your data in form:input tags other than that you want to allow your user to edit the data. If that is not the case, then using form:input just to display the data is pointless.
If you want to allow your user to edit the data, how are you going to get back the changes he has done? Obviously you are going to need your Command object. So there is no reason not to use formBackingObject() in your FormController to set values in your Command object, which will be consequently displayed on your JSP. When user will make any changes and submit the form, you will get all those modified values in your Command object which you can process in onSubmit() method of your FormController.

Resources